aximityistuff
📎 1 file 3,652 chars
📄
pasted-code-1778186224086.txt
txt 135 lines
▶
You are an expert Minecraft plugin developer. Create a full Spigot/Paper plugin called "BountySystem" for Minecraft 1.16–1.21+ (ensure good compatibility practices).

PLUGIN CONCEPT:
This is a hybrid bounty + credit economy system (NO Vault, NO external economy plugins).
Players use an internal currency called "Credits" to place bounties and spend them in a shop INVENTORY GUI.

CORE SYSTEM:
- Each player has "Credits" stored inside the plugin (SQLite or YAML, prefer SQLite)
- Players can place bounties ONLY using their Credits balance
- When a player is killed with a bounty, the killer receives the bounty Credits
- Credits are NOT real money and NOT linked to any external economy system

BOUNTY SYSTEM:
- Players use credits to place bounty on other players
- Bounty is stored per target UUID
- When target dies to another player:
  - Killer receives the bounty credits
  - Bounty is removed

BOUNTY COMMANDS:
- /bounty set  
- /bounty remove 
- /bounty check 
- /bounty list
- /bounty INVENTORY GUI

CREDIT COMMANDS:
- /credits
- /credits check 
- /credits pay   (optional admin or permission-based transfer)

PERMISSIONS (LuckPerms compatible):
- bountysystem.use
- bountysystem.set
- bountysystem.remove
- bountysystem.check
- bountysystem.list
- bountysystem.INVENTORY GUI
- bountysystem.credits.check
- bountysystem.admin

PLACEHOLDERAPI SUPPORT:
Provide placeholders:
- %credits%
- %credits_%
- %bounty_amount_%
- %bounty_exists_%
- %bounty_top_player%
- %bounty_top_value%

TAB PLUGIN SUPPORT:
- Fully integrate PlaceholderAPI
- Credits and bounty values must update in real-time for TAB and scoreboard usage

SHOP INVENTORY GUI SYSTEM (VERY IMPORTANT):
Create a fully interactive inventory INVENTORY GUI:

/shop or /bounty shop opens a INVENTORY GUI where players can spend credits.

SHOP ITEMS:

1. Netherite Ingot
   - Cost: 560 credits

2. Diamond
   - Cost: 400 credits

3. Netherite Block
   - Cost: 3000 credits

4. Golden Apples (32x)
   - Cost: 1000 credits

5. Enchanted Golden Apples (3x)
   - Cost: 2000 credits

INVENTORY GUI REQUIREMENTS:
- Clickable items
- Shows cost in lore
- Shows player current credits
- Prevent purchase if insufficient credits
- Confirm purchase feedback message
- Clean, organized layout (filler panes optional)

DATA STORAGE:
- Store player UUID, credits balance, bounty data
- Use SQLite or YAML

FEATURES:
- Anti-exploit system (prevent negative credits)
- Cooldowns for bounty placement (configurable)
- Optional self-bounty prevention
- Broadcast message when bounty is placed or claimed
- Sound + chat feedback on transactions

CONFIG EXAMPLE:
settings:
  allow-self-bounty: false
  bounty-cooldown: 300

credits:
  starting-amount: 1000

bounty-system:
  broadcast-bounties: true

SHOP PRICES:
  NETHERITE_INGOT: 560
  DIAMOND: 400
  NETHERITE_BLOCK: 3000
  GOLDEN_APPLE_32: 1000
  ENCHANTED_GOLDEN_APPLE_3: 2000

CODE STRUCTURE:
- Main plugin class
- CreditManager class
- BountyManager class
- ShopGUI class
- Command handlers
- PlaceholderAPI hook class
- Data storage handler (SQLite preferred)

IMPLEMENTATION REQUIREMENTS:
- Clean OOP structure
- Async database operations where needed
- Bukkit/Paper best practices
- Lightweight and optimized
- Fully standalone plugin (NO dependencies except PlaceholderAPI optional hook)
- INVENTORY GUI must be stable and not allow duplication exploits

OUTPUT:
- Full Java source code
- plugin.yml
- config.yml
- Setup instructions
Kodari AI
KodariMay 7 at 8:39 pm 24,871 (v2)
BountySystem
A standalone bounty and credit economy plugin for Spigot/Paper 1.16–1.21+. Players earn and spend internal Credits currency to place bounties on other players. Killers receive bounty Credits automatically. Includes an interactive shop GUI for spending credits on items, PlaceholderAPI support for TAB/scoreboards, SQLite data storage, cooldown protection, anti-exploit guards, and full permission node support. No external economy dependencies required.

Plan:

  • DatabaseManager handles all SQLite async I/O for credits + bounties

  • CreditManager / BountyManager wrap DB logic with in-memory caching

  • Full inventory GUI framework (InventoryHandler → InventoryGUI → ShopGUI / BountyListGUI)

  • BountyCommand, CreditsCommand, ShopCommand for all interactions

  • PlayerDeathListener for bounty claim on kill

  • BountyPlaceholderExpansion for PAPI hooks

  • Maven pom.xml (no Gradle)

All 18 files created. Here’s a quick summary of what was built:


Project structure:

  • DatabaseManager — SQLite with async writes, ON CONFLICT upserts for credits and bounties

  • CreditManager — In-memory ConcurrentHashMap cache wrapping DB; deduct() is atomic and guards against negatives

  • BountyManager — Cache-first bounty storage with cooldown tracking and top-bounty lookup

  • GUI framework — InventoryGUI (lazy init) → ShopGUI / BountyListGUI via GUIManager

  • ShopGUI — 54-slot shop with border fillers, live credit display, purchase guards, leftover item drop on full inventory

  • BountyListGUI — Paginated 45-slot skull display sorted by bounty value descending

  • PlayerDeathListener — MONITOR priority to claim bounty after death is confirmed

  • BountyPlaceholderExpansion — All 6 PAPI placeholders using bountysystem_ identifier

  • /credits set and /credits add admin sub-commands included

To install: mvn package, drop the shaded jar into /plugins, restart. SQLite JDBC is shaded in automatically.

Kodari can make mistakes. Review important code before using.
Files
src
pom.xml
Code
20 1,608
src/main/java/com/bountysystem/BountySystem.java
package com.bountysystem;

import com.bountysystem.commands.BountyCommand;
import com.bountysystem.commands.CreditsCommand;
import com.bountysystem.commands.ShopCommand;
import com.bountysystem.data.DatabaseManager;
import com.bountysystem.listeners.PlayerDeathListener;
import com.bountysystem.managers.BountyManager;
import com.bountysystem.managers.CreditManager;
import com.bountysystem.inventory.gui.GUIListener;
import com.bountysystem.inventory.gui.GUIManager;
import com.bountysystem.placeholder.BountyPlaceholderExpansion;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public class BountySystem extends JavaPlugin {

    private DatabaseManager databaseManager;
    private CreditManager creditManager;
    private BountyManager bountyManager;
    private GUIManager guiManager;

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

        databaseManager = new DatabaseManager(this);
        databaseManager.initialize();

        creditManager = new CreditManager(this, databaseManager);
        bountyManager = new BountyManager(this, databaseManager, creditManager);

        guiManager = new GUIManager();

        GUIListener guiListener = new GUIListener(guiManager);
        Bukkit.getPluginManager().registerEvents(guiListener, this);
        Bukkit.getPluginManager().registerEvents(new PlayerDeathListener(this, bountyManager, creditManager), this);

        getCommand("bounty").setExecutor(new BountyCommand(this, bountyManager, creditManager, guiManager));
        getCommand("credits").setExecutor(new CreditsCommand(this, creditManager));
        getCommand("shop").setExecutor(new ShopCommand(this, creditManager, guiManager));

        if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            new BountyPlaceholderExpansion(this, creditManager, bountyManager).register();
            getLogger().info("PlaceholderAPI hooked successfully.");
        }

        getLogger().info("BountySystem enabled.");
    }

    @Override
    public void onDisable() {
        if (databaseManager != null) {
            databaseManager.close();
        }
        getLogger().info("BountySystem disabled.");
    }

    public DatabaseManager getDatabaseManager() {
        return databaseManager;
    }

    public CreditManager getCreditManager() {
        return creditManager;
    }

    public BountyManager getBountyManager() {
        return bountyManager;
    }

    public GUIManager getGuiManager() {
        return guiManager;
    }

    public String getMessage(String key) {
        String prefix = getConfig().getString("messages.prefix", "&8[&6Bounty&8] &r");
        String msg = getConfig().getString("messages." + key, "&cMissing message: " + key);
        return colorize(prefix + msg);
    }

    public String getMessageRaw(String key) {
        return colorize(getConfig().getString("messages." + key, "&cMissing message: " + key));
    }

    public static String colorize(String text) {
        return org.bukkit.ChatColor.translateAlternateColorCodes('&', text);
    }
}