Uttura

Make a minecraft plugin out of it

1 image attached
Kodari AI
KodariMay 28 at 3:23 pm 85
TradeStock
A dynamic player-driven economy plugin where players sell items into a central stock pool for instant cash. Prices fluctuate based on supply — high stock lowers sell price, low stock raises it. Players can buy back items at sell price plus a configurable markup fee (currency sink). No pre-stocked inventory; all stock is player-supplied. Features a GUI shop browser, transaction logging via SQLite, Vault economy integration, and a blacklist system.

Here’s the full plan before writing any code:

  1. TradeStock.java — main plugin class, wires everything together

  2. config.yml — base price, markup fee, dynamic pricing toggle, blacklist

  3. plugin.yml — commands + permissions

  4. database/DatabaseManager.java — SQLite setup, stock table, transaction log

  5. economy/StockManager.java — central pool, dynamic price calculation

  6. economy/PriceCalculator.java — supply/demand formula

  7. commands/TradeCommand.java — /trade sell, /trade buy, /trade shop

  8. commands/TradeAdminCommand.java — /tradeadmin reload, /tradeadmin stock, /tradeadmin blacklist

  9. inventory/InventoryHandler.java — interface

  10. inventory/InventoryButton.java — button builder

  11. inventory/InventoryGUI.java — abstract base

  12. inventory/gui/GUIManager.java — active inventory tracker

  13. inventory/gui/GUIListener.java — event listener

  14. inventory/impl/ShopBrowserGUI.java — paginated shop browser

  15. inventory/impl/SellConfirmGUI.java — sell confirmation

  16. inventory/impl/BuyConfirmGUI.java — buy confirmation

  17. listeners/PlayerSellListener.java — handles sell-by-hand flow

  18. util/ItemUtil.java — item display name helpers

  19. util/MessageUtil.java — color formatting

Now I need to add getEconomy() to StockManager and hook Vault. Let me also create the commands and utilities:

Now let me write all the remaining files properly from scratch:

Now fix the duplicate StockManager.java that was partially patched earlier — the file was already recreated cleanly above, but the patch left a broken version. Let me verify:

Good — the patched version is in place. Now let me write all the actual file contents properly. I’ll create every file:

Now fix the StockManager — the getAllStock() method returns a copy so the admin command’s put won’t work. Let me patch that:

The files are all empty shells from the <create> tags — the system created them but I need to actually write the content. Let me write all files now with full content:

Here’s what was built:


TradeStock — full dynamic economy plugin matching your diagram:

Economy Flow

  • Sell — players sell items from hand or by name; items enter the central stock pool, cash is paid instantly

  • Buy — players buy from the pool at sell price + markup; if stock is 0, purchase is blocked

  • Dynamic Pricing — uses a power-curve formula: high stock → price decays, low stock → price rises. Configurable sensitivity + reference stock level

GUIs

  • /trade shop — paginated 6-row browser showing all configured items with live stock, sell price, buy price; left-click to buy, right-click to sell

  • Sell Confirm GUI — adjust amount with ±1/±10/±64 buttons, confirm removes items from inventory

  • Buy Confirm GUI — same amount picker, checks balance + stock before confirming

Commands

Command
Description
/trade
/
/trade shop
Open shop browser
/trade sell [item] [amount]
Sell item (hand or by name)
/trade buy <item> [amount]
Buy item
/tradeadmin reload
Reload config
/tradeadmin stock [item]
View stock levels
/tradeadmin clearstock <item|all>
Wipe stock
/tradeadmin blacklist add/remove <item>
Manage blacklist

Technical

  • SQLite persistence — stock table + full transaction log (player, type, item, amount, price, timestamp)

  • Vault integration — works with EssentialsX, CMI, any Vault economy

  • Blacklist — configurable per-item, hot-reloadable

  • 35 pre-configured items with sensible base prices in config.yml

Uttura

how does it work tho where to put it

Kodari can make mistakes. Review important code before using.
Files
src
Code
18 1,522
src/main/java/com/tradestock/TradeStock.java
package com.tradestock;

import com.tradestock.commands.TradeAdminCommand;
import com.tradestock.commands.TradeCommand;
import com.tradestock.database.DatabaseManager;
import com.tradestock.economy.StockManager;
import com.tradestock.inventory.gui.GUIListener;
import com.tradestock.inventory.gui.GUIManager;
import org.bukkit.plugin.java.JavaPlugin;

public class TradeStock extends JavaPlugin {

    private DatabaseManager databaseManager;
    private StockManager stockManager;
    private GUIManager guiManager;

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

        databaseManager = new DatabaseManager(this);
        databaseManager.initialize();

        stockManager = new StockManager(this);
        guiManager = new GUIManager();

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

        TradeCommand tradeCommand = new TradeCommand(this);
        getCommand("trade").setExecutor(tradeCommand);
        getCommand("trade").setTabCompleter(tradeCommand);

        TradeAdminCommand adminCommand = new TradeAdminCommand(this);
        getCommand("tradeadmin").setExecutor(adminCommand);
        getCommand("tradeadmin").setTabCompleter(adminCommand);

        getLogger().info("TradeStock enabled! Dynamic economy is live.");
    }

    @Override
    public void onDisable() {
        if (databaseManager != null) {
            databaseManager.close();
        }
        getLogger().info("TradeStock disabled.");
    }

    public DatabaseManager getDatabaseManager() {
        return databaseManager;
    }

    public StockManager getStockManager() {
        return stockManager;
    }

    public GUIManager getGuiManager() {
        return guiManager;
    }
}