morgangaming0021

Create a minecraft plugin exactely like th donut smp economy like on the right there is the balance ,keyall systeme and the time we played and there is a command Mike /shop, /sell and /adminbal To change the balance of the player

Kodari AI
KodariJun 4 at 7:35 pm 50
DonutEconomy
A Donut SMP-style economy plugin featuring a live sidebar scoreboard showing balance, key count, and playtime. Includes a multi-category shop GUI (/shop), item selling system (/sell hand|all), admin balance management (/adminbal), and a server-wide key distribution system (/keyall). Player data is persisted per-UUID as YAML files with automatic save on quit and periodic playtime snapshots.

Here’s a full breakdown of everything built:


📊 Sidebar Scoreboard

Automatically applied to every player on join. Updates every second showing:

  • Balance — formatted with commas (e.g. $1,234.56)

  • Keys — virtual key count

  • Play Time — live session time (e.g. 2h 15m)


🛒 /shop

Opens a 27-slot GUI with 4 categories (Food, Blocks, Ores, Tools). Each category opens a 54-slot item grid with price lore, buy confirmation, and a back button. All items & prices are fully configurable in config.yml.

💰 /sell <hand|all>

  • hand — sells the item in your main hand

  • all — scans your entire inventory and sells every item with a configured sell price

🔑 /keyall <amount> (op)

Gives virtual keys to all online players and notifies each one. Updates their scoreboard instantly.

⚙️ /adminbal <player> <set|add|remove> <amount> (op)

Modifies any online player’s balance in real time. Both the admin and target receive feedback messages, and the scoreboard refreshes immediately.

📖 /bal [player]

Check your own or another player’s balance.


Data is saved per-UUID as YAML files in plugins/DonutEconomy/playerdata/. Playtime is snapshotted every minute and saved on quit.

Kodari can make mistakes. Review important code before using.
Files
src
Code
21 1,343
src/main/java/com/kodari/donuteconomy/DonutEconomy.java
package com.kodari.donuteconomy;

import com.kodari.donuteconomy.commands.*;
import com.kodari.donuteconomy.data.DataManager;
import com.kodari.donuteconomy.inventory.gui.GUIListener;
import com.kodari.donuteconomy.inventory.gui.GUIManager;
import com.kodari.donuteconomy.listeners.PlayerListener;
import com.kodari.donuteconomy.managers.ScoreboardManager;
import com.kodari.donuteconomy.managers.SellManager;
import lombok.Getter;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class DonutEconomy extends JavaPlugin {

    @Getter private static DonutEconomy instance;

    @Getter private DataManager dataManager;
    @Getter private ScoreboardManager scoreboardManager;
    @Getter private GUIManager guiManager;
    @Getter private SellManager sellManager;

    @Override
    public void onEnable() {
        instance = this;
        saveDefaultConfig();

        dataManager = new DataManager(this);
        scoreboardManager = new ScoreboardManager(this);
        guiManager = new GUIManager();
        sellManager = new SellManager(this);

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

        getCommand("shop").setExecutor(new ShopCommand(this));
        getCommand("sell").setExecutor(new SellCommand(this));
        getCommand("adminbal").setExecutor(new AdminBalCommand(this));
        getCommand("keyall").setExecutor(new KeyAllCommand(this));
        getCommand("bal").setExecutor(new BalCommand(this));

        // Update all scoreboards every second
        getServer().getScheduler().runTaskTimer(this, () -> scoreboardManager.updateAll(), 20L, 20L);

        // Snapshot playtime every minute to prevent loss on crash
        getServer().getScheduler().runTaskTimer(this, () -> dataManager.updatePlayTimes(), 1200L, 1200L);

        // Handle reloads — restore scoreboard for already-online players
        for (Player player : getServer().getOnlinePlayers()) {
            dataManager.loadPlayer(player.getUniqueId(), player.getName());
            scoreboardManager.setup(player);
        }

        getLogger().info("DonutEconomy enabled — " + getServer().getOnlinePlayers().size() + " player(s) loaded.");
    }

    @Override
    public void onDisable() {
        for (Player player : getServer().getOnlinePlayers()) {
            dataManager.updatePlayTime(player.getUniqueId());
            dataManager.savePlayer(player.getUniqueId());
        }
        getLogger().info("DonutEconomy disabled — all player data saved.");
    }
}