Build KashEconomy, an independent production-oriented Paper 1.21.11 Java 21 Maven plugin under net.kashspade. Project is newly created and empty. Implement full Vault Economy provider, SQLite persistence with architecture accommodating future MySQL, persistent balances, atomic safe transactions, transaction history, configurable starting balance and currency symbol, failure handling and safe async database operations where appropriate without async Bukkit API access. Implement /balance (alias /bal), /pay <player> <amount>, /eco give|take|set|reset <player> [amount], /baltop, proper permissions kasheconomy.admin, kasheconomy.pay, kasheconomy.baltop, tab completion and configurable messages. Reject invalid/nonfinite/negative amounts, insufficient funds, self-pay, offline pay if unsupported; ensure money cannot be lost or duplicated under failures or concurrent operations and no negative balances. Include config.yml, messages.yml, plugin.yml, Maven POM with Paper and Vault provided and suitable SQLite runtime dependency handling. Register/unregister Vault service and cleanly close database/tasks on disable. Integrate with KashCore only through standard Vault; no project dependency. Implement feature code only, no tests. Inspect project structure and ensure registrations/resources are complete; report integration requirements and any limitations honestly.

Kodari AI
KodariNov 15 at 12:02 pm 8
KashEconomy
KashEconomy is a production-oriented Paper 1.21.11 economy plugin implementing a full Vault Economy provider with SQLite persistence and atomic transactions. Features include persistent balances, transaction history, configurable starting balance and currency symbol, and commands for balance checking, player payments, and admin economy management. The plugin provides /balance, /pay, /eco give|take|set|reset, and /baltop with tab completion and proper permissions. It handles invalid amounts, insufficient funds, self-pay, and offline payments safely, ensuring no money loss or duplication under failures or concurrent operations. SQLite storage architecture accommodates future MySQL migration, with safe async database operations and clean shutdown procedures.
  • Store balances as integer cents and commit balance changes and history together.

  • Run command database work asynchronously; keep Vault’s synchronous API compatible.

  • Register the provider, commands, permissions, and configurable resources.

Built KashEconomy with SQLite persistence, atomic transfers, transaction history, Vault registration, commands, permissions, and configurable messages.

Integration: Install Vault alongside the plugin. KashCore can use the registered Vault economy provider without a direct dependency. Paper must be able to download the SQLite runtime library on first load.

Limitations: Vault calls are synchronous and may block on database access; command database work runs asynchronously. Payments require an online recipient, while admin and legacy Vault name lookups require a cached player. Bank accounts and MySQL are not implemented. History is stored in SQLite but has no in-game viewer. If a database commit’s outcome cannot be confirmed, check the balance before retrying.

The project has not been compiled or tested in this session.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
10 540
src/main/java/net/kashspade/kasheconomy/KashEconomy.java
package net.kashspade.kasheconomy;

import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;

public final class KashEconomy extends JavaPlugin {
    private EconomyStore store;
    private VaultEconomy provider;
    private ExecutorService executor;
    private final AtomicBoolean accepting = new AtomicBoolean();
    private YamlConfiguration messages;
    private String symbol, singular, plural;
    private int topSize;

    @Override public void onEnable() {
        try {
            saveDefaultConfig();
            saveResource("messages.yml", false);
            messages = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "messages.yml"));
            symbol = getConfig().getString("currency-symbol", "$");
            singular = getConfig().getString("currency-singular", "dollar");
            plural = getConfig().getString("currency-plural", "dollars");
            topSize = Math.max(1, Math.min(100, getConfig().getInt("baltop-size", 10)));
            long starting = Amounts.parse(getConfig().getString("starting-balance", "0"));
            store = new SqliteStore(new File(getDataFolder(), "economy.db"), starting);
            executor = Executors.newSingleThreadExecutor(r -> { Thread t = new Thread(r, "KashEconomy-Database"); t.setDaemon(true); return t; });
            EconomyCommands commands = new EconomyCommands(this, store);
            for (String name : new String[]{"balance", "pay", "eco", "baltop"}) {
                java.util.Objects.requireNonNull(getCommand(name)).setExecutor(commands);
                java.util.Objects.requireNonNull(getCommand(name)).setTabCompleter(commands);
            }
            provider = new VaultEconomy(this, store);
            getServer().getServicesManager().register(Economy.class, provider, this, ServicePriority.High);
            accepting.set(true);
        } catch (Exception e) {
            getLogger().severe("Failed to start KashEconomy: " + e.getMessage());
            getServer().getPluginManager().disablePlugin(this);
        }
    }
    @Override public void onDisable() {
        accepting.set(false);
        getServer().getServicesManager().unregisterAll(this);
        if (executor != null) {
            executor.shutdown();
            boolean interrupted = false;
            while (!executor.isTerminated()) {
                try {
                    if (!executor.awaitTermination(1, TimeUnit.SECONDS)) getLogger().warning("Waiting for economy transactions to finish...");
                } catch (InterruptedException e) {
                    interrupted = true;
                }
            }
            if (interrupted) Thread.currentThread().interrupt();
        }
        if (store != null) try { store.close(); } catch (Exception e) { getLogger().severe("Failed to close economy database: " + e.getMessage()); }
    }
    public String symbol() { return symbol; }
    public String currencySingular() { return singular; }
    public String currencyPlural() { return plural; }
    public int topSize() { return topSize; }
    public String message(String key) {
        return org.bukkit.ChatColor.translateAlternateColorCodes('&', messages.getString("prefix", "") + messages.getString(key, key));
    }
    public void submit(Runnable task) {
        if (!accepting.get()) throw new IllegalStateException("Economy is shutting down");
        executor.execute(task);
    }
    public void reply(Runnable task) {
        if (!accepting.get()) return;
        try { Bukkit.getScheduler().runTask(this, task); } catch (IllegalStateException ignored) { }
    }
}