vanshu28

Create a Minecraft plugin for Paper 1.21.1.

Plugin Name: MoneyPaper

Purpose:

This plugin adds a special Paper item that stores money, mainly for crates, rewards, and admin distribution.

Core Features:

  • Special Paper item represents a fixed amount of money
  • Player can RIGHT CLICK the paper to claim money
  • Money is added to player's balance using Vault
  • Paper item is consumed after claim
  • Secure validation to prevent fake or edited items

Command Requirements:

Add an admin command to generate money paper.

Command:

  • /moneypaper <amount> [player]

Behavior:

  • If player is specified → give paper to that player
  • If player is not specified → give paper to command sender
  • Only players with permission can use it
  • Amount must be validated (positive number)

Permission:

  • moneypaper.give

Item Details:

  • Item type: PAPER
  • Custom name: §aMoney Voucher
  • Lore displays amount (formatted currency)
  • Actual amount stored securely in PersistentDataContainer

Technical Requirements:

  • Paper API 1.21.1
  • Vault economy support
  • Use PlayerInteractEvent for right-click detection
  • Use NamespacedKey for validation
  • Prevent duplication/exploit abuse
  • Async-safe economy handling
  • Clean console, no errors

Other:

  • Plugin must be lightweight and production-ready
  • No unnecessary features
  • Compatible with crate plugins

Output Required:

  1. Full Java source code
  2. Main plugin class
  3. Command executor
  4. Event listener
  5. plugin.yml
  6. Example usage of the command
  7. Short explanation of how the plugin works

Do NOT explain Minecraft basics.

Provide clean, optimized, production-ready code.

Kodari AI
KodariJan 11 at 3:08 pm 4,720 (v2)

I’ll create a secure money voucher plugin for Paper 1.21.1 with Vault integration.

MoneyPaper
A secure money voucher system that allows administrators to create special paper items representing currency. Players can claim the stored value by right-clicking the voucher, with money automatically added to their Vault economy balance. Features PersistentDataContainer validation to prevent duplication exploits and supports direct player distribution for rewards and crate systems.

Project created successfully! Here’s how it works:

Core Mechanics:

  • PersistentDataContainer stores the exact money value securely on each paper item

  • NamespacedKey (moneypaper:money_amount) ensures only plugin-created items are valid

  • Right-click detection uses EquipmentSlot.HAND to prevent double-firing

  • Item is consumed after successful claim

Security Features:

  • Validates amount is positive and finite (prevents NaN/Infinity exploits)

  • Checks PersistentDataContainer for authentic vouchers (prevents fake items)

  • Permission-based command access

  • Inventory space validation before giving items

Example Usage:

Plain Text
/moneypaper 1000          → Gives you a $1,000 voucher
/moneypaper 500 Steve     → Gives Steve a $500 voucher
/moneypaper 25000.50      → Supports decimals ($25,000.50)

Integration:

  • Works with any Vault-compatible economy plugin (EssentialsX, CMI, etc.)

  • Compatible with crate plugins - they can give the voucher as a reward

  • Async-safe economy calls (Vault handles this)

The plugin is production-ready with proper validation, formatted currency display, and exploit prevention.

vanshu28

Create a Minecraft plugin for Paper 1.21.1.

Plugin Name: MoneyPaper

Purpose:

This plugin adds a special Paper item that stores a money amount.

The item is mainly used for crates and rewards.

Core Behavior:

  • A special Paper item represents a fixed money amount
  • When a player RIGHT CLICKS the paper:

- The plugin runs a CONSOLE COMMAND: eco give <player> <amount> - <amount> must be taken from the paper itself - The paper item is consumed (removed) - Player receives a success message

  • No Vault API usage (command-based economy only)

Command to Create Paper:

  • /moneypaper <amount> [player]

Command Behavior:

  • Generates a special money paper
  • Amount must be a positive number
  • If player is specified → give to that player
  • Else → give to command sender
  • Permission required to use the command

Permission:

  • moneypaper.give

Item Details:

  • Item type: PAPER
  • Custom name: §aMoney Voucher
  • Lore displays the money amount (example: "$5,000")
  • Real amount must be stored securely using PersistentDataContainer
  • Fake or renamed papers must NOT work

Technical Requirements:

  • Paper API 1.21.1
  • Use PlayerInteractEvent
  • Detect RIGHT_CLICK_AIR and RIGHT_CLICK_BLOCK
  • Validate item via NamespacedKey
  • Execute command as CONSOLE using Bukkit.dispatchCommand
  • Remove item only after successful execution
  • Prevent duplication/exploit abuse
  • No console errors or spam

Compatibility:

  • Must work on offline-mode servers
  • Must work with any economy plugin that supports:

eco give <player> <amount>

  • Fully compatible with crate plugins

Output Required:

  1. Full Java source code
  2. Main plugin class
  3. Command executor
  4. Event listener
  5. plugin.yml
  6. Example command usage
  7. Short explanation of how it works

Do NOT explain Minecraft basics.

Provide clean, optimized, production-ready code.

Kodari AI
KodariJan 11 at 3:39 pm 9,089 (v2)

I’ll read the existing plugin files to check the current implementation against your requirements.

Analysis

The current implementation uses Vault API for economy integration, but your requirements explicitly state:

  • No Vault API usage (command-based economy only)

  • Execute eco give <player> <amount> as console command

  • Must work with any economy plugin that supports that command

I need to completely rewrite the plugin to remove Vault dependency and use console command execution instead.

Changes Required:

  • Remove Vault dependency from build.gradle and plugin.yml

  • Remove Economy setup from main class

  • Change listener to execute console command instead of Vault API

  • Update item name from “Money Voucher” to “§aMoney Voucher” (legacy color)

  • Simplify lore formatting to use legacy colors

Summary

Complete rewrite to use console command execution instead of Vault API:

Key Changes:

  1. Removed Vault dependency - No longer requires Vault plugin

  2. Console command execution - Uses Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "eco give <player> <amount>")

  3. Legacy color codes - Uses ChatColor instead of Adventure Components for maximum compatibility

  4. Secure validation - Only papers with valid PersistentDataContainer data work

  5. Item consumption - Paper removed only after successful command execution

  6. Offline-mode compatible - Uses player names, works on cracked servers

How It Works:

  • Command creates paper with amount stored in PersistentDataContainer

  • Right-clicking executes eco give command as console

  • Item removed only if command succeeds

  • Fake papers without PDC data are ignored

Example Usage:

Plain Text
/moneypaper 5000          → Give yourself $5,000 voucher
/moneypaper 10000 Steve   → Give Steve $10,000 voucher

Compatible with: EssentialsX, CMI, UltraEconomy, or any plugin supporting eco give command.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
6 246
src/main/java/com/moneypaper/MoneyPaper.java
package com.moneypaper;

import org.bukkit.NamespacedKey;
import org.bukkit.plugin.java.JavaPlugin;

public class MoneyPaper extends JavaPlugin {
    private NamespacedKey moneyKey;
    
    @Override
    public void onEnable() {
        moneyKey = new NamespacedKey(this, "money_amount");
        
        getCommand("moneypaper").setExecutor(new MoneyPaperCommand(this));
        getServer().getPluginManager().registerEvents(new MoneyPaperListener(this), this);
        
        getLogger().info("MoneyPaper enabled successfully!");
    }
    
    @Override
    public void onDisable() {
        getLogger().info("MoneyPaper disabled.");
    }
    
    public NamespacedKey getMoneyKey() {
        return moneyKey;
    }
}