maxpro game
๐Ÿ“Ž 1 file 4,730 chars
๐Ÿ“„
pasted-code-1790012900186.txt
txt 223 lines
โ–ถ
Create a complete Minecraft **Paper 1.21.1** plugin called **ShopGUI**.

### Main Requirements

Create ONE standalone plugin with **no Vault dependency**.

#### 1. Shop GUI

* `/shop` opens a clean chest-style GUI.
* Add multiple categories:

  * Blocks
  * Ores
  * Farming
  * Food
  * Mob Drops
  * Nether
  * Building
  * **Spawners**
* Add many Minecraft 1.21.1 items to the shop.
* Every item must have configurable:

  * Buy price
  * Sell price
  * Display name
  * GUI slot
* Left-click an item to buy.
* Right-click an item to sell.
* Shift-click to buy/sell larger quantities.
* Show the item price and amount in the item's lore.

#### 2. Money System

Create a built-in economy without Vault.

Commands:

* `/balance`
* `/bal`
* `/pay  `

Store player balances safely in a YAML file.

#### 3. Sell GUI

Create `/sell`.

When `/sell` is opened:

* Player gets a sell GUI.
* Player can place items into the GUI.
* Add a **Sell All** button.
* Calculate the total value using the shop's sell prices.
* Give the money directly to the player.
* Prevent players from losing items when closing the GUI.
* Do not allow players to take the Sell button or GUI decoration items.

#### 4. Money Spawners

Do NOT create a separate spawner GUI.

Instead, add spawners directly inside the existing:

`/shop โ†’ Spawners`

category.

Example spawners:

* Zombie
* Skeleton
* Spider
* Creeper
* Cow
* Pig
* Chicken
* Iron Golem

Players buy the spawner from the normal Shop GUI.

When a player places a purchased money spawner:

* The spawner must be linked to its owner.
* It should NOT need to spawn mobs.
* Instead, it automatically generates money for its owner.
* Money should be added to the plugin's built-in economy.
* Show a message/action bar when money is generated.
* Support configurable generation intervals.
* Support configurable money amounts.
* Save spawner ownership and locations so they survive server restarts.

Example configuration:

```yaml
spawners:
  ZOMBIE:
    buy-price: 10000
    money-per-generation: 100
    interval-seconds: 60

  SKELETON:
    buy-price: 15000
    money-per-generation: 150
    interval-seconds: 60

  CREEPER:
    buy-price: 30000
    money-per-generation: 300
    interval-seconds: 60

  IRON_GOLEM:
    buy-price: 100000
    money-per-generation: 1000
    interval-seconds: 60
```

Make every value configurable.

#### 5. Spawner Protection

* Only the owner can break their money spawner.
* When broken, return the spawner item to the owner.
* Other players cannot break or steal it.
* Prevent piston/explosion methods from bypassing ownership.
* Save all spawners in a persistent YAML or similar data file.
* Handle chunk unload/load correctly.
* Do not create duplicate spawners.

#### 6. Admin Commands

Create:

`/shopadmin reload`

`/shopadmin give   `

`/shopadmin give-spawner   `

`/shopadmin setbalance  `

`/shopadmin addbalance  `

Only operators or a configurable permission should be able to use these commands.

#### 7. Permissions

Add permissions such as:

```text
shopgui.shop
shopgui.sell
shopgui.balance
shopgui.pay
shopgui.admin
shopgui.admin.give
shopgui.admin.spawner
```

#### 8. Configuration

Create an easy-to-edit `config.yml` containing:

* Shop title
* GUI sizes
* Item buy prices
* Item sell prices
* Spawner prices
* Spawner money generation
* Generation intervals
* Messages
* Currency symbol
* Admin permissions

#### 9. Compatibility

Target:

**Paper 1.21.1**

Use Java compatible with Paper 1.21.1.

Do not require:

* Vault
* Essentials
* ShopGUI+
* Any other economy plugin

The plugin must be completely standalone.

#### 10. Code Quality

* Use clean Java code.
* Use separate classes for GUI, economy, shop items, sell GUI, spawners, commands, listeners, and data storage.
* Properly register listeners and commands.
* Avoid memory leaks.
* Cancel tasks when the plugin disables.
* Validate all player input.
* Handle offline players correctly.
* Prevent item duplication exploits.
* Prevent money duplication exploits.
* Properly save data when the server shuts down.

#### 11. Final Output

Provide the complete project source code with:

```text
ShopGUI/
โ”œโ”€โ”€ pom.xml
โ”œโ”€โ”€ src/main/java/...
โ”œโ”€โ”€ src/main/resources/
โ”‚   โ”œโ”€โ”€ plugin.yml
โ”‚   โ””โ”€โ”€ config.yml
โ””โ”€โ”€ README.md
```

Also provide instructions for compiling it into:

`ShopGUI.jar`

The final plugin must be ready for installation on a **Paper 1.21.1 Minecraft server**.
Kodari AI
KodariSep 21 at 5:58 pm 2
ShopGUI
A standalone Paper 1.21.1 plugin providing a comprehensive shop and economy system without Vault. Features a multi-category chest GUI with configurable buy/sell prices, left-click to buy, right-click to sell, and shift-click for bulk transactions. Includes a built-in YAML-based economy with balance, pay, and admin balance commands. A sell GUI allows players to place items and sell all at once with automatic value calculation. Money spawners can be purchased from the shop, placed to generate income for their owner at configurable intervals, with ownership protection preventing theft or destruction by other players. All data persists across restarts.
  1. Create the Maven Paper 1.21.1 project and configuration.

  2. Implement the built-in economy, shop data, menus, and commands.

  3. Implement sell handling, protected money spawners, persistence, and admin operations.

  4. Add installation and compilation documentation.

Created the complete ShopGUI Paper 1.21.1 project with:

  • Configurable shop categories and item pricing

  • /shop, /sell, /balance, /bal, /pay

  • YAML-based standalone economy

  • Protected money spawners with persistent ownership

  • Spawner generation intervals and configurable payouts

  • Explosion and piston protection

  • Admin commands and permissions

  • pom.xml, plugin.yml, config.yml, Java source, and README

Build it with:

Shell
mvn clean package

The resulting plugin will be:

Plain Text
target/ShopGUI.jar
Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
README.md
Code
21 1,512
src/main/java/com/kodari/shopgui/ShopGUIPlugin.java
package com.kodari.shopgui;

import com.kodari.shopgui.command.BalanceCommand;
import com.kodari.shopgui.command.PayCommand;
import com.kodari.shopgui.command.SellCommand;
import com.kodari.shopgui.command.ShopAdminCommand;
import com.kodari.shopgui.command.ShopCommand;
import com.kodari.shopgui.economy.EconomyManager;
import com.kodari.shopgui.gui.SellMenu;
import com.kodari.shopgui.gui.ShopMenu;
import com.kodari.shopgui.shop.ShopManager;
import com.kodari.shopgui.spawner.SpawnerManager;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

import java.text.DecimalFormat;

public class ShopGUIPlugin extends JavaPlugin {
    private EconomyManager economy;
    private ShopManager shop;
    private ShopMenu shopMenu;
    private SellMenu sellMenu;
    private SpawnerManager spawners;
    private NamespacedKey spawnerKey;
    private int spawnerTask = -1;
    private final DecimalFormat moneyFormat = new DecimalFormat("#,##0.00");

    @Override
    public void onEnable() {
        saveDefaultConfig();
        spawnerKey = new NamespacedKey(this, "money_spawner_type");
        economy = new EconomyManager(this);
        shop = new ShopManager(this, economy);
        shopMenu = new ShopMenu(this, shop);
        sellMenu = new SellMenu(this);
        spawners = new SpawnerManager(this, shop);
        getServer().getPluginManager().registerEvents(new ShopListener(this), this);

        getCommand("shop").setExecutor(new ShopCommand(this));
        getCommand("sell").setExecutor(new SellCommand(this));
        getCommand("balance").setExecutor(new BalanceCommand(this));
        getCommand("pay").setExecutor(new PayCommand(this));
        ShopAdminCommand adminCommand = new ShopAdminCommand(this);
        getCommand("shopadmin").setExecutor(adminCommand);
        getCommand("shopadmin").setTabCompleter(adminCommand);
        spawnerTask = getServer().getScheduler().scheduleSyncRepeatingTask(this, spawners::tick, 20L, 20L);
    }

    @Override
    public void onDisable() {
        if (spawnerTask != -1) {
            getServer().getScheduler().cancelTask(spawnerTask);
        }
        if (economy != null) {
            economy.save();
        }
        if (spawners != null) {
            spawners.save();
        }
    }

    public EconomyManager economy() {
        return economy;
    }

    public ShopManager shop() {
        return shop;
    }

    public ShopMenu shopMenu() {
        return shopMenu;
    }

    public SellMenu sellMenu() {
        return sellMenu;
    }

    public SpawnerManager spawners() {
        return spawners;
    }

    public NamespacedKey spawnerKey() {
        return spawnerKey;
    }

    public String money(double amount) {
        return getConfig().getString("currency-symbol", "$") + moneyFormat.format(amount);
    }

    public String message(String path, String... replacements) {
        String message = getConfig().getString("messages." + path, "&cMissing message: " + path);
        for (int index = 0; index + 1 < replacements.length; index += 2) {
            message = message.replace(replacements[index], replacements[index + 1]);
        }
        return ChatColor.translateAlternateColorCodes('&', message);
    }
}