fabiw09

bank sysem

Kodari AI
KodariNov 14 at 3:59 pm 1
BankSystem
A comprehensive virtual banking plugin for Minecraft servers. Players can create personal bank accounts, deposit and withdraw in-game currency, transfer funds between players, and view transaction history. Includes interest accrual on stored balances, configurable starting balances, and admin commands for managing accounts, setting balances, and auditing transactions. Features a persistent SQLite or YAML storage system, player-friendly GUI menus for banking operations, and comprehensive permission-based access control. Supports Vault economy integration for cross-plugin currency compatibility, along with detailed logging and anti-exploit measures to prevent duplication or balance manipulation.

I’ll build a simple emerald bank with persistent balances and /bank balance, /bank deposit, and /bank withdraw commands.

Created an emerald bank with persistent personal balances.

  • /bank — check your balance

  • /bank deposit <amount> — deposit plain emeralds

  • /bank withdraw <amount> — withdraw emeralds

fabiw09

oppass plugin machen

Kodari AI
KodariNov 14 at 4:07 pm 1

Was meinst du mit „OPPass“? Soll das Plugin Operator-Rechte durch ein Passwort schützen oder etwas anderes machen?

fabiw09

nein ein battelpass

Kodari AI
KodariNov 14 at 4:09 pm 2

Ich ergänze einen Battle Pass mit Monster-Kills für EP, Stufenbelohnungen und einem Admin-Befehl. Die bestehende Bank bleibt erhalten.

Der Battle Pass ist ergänzt; die Bank bleibt bestehen.

  • /bp zeigt deinen Fortschritt.

  • Monster-Kills geben Battle-Pass-EP.

  • /bp belohnung <stufe> holt eine erreichte Belohnung ab.

  • Admins können mit /bp addxp <spieler> <menge> EP vergeben.

Stufen, EP und Belohnungen lassen sich in der config.yml einstellen.

fabiw09

ja

Kodari AI
KodariNov 14 at 4:09 pm 1

Was möchtest du als Nächstes am Battle Pass ändern oder hinzufügen?

fabiw09

qust

Kodari AI
KodariNov 14 at 4:10 pm 1

Ich ergänze tägliche Quests für Monster-Kills und abgebaute Blöcke. Fortschritt und EP-Belohnungen werden gespeichert; /bp quests zeigt sie an.

Tägliche Quests sind hinzugefügt:

  • 10 Monster besiegen oder 50 Blöcke abbauen – jeweils für Battle-Pass-EP.

  • /bp quests zeigt deinen Fortschritt.

  • Die Quests werden täglich um 00:00 Uhr UTC zurückgesetzt.

Ziele und EP kannst du in der config.yml ändern.

fabiw09

ja

Kodari AI
KodariNov 14 at 4:10 pm 1

Was möchtest du als Nächstes hinzufügen? Zum Beispiel wöchentliche Quests, ein Battle-Pass-Menü oder weitere Belohnungen?

fabiw09

nix mehr

Kodari AI
KodariNov 14 at 4:11 pm 1

Alles klar!

fabiw09

das pluig bitte

Kodari AI
KodariNov 14 at 4:11 pm 1

So bekommst du das Plugin als JAR:

  1. Klicke oben auf Compile. Am Handy: ⋮ → Compile Project.

  2. Klicke im Fenster auf Compile.

  3. Klicke nach dem erfolgreichen Build auf Download.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
5 428
src/main/java/com/kodari/emeraldbank/EmeraldBank.java
package com.kodari.emeraldbank;

import java.io.File;
import java.io.IOException;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.java.JavaPlugin;

public final class EmeraldBank extends JavaPlugin {
    private File accountsFile;
    private YamlConfiguration accounts;
    private Material emerald;

    @Override
    public void onEnable() {
        emerald = Material.matchMaterial("EMERALD");
        if (emerald == null) {
            getLogger().severe("Emeralds are not available on this server.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        if (!getDataFolder().exists() && !getDataFolder().mkdirs()) {
            getLogger().severe("Could not create the bank data directory.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        accountsFile = new File(getDataFolder(), "accounts.yml");
        accounts = new YamlConfiguration();
        if (accountsFile.exists()) {
            try {
                accounts.load(accountsFile);
            } catch (Exception e) {
                getLogger().severe("Could not load bank accounts: " + e.getMessage());
                getServer().getPluginManager().disablePlugin(this);
                return;
            }
        }
        saveDefaultConfig();
        BattlePass battlePass = new BattlePass(this);
        getServer().getPluginManager().registerEvents(battlePass, this);
        getCommand("battlepass").setExecutor(battlePass);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage(ChatColor.RED + "Only players can use the bank.");
            return true;
        }
        Player player = (Player) sender;
        String key = player.getUniqueId().toString();
        long balance = accounts.getLong(key, 0L);
        if (args.length == 0 || (args.length == 1 && args[0].equalsIgnoreCase("balance"))) {
            player.sendMessage(ChatColor.GREEN + "Bank balance: " + balance + " emeralds.");
            return true;
        }
        if (args.length != 2 || (!args[0].equalsIgnoreCase("deposit") && !args[0].equalsIgnoreCase("withdraw"))) {
            player.sendMessage(ChatColor.YELLOW + "Usage: /bank [balance|deposit <amount>|withdraw <amount>]");
            return true;
        }
        int amount;
        try {
            amount = Integer.parseInt(args[1]);
            if (amount <= 0) throw new NumberFormatException();
        } catch (NumberFormatException e) {
            player.sendMessage(ChatColor.RED + "Enter a positive whole number.");
            return true;
        }
        PlayerInventory inventory = player.getInventory();
        if (args[0].equalsIgnoreCase("deposit")) {
            ItemStack[] contents = inventory.getStorageContents();
            long available = 0;
            for (ItemStack item : contents) {
                if (item != null && item.getType() == emerald && !item.hasItemMeta()) available += item.getAmount();
            }
            if (available < amount) {
                player.sendMessage(ChatColor.RED + "You do not have enough plain emeralds in your inventory.");
                return true;
            }
            if (balance > Long.MAX_VALUE - amount) {
                player.sendMessage(ChatColor.RED + "Your bank balance cannot hold that many emeralds.");
                return true;
            }
            accounts.set(key, balance + amount);
            if (!saveAccounts()) {
                accounts.set(key, balance);
                player.sendMessage(ChatColor.RED + "Bank data could not be saved; no emeralds were deposited.");
                return true;
            }
            int remaining = amount;
            for (int i = 0; i < contents.length && remaining > 0; i++) {
                ItemStack item = contents[i];
                if (item == null || item.getType() != emerald || item.hasItemMeta()) continue;
                int taken = Math.min(remaining, item.getAmount());
                remaining -= taken;
                if (taken == item.getAmount()) contents[i] = null;
                else item.setAmount(item.getAmount() - taken);
            }
            inventory.setStorageContents(contents);
            player.sendMessage(ChatColor.GREEN + "Deposited " + amount + " emeralds. Balance: " + (balance + amount) + ".");
        } else {
            if (balance < amount) {
                player.sendMessage(ChatColor.RED + "You do not have enough emeralds in the bank.");
                return true;
            }
            long space = 0;
            ItemStack plainEmerald = new ItemStack(emerald);
            for (ItemStack item : inventory.getStorageContents()) {
                if (item == null || item.getType().isAir()) space += emerald.getMaxStackSize();
                else if (item.isSimilar(plainEmerald)) space += Math.max(0, item.getMaxStackSize() - item.getAmount());
            }
            if (space < amount) {
                player.sendMessage(ChatColor.RED + "You do not have enough inventory space.");
                return true;
            }
            accounts.set(key, balance - amount);
            if (!saveAccounts()) {
                accounts.set(key, balance);
                player.sendMessage(ChatColor.RED + "Bank data could not be saved; no emeralds were withdrawn.");
                return true;
            }
            int remaining = amount;
            while (remaining > 0) {
                int stackSize = Math.min(remaining, emerald.getMaxStackSize());
                Map<Integer, ItemStack> leftovers = inventory.addItem(new ItemStack(emerald, stackSize));
                if (!leftovers.isEmpty()) {
                    int undelivered = remaining;
                    for (ItemStack leftover : leftovers.values()) undelivered -= stackSize - leftover.getAmount();
                    accounts.set(key, balance - amount + undelivered);
                    saveAccounts();
                    player.sendMessage(ChatColor.RED + "Inventory changed; withdrew " + (amount - undelivered) + " emeralds.");
                    return true;
                }
                remaining -= stackSize;
            }
            player.sendMessage(ChatColor.GREEN + "Withdrew " + amount + " emeralds. Balance: " + (balance - amount) + ".");
        }
        return true;
    }

    private boolean saveAccounts() {
        try {
            accounts.save(accountsFile);
            return true;
        } catch (IOException e) {
            getLogger().severe("Could not save bank accounts: " + e.getMessage());
            return false;
        }
    }
}