eufqriv_
๐Ÿ“Ž 1 file 3,111 chars
๐Ÿ“„
pasted-code-1774639369395.txt
txt 10 lines
โ–ถ
Generate a Spigot/Paper plugin that implements a high-stakes, economy-driven bounty system. Track each player's bounty balance as server currency. The codebase must be highly optimized, utilizing asynchronous tasks where appropriate, and ensure data persistence (e.g., saving the HashMap to config on onDisable).

Implement a passive economy accumulator using an async repeating task that adds $10 to every online player's bounty every 60 seconds. Include a 'Pacifist Penalty': track the timestamp of each player's last EntityDamageByEntityEvent (where both damager and victim are players). If 10 minutes pass without a player dealing PvP damage, their accumulation rate doubles to $20/minute. This penalty resets immediately upon dealing PvP damage. Upon a PlayerDeathEvent involving PvP, transfer 100% of the victim's bounty currency to the killer. The killer's own bounty must simultaneously reset to $0.

For player feedback, utilize an async task to continuously update every player's action bar, formatted as &cYour Bounty: &6$[PlayerMoney] &8| &4Top Target: &7[TopPlayerName]. Apply PotionEffectType.GLOWING permanently to any player whose bounty exceeds $2000, removing it only upon their death or when they secure a kill. On a PvP kill, trigger Bukkit.broadcastMessage announcing the kill and the transferred currency amount, accompanied by Sound.ENTITY_ENDERMAN_SCREAM for all online players. Play Sound.ENTITY_EXPERIENCE_ORB_PICKUP privately to players when their passive bounty ticks up.

Register two custom items with complex ShapedRecipe configurations in the onEnable method. The first is "The Stalker's Compass" (Material.COMPASS). Implement a task that updates its CompassMeta lodestone location every 15 seconds to target the player with the highest bounty (or the second-highest if the holder is the top target). The recipe shape is G D G, D R D, G H G (where G=NETHERITE_INGOT, D=DIAMOND_BLOCK, R=RECOVERY_COMPASS, and H=HEART_OF_THE_SEA).

The second item is "The Hunter's Rift-Pearl" (Material.ENDER_PEARL). Listen for PlayerInteractEvent; upon right-click, cancel the projectile launch and instantly teleport the user to the highest bounty player. This is a strict one-time-use mechanic per player lifetime (track usage via a persistent Set). Upon successful use, consume the item from the inventory, play Sound.ITEM_TOTEM_USE, and deny any future usage of Rift-Pearls by that UUID. The recipe shape is C T C, P E P, C P C (where C=END_CRYSTAL, T=TOTEM_OF_UNDYING, P=ENDER_PEARL, and E=ECHO_SHARD).
Implement a /bountyadmin command restricted to players with the bounty.admin permission. This command must include subcommands to manually set or add to a specific player's bounty balance (e.g., /bountyadmin set [player] [amount]), a toggle to reset a player's pacifist penalty timer, and a command to give the sender "The Stalker's Compass" or "The Hunter's Rift-Pearl" directly for testing purposes. Ensure all admin actions log a confirmation message to the sender and include basic tab-completion for player names and subcommands to streamline the testing process.
Kodari AI
KodariMar 27 at 7:26 pm 19,618 (v2)
BountySystem
A high-stakes economy-driven bounty system for Spigot/Paper servers. Players accumulate bounty currency passively, with a Pacifist Penalty doubling income for inactive PvP players. PvP kills transfer 100% of victim bounty to killer, who resets to zero. Features real-time action bar HUD, glowing effect for top targets, two craftable custom items (Stalker's Compass and Hunter's Rift-Pearl), and full /bountyadmin management with tab-completion and persistent data saving.
  • Plan all classes: BountyPlugin, BountyManager, ItemManager, BountyListener, ActionBarTask, CompassTask, BountyAdminCommand โ€” all methods mapped before writing

  • Use ConcurrentHashMap for thread safety, async for accumulation calc + sync dispatch for Bukkit API calls, XSeries for all enums

  • PersistentDataContainer tags for custom item identification, NamespacedKeys registered in plugin

All 12 files created. Hereโ€™s a summary of what was built:

  • BountyManager โ€” thread-safe ConcurrentHashMap storage for bounties, last PvP timestamps, and Rift-Pearl usage; handles pacifist detection (>10 min since last PvP), glowing threshold checks, and config persistence on enable/disable

  • BountyListener โ€” handles EntityDamageByEntityEvent to reset pacifist timers, PlayerDeathEvent for full bounty transfer + killer reset + broadcast + Enderman scream for all, and PlayerInteractEvent for Rift-Pearl one-time teleport with totem sound and item consumption

  • ActionBarTask โ€” async repeating task updating every playerโ€™s action bar every second with their bounty and the current top target name

  • CompassTask โ€” sync repeating task every 15s updating CompassMeta lodestone on any held Stalkerโ€™s Compass to point at the top bounty player (or second-highest if the holder is top)

  • ItemManager โ€” PersistentDataContainer tagging for custom item identification, creates both custom items with lore, and registers both ShapedRecipes via XMaterial for cross-version safety

  • BountyAdminCommand โ€” full tab-completion for set, add, resetpacifist, and give subcommands with player name suggestions and confirmation messages

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
14 988
src/main/java/com/bountysystem/BountyPlugin.java
package com.bountysystem;

import com.bountysystem.commands.BountyAdminCommand;
import com.bountysystem.inventory.gui.GUIListener;
import com.bountysystem.inventory.gui.GUIManager;
import com.bountysystem.tasks.ActionBarTask;
import com.bountysystem.tasks.CompassTask;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class BountyPlugin extends JavaPlugin {

    @Getter
    private BountyManager bountyManager;
    @Getter
    private ItemManager itemManager;
    @Getter
    private GUIManager guiManager;

    @Override
    public void onEnable() {
        bountyManager = new BountyManager(this);
        itemManager = new ItemManager(this);
        guiManager = new GUIManager();

        bountyManager.loadData();
        itemManager.registerRecipes();

        GUIListener guiListener = new GUIListener(guiManager);
        BountyListener bountyListener = new BountyListener(this);

        Bukkit.getPluginManager().registerEvents(guiListener, this);
        Bukkit.getPluginManager().registerEvents(bountyListener, this);

        BountyAdminCommand adminCommand = new BountyAdminCommand(this);
        getCommand("bountyadmin").setExecutor(adminCommand);
        getCommand("bountyadmin").setTabCompleter(adminCommand);

        new ActionBarTask(this).runTaskTimerAsynchronously(this, 20L, 20L);
        new CompassTask(this).runTaskTimer(this, 300L, 300L);

        startPassiveAccumulator();
    }

    @Override
    public void onDisable() {
        bountyManager.saveData();
    }

    private void startPassiveAccumulator() {
        Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
            if (Bukkit.getOnlinePlayers().isEmpty()) return;
            Bukkit.getScheduler().runTask(this, () -> {
                for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) {
                    double amount = bountyManager.isPacifist(player.getUniqueId()) ? 20.0 : 10.0;
                    bountyManager.addBounty(player.getUniqueId(), amount);
                    bountyManager.checkAndApplyGlowing(player);
                    com.cryptomorin.xseries.XSound.matchXSound("ENTITY_EXPERIENCE_ORB_PICKUP")
                            .ifPresent(s -> s.play(player));
                }
            });
        }, 1200L, 1200L);
    }
}