Ed Dhaene

this is the token item token-item: H4sIAAAAAAAA/7XQsU7DMBAG4AttoTViAfEEvEDiJriwoDYJCzsrch2HWnVsZJ8Fj4/LAKs9cNOd9P/fcARgBpcdR/4qnVfWAFw/LeFMDXAzKSOF4yM++mBGbT+lm8FC2GAQAAoCRNjpwxpp0BO4/YuL4NFOb4ZPcgUL+YWOk9hYFXCukGsloAASzCCdjp0hXvO91QMsT7q2Di7u2pqxsowxux+DFxx/YlcenTpKPDgb3g8xP8eoQ/ECGXRHN13FUmmVQ/fltqZ9Kq2z6H63rZt/oZ/brmzaVBqzfs12VZ1M2xx6Rx/oukuljzn0pmWUJtMyh75nzbpKps3veppvVdaOi6wDAAA=

📎 1 file 1,438 chars
📄
pasted-code-1790452763183.txt
txt 42 lines
▶
Create a Minecraft Paper 1.21.11 plugin called "RoyaleFFA Bounties".

BOUNTY SYSTEM:
- Add a Kill Token currency.
- `/tokens` shows your current Kill Token balance.
- Players receive a configurable amount of Kill Tokens when they get a kill.
- `/bounty add  ` lets players place Kill Tokens on another player.
- `/bounty remove ` removes your bounty from a player.
- `/bounty list` shows all active bounties, sorted from highest to lowest.
- `/bounty help` shows all bounty commands.

When a player with a bounty is killed:
- The killer receives the entire bounty in Kill Tokens.
- The bounty is removed.
- Announce it in chat, for example:
  `[Bounty] Player1 claimed the 50 Kill Token bounty on Player2!`

When a bounty is created or increased, announce it in chat.

Rules:
- Players cannot place a bounty on themselves.
- Players cannot spend more Kill Tokens than they have.
- Amounts cannot be negative or 0.
- Add a configurable minimum bounty amount.

PERSISTENCE:
- Kill Token balances and bounties must survive server restarts.
- Use SQLite and UUIDs for player data.

CONFIG:
Make the following configurable in `config.yml`:
- Kill reward
- Minimum bounty
- All messages
- Prefix

TECHNICAL:
- Paper 1.21.11
- Clean Java code
- Tab completion
- Include `plugin.yml`, `config.yml`, all Java source code and a README.
- Make sure the plugin compiles without errors.
Kodari AI
KodariSep 26 at 8:01 pm 1
RoyaleFFABounties
RoyaleFFABounties is a Paper 1.21.11 plugin that introduces a Kill Token currency and a bounty system for FFA servers. Players earn configurable Kill Token rewards for kills, view balances via /tokens, and place bounties on other players using /bounty add, remove, list, and help commands. Bounties are announced in chat when created or increased, and when a targeted player is killed, the killer claims the full bounty with a chat announcement. The plugin enforces rules preventing self-bounties, overspending, and invalid amounts, with a configurable minimum bounty. All balances and bounties persist across restarts using SQLite with UUID-based storage. Configuration includes kill rewards, minimum bounty, prefix, and all messages.
  1. Set up the Paper 1.21.11 Gradle project and plugin resources.

  2. Implement SQLite-backed token balances and per-player bounties.

  3. Add commands, tab completion, kill handling, configurable messages, and the supplied token item.

  4. Document setup and commands in the README.

Created the RoyaleFFA Bounties Paper plugin with SQLite-backed Kill Token balances and UUID-based bounties, configurable rewards/messages, tab completion, and bounty claim announcements. The supplied token item is configured for /tokens deposit and /tokens withdraw.

Added the Gradle project, plugin.yml, config.yml, Java sources, and README. Build with Java 21 for Paper 1.21.11.

Ed Dhaene

looks for bugs and loopholes also make the user hold there kill tokens when they use the bounty commands and make the killtokens dissapear when the bounty is set

Kodari AI
KodariSep 26 at 10:20 pm 1
  1. Audit bounty/token flows for provable exploits and report the exact reproduction.

  2. Update bounty commands so players must have the Kill Token items and those items are consumed when a bounty is placed.

Updated /bounty add: players must have the configured Kill Token items in their inventory, and the amount placed is consumed. The bounty uses those items rather than also deducting the bank balance; /tokens withdraw already debits that balance. Removing a bounty still refunds its value to the creator’s bank balance.

Audit findings

  • Kill farming: BountyListener.onPlayerDeath credits the configured reward for every non-self player kill. Two players can repeatedly trade kills to farm tokens without limit.

  • Server-thread database work: BountyCommand.addBounty and BountyListener.onPlayerDeath call SQLite synchronously. Slow disk I/O can stall the server thread during commands or kills.

I left the kill-reward policy and database scheduling unchanged.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
README.md
settings.gradle
Code
12 787
src/main/java/com/royaleffa/bounties/RoyaleFFABountiesPlugin.java
package com.royaleffa.bounties;

import com.royaleffa.bounties.command.BountyCommand;
import com.royaleffa.bounties.command.TokensCommand;
import com.royaleffa.bounties.data.SQLiteStorage;
import com.royaleffa.bounties.listener.BountyListener;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.io.BukkitObjectInputStream;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Base64;
import java.util.Objects;
import java.util.zip.GZIPInputStream;

public final class RoyaleFFABountiesPlugin extends JavaPlugin {
    private SQLiteStorage storage;
    private ItemStack tokenItem;

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

        try {
            storage = new SQLiteStorage(this);
        } catch (RuntimeException exception) {
            getLogger().severe("Could not initialize SQLite storage: " + exception.getMessage());
            Bukkit.getPluginManager().disablePlugin(this);
            return;
        }

        Objects.requireNonNull(getCommand("tokens")).setExecutor(new TokensCommand(this));
        Objects.requireNonNull(getCommand("tokens")).setTabCompleter(new TokensCommand(this));
        BountyCommand bountyCommand = new BountyCommand(this);
        Objects.requireNonNull(getCommand("bounty")).setExecutor(bountyCommand);
        Objects.requireNonNull(getCommand("bounty")).setTabCompleter(bountyCommand);
        Bukkit.getPluginManager().registerEvents(new BountyListener(this), this);
    }

    @Override
    public void onDisable() {
        if (storage != null) {
            storage.close();
        }
    }

    public SQLiteStorage getStorage() {
        return storage;
    }

    public long getKillReward() {
        return Math.max(0, getConfig().getLong("kill-reward", 1));
    }

    public long getMinimumBounty() {
        return Math.max(1, getConfig().getLong("minimum-bounty", 1));
    }

    public ItemStack getTokenItem() {
        return tokenItem == null ? null : tokenItem.clone();
    }

    public void sendMessage(org.bukkit.command.CommandSender sender, String key, String... replacements) {
        sender.sendMessage(formatMessage(key, replacements));
    }

    public String formatMessage(String key, String... replacements) {
        String message = getConfig().getString("messages." + key, "&cMissing message: " + key);
        String prefix = getConfig().getString("prefix", "");
        if (prefix != null && !prefix.isEmpty()) {
            message = prefix + message;
        }
        for (int index = 0; index + 1 < replacements.length; index += 2) {
            message = message.replace(replacements[index], replacements[index + 1]);
        }
        return ChatColor.translateAlternateColorCodes('&', message);
    }

    private void loadTokenItem() {
        String encoded = getConfig().getString("token-item", "");
        if (encoded == null || encoded.isBlank()) {
            return;
        }
        try (ByteArrayInputStream bytes = new ByteArrayInputStream(Base64.getDecoder().decode(encoded));
             GZIPInputStream gzip = new GZIPInputStream(bytes);
             BukkitObjectInputStream input = new BukkitObjectInputStream(gzip)) {
            Object item = input.readObject();
            if (item instanceof ItemStack stack) {
                tokenItem = stack;
            } else {
                getLogger().warning("The configured token-item does not contain an ItemStack.");
            }
        } catch (IOException | ClassNotFoundException | IllegalArgumentException exception) {
            getLogger().warning("Could not load the configured token-item: " + exception.getMessage());
        }
    }
}