cjcjcjcjcj8789576958

A plugin that adds chest shopsd

Kodari AI
KodariJun 1 at 9:37 pm 34
ChestShops
A fully-featured chest shop plugin that lets players turn any chest into a player-run shop. Features include GUI-based buying and selling, automatic stock management from the chest inventory, buy/sell price configuration, per-player shop limits, and Vault economy integration. Includes shop management GUI for owners, admin override permissions, and persistent shop data storage.

Here’s a summary of what was built:


ChestShops — 16 files, fully production-ready.

How it works

  1. Create a shop — hold any item, look at a chest within 5 blocks, run /cshop create <buyPrice> [sellPrice]. Use 0 to disable buying or selling.

  2. Customer interaction — right-clicking a shop chest opens a GUI with the item, stock count, and BUY / SELL buttons.

  3. Owner interaction — right-clicking your own shop opens a management GUI showing stock, prices, and a remove button.

  4. Economy — fully Vault-integrated. Buying deducts from the customer and pays the owner. Selling deducts from the owner’s balance and pays the customer.

Commands

Command
Description
/cshop create <buy> [sell]
Create or update a shop (looking at a chest, holding item)
/cshop remove
Remove shop you’re looking at
/cshop info
View shop details
/cshop list [page]
List your shops
/cshop reload
Reload config

Features

  • Explosion protection (TNT/creepers can’t destroy shop chests)

  • Per-player shop limits (configurable)

  • Stock pulled directly from the chest — just add items to restock

  • Persistent storage in shops.yml

  • All messages fully configurable in config.yml

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
16 1,388
src/main/java/com/kodari/chestshops/ChestShopsPlugin.java
package com.kodari.chestshops;

import com.kodari.chestshops.command.ShopCommand;
import com.kodari.chestshops.inventory.gui.GUIListener;
import com.kodari.chestshops.inventory.gui.GUIManager;
import com.kodari.chestshops.listener.ShopListener;
import com.kodari.chestshops.manager.ShopManager;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

public class ChestShopsPlugin extends JavaPlugin {

    private Economy economy;
    private ShopManager shopManager;
    private GUIManager guiManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();

        if (!setupEconomy()) {
            getLogger().severe("Vault economy provider not found! Disabling ChestShops.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        shopManager = new ShopManager(this);
        guiManager = new GUIManager();

        shopManager.loadShops();

        getServer().getPluginManager().registerEvents(new GUIListener(guiManager), this);
        getServer().getPluginManager().registerEvents(new ShopListener(this, shopManager, guiManager), this);

        ShopCommand shopCommand = new ShopCommand(this, shopManager);
        getCommand("cshop").setExecutor(shopCommand);
        getCommand("cshop").setTabCompleter(shopCommand);

        getLogger().info("ChestShops v" + getDescription().getVersion() + " enabled!");
    }

    @Override
    public void onDisable() {
        if (shopManager != null) {
            shopManager.saveShops();
        }
        getLogger().info("ChestShops disabled.");
    }

    private boolean setupEconomy() {
        if (getServer().getPluginManager().getPlugin("Vault") == null) return false;
        RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
        if (rsp == null) return false;
        economy = rsp.getProvider();
        return economy != null;
    }

    public String msg(String key) {
        String prefix = getConfig().getString("messages.prefix", "&8[&6ChestShops&8] &r");
        String message = getConfig().getString("messages." + key, "&cMissing message: " + key);
        return colorize(prefix + message);
    }

    public String msgRaw(String key) {
        return colorize(getConfig().getString("messages." + key, "&cMissing message: " + key));
    }

    public static String colorize(String text) {
        return text.replace("&", "\u00a7");
    }

    public Economy getEconomy() {
        return economy;
    }

    public ShopManager getShopManager() {
        return shopManager;
    }

    public GUIManager getGuiManager() {
        return guiManager;
    }
}