Kartik sharma

this plugin for 1.21.11

📎 1 file 9,928 chars
📄
pasted-code-1790487092278.txt
txt 605 lines
▶
Create a complete, production-ready Minecraft Java Edition server plugin called **BountyHunter**.

### Goal

Create a highly engaging **Bounty Hunter + Crime Record system** where every player has a Crime Level and Bounty. Players who commit crimes, especially killing other players, become more wanted. Their bounty increases, creating a "Most Wanted" system and PvP drama.

The plugin should be optimized for multiplayer survival/PvP servers and designed to create viral gameplay moments.

### Compatibility

* Minecraft Java Edition
* Paper/Spigot
* Target a modern Minecraft version
* Java 21+
* Use clean, efficient and maintainable code
* Avoid unnecessary dependencies
* Make all important values configurable

---

## 1. Crime System

Every player should have:

* Crime Level
* Total Crimes
* Player Kills
* Deaths
* Current Bounty
* Highest Bounty
* Wanted Status
* Last Crime Time

When a player kills another player:

1. Register the kill as a crime.
2. Increase the killer's Crime Level.
3. Increase their bounty.
4. Record the victim.
5. Send a configurable message to the killer.
6. Broadcast an optional server-wide message if the new bounty reaches certain levels.

Example:

Player A kills Player B.

Player A:

Crime Level: 1
Bounty: $1,000

If Player A continues killing players:

Crime Level: 5
Bounty: $25,000

Crime Level: 10
Bounty: $100,000

The bounty calculation must be configurable.

---

## 2. Bounty System

Each player can have a monetary bounty placed on them.

Command:

/bounty set  

Example:

/bounty set Steve 50000

This should place a $50,000 bounty on Steve.

Add permissions for admin commands.

Suggested permissions:

bounty.admin
bounty.set
bounty.view
bounty.claim

The plugin should prevent invalid amounts and negative values.

---

## 3. Bounty Claiming

When a player kills a wanted player:

* The killer receives the target's bounty.
* The target's bounty becomes 0.
* A configurable percentage can optionally be taken as a server tax.
* The kill is recorded in the crime history.
* The killer receives a reward message.
* A server-wide announcement can optionally be displayed.

Example:

Steve has a $100,000 bounty.

Alex kills Steve.

Alex receives:

$100,000

Optional tax:

10%

Alex receives:

$90,000

Steve's bounty becomes:

$0

Make the tax configurable in config.yml.

---

## 4. Most Wanted Leaderboard

Create a leaderboard showing players with the highest current bounty.

Command:

/mostwanted

Also allow:

/bounty top

Display something like:

╔══════════════════════╗
MOST WANTED
╠══════════════════════╣

1. Steve - $500,000
2. Alex - $350,000
3. Notch - $200,000
4. Player4 - $125,000
5. Player5 - $100,000
   ╚══════════════════════╝

Include:

* Player name
* Current bounty
* Crime level
* Number of kills

Make the format completely configurable.

---

## 5. GUI Leaderboard

Create an optional inventory GUI for the Most Wanted leaderboard.

Command:

/wanted

GUI should contain player heads.

Each player's head should show:

Player Name
Current Bounty
Crime Level
Kills
Deaths
Total Crimes

Clicking a player's head should open a detailed profile.

Use configurable GUI title, item slots and item names.

---

## 6. Crime Record

Every player should have a permanent crime record.

Command:

/crime 

Example output:

Crime Record: Steve

Crime Level: 12
Current Bounty: $450,000
Total Crimes: 18
Player Kills: 18
Deaths: 7
Highest Bounty: $700,000

Recent Crimes:

1. Killed Alex
2. Killed John
3. Killed Bob

Store crime history in persistent storage.

---

## 7. Wanted Posters

Add an in-game Wanted Poster system.

Command:

/wantedposter 

Generate a formatted Minecraft message such as:

━━━━━━━━━━━━━━━━━━━━
WANTED
━━━━━━━━━━━━━━━━━━━━

PLAYER: Steve

BOUNTY:
$500,000

CRIME LEVEL:
12

CRIMES:
18

"DEAD OR ALIVE"

━━━━━━━━━━━━━━━━━━━━

Allow server administrators to customize the design.

Optional feature:

Allow the poster to be displayed as an item or GUI.

---

## 8. Bounty Notifications

When a player's bounty becomes high enough, send notifications.

Example:

⚠ STEVE IS NOW WANTED!

Bounty: $100,000

Crime Level: 8

Optional server-wide broadcast:

☠ MOST WANTED ALERT ☠
Steve's bounty has reached $100,000!

Make notification thresholds configurable.

---

## 9. Bounty Hunter Tracking

Add an optional tracking system.

Command:

/hunt 

If the player is online, provide the hunter with a compass that points toward the target.

Example:

/hunt Steve

Compass → Steve

The tracking system should:

* Update periodically
* Stop when the target disconnects
* Stop when the target dies
* Be configurable
* Avoid excessive server load

---

## 10. Bounty Hunting Statistics

Track:

* Total bounties claimed
* Total money earned from bounties
* Most valuable kill
* Total hunted players
* Successful hunts

Command:

/hunterstats

Example:

Hunter Statistics

Bounties Claimed: 27
Money Earned: $1,250,000
Most Valuable Kill: $500,000
Successful Hunts: 27

---

## 11. Anti-Abuse Protection

VERY IMPORTANT:

Prevent players from farming bounty by repeatedly killing the same player.

Implement configurable anti-abuse protection such as:

* Kill cooldown between the same two players
* Reduced bounty for repeated kills
* Daily/temporary bounty claim limit
* Alt/farming protection where reasonably possible
* Prevent self-kills from generating bounty
* Prevent environmental deaths from incorrectly awarding bounty

All anti-abuse settings must be configurable.

---

## 12. Economy Integration

Support Vault economy.

If Vault is installed:

* Use Vault for money
* Deposit bounty rewards into the killer's balance
* Withdraw money when manually setting a bounty, if configured

If Vault is not installed:

* Clearly state the dependency requirement
* Do not crash the server

Make economy behavior configurable.

---

## 13. Storage

Use SQLite by default.

Store:

* UUID
* Player name
* Crime level
* Current bounty
* Total crimes
* Kills
* Deaths
* Highest bounty
* Total bounty earnings
* Crime history
* Bounty history

Use UUID instead of player names as the primary identifier.

The plugin must load/save data safely and asynchronously where appropriate.

---

## 14. Commands

Implement these commands:

/bounty
/bounty set  
/bounty add  
/bounty remove  
/bounty top

/crime 

/mostwanted

/wanted

/wantedposter 

/hunt 

/hunterstats

/bounty reload

Add tab completion for commands.

Add proper permission checks and helpful error messages.

---

## 15. Configuration

Create a detailed config.yml.

Everything important should be configurable, including:

* Starting bounty
* Crime level increase
* Bounty increase per kill
* Kill rewards
* Economy tax
* Anti-abuse cooldown
* Broadcast settings
* GUI settings
* Messages
* Wanted thresholds
* Compass tracking interval
* Database settings
* Sound effects
* Particle effects
* Formatting

Example:

crime:
bounty-per-kill: 1000
crime-level-per-kill: 1

economy:
bounty-tax: 10

anti-abuse:
enabled: true
kill-cooldown: 3600

notifications:
broadcast-high-bounty: true

---

## 16. Visual Effects

Make important events feel exciting.

When a player claims a large bounty:

* Sound effect
* Particles
* Title
* Action bar
* Optional server-wide broadcast

Example:

TITLE:

BOUNTY CLAIMED!

SUBTITLE:

$500,000

Make all effects configurable.

---

## 17. Death Handling

Correctly detect player-vs-player kills.

The bounty should only be awarded when the configured PvP conditions are met.

Handle:

* Normal PvP kills
* Void deaths
* Fall damage
* Fire
* Lava
* Mobs
* Disconnect deaths

Do not accidentally reward bounty for non-PvP deaths.

---

## 18. Performance

The plugin must be lightweight.

Requirements:

* Do not run database queries synchronously on the main server thread.
* Avoid unnecessary repeating tasks.
* Cache frequently accessed player data.
* Properly close database connections.
* Prevent memory leaks.
* Handle large player counts efficiently.

---

## 19. Plugin Structure

Use a clean architecture such as:

BountyHunter/
├── src/main/java/
│   └── ...
├── commands/
├── listeners/
├── managers/
├── database/
├── gui/
├── models/
├── utils/
└── config/

Include:

plugin.yml

config.yml

messages.yml if useful

README.md

---

## 20. Code Quality

Write the COMPLETE plugin, not pseudocode.

Provide:

1. Full source code
2. pom.xml or Gradle build file
3. plugin.yml
4. config.yml
5. messages.yml if used
6. Database implementation
7. All commands
8. Event listeners
9. GUI
10. Tab completion
11. README with installation instructions

The code should compile without missing classes or placeholder methods.

Do not write:

"Implement this yourself"

"Add your code here"

"TODO"

or incomplete sections.

---

## 21. Important Gameplay Rule

The main gameplay loop should be:

COMMIT CRIMES
↓
CRIME LEVEL INCREASES
↓
BOUNTY INCREASES
↓
PLAYER BECOMES MORE WANTED
↓
APPEARS ON MOST WANTED LEADERBOARD
↓
OTHER PLAYERS HUNT THEM
↓
SOMEONE KILLS THEM
↓
HUNTER CLAIMS THE BOUNTY
↓
SERVER-WIDE DRAMA / ANNOUNCEMENT

Make this system feel exciting and suitable for YouTube content.

Before generating the code, briefly explain the architecture and important design decisions. Then provide the complete project files.
Kodari AI
KodariSep 27 at 5:34 am 2
BountyHunter
A comprehensive Minecraft bounty and crime tracking plugin. Players accumulate crime levels and bounties from PvP kills, appearing on a Most Wanted leaderboard. Hunters can claim bounties, track targets with compasses, and earn rewards through Vault economy integration. Features SQLite storage, configurable anti-abuse protections, GUI leaderboards, wanted posters, and detailed crime records. Includes configurable notifications, visual effects, and a complete command suite with tab completion.

Architecture: a Paper 1.21.11 plugin with a SQLite-backed player profile cache, asynchronous database work, and main-thread-safe gameplay updates. One command router handles all requested commands; dedicated listeners manage PvP, tracking, and the Most Wanted inventory. Vault is optional at startup, but bounty payouts and configured withdrawals require it.

  1. Persist profiles, crime history, bounty history, and hunter stats in SQLite.

  2. Add configurable crime growth, bounty claims/tax, anti-farming cooldowns, alerts, and tracking.

  3. Implement commands, tab completion, wanted GUI/posters, and setup documentation.

Created the BountyHunter project for Paper 1.21.11 and Java 21, including:

  • SQLite-backed player profiles, crime records, and bounty history, with database work on a dedicated thread.

  • PvP crime and bounty growth, configurable repeat-kill protection, Vault payouts and tax, and wanted-threshold alerts.

  • Bounty, crime, leaderboard, poster, tracking, and hunter-stat commands with tab completion and permissions.

  • A Most Wanted player-head GUI, configurable messages and effects, plus installation instructions.

The project files are in place. I did not run a build or server test in this session.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
README.md
settings.gradle
Code
14 1,233
src/main/java/com/kodari/bountyhunter/BountyHunterPlugin.java
package com.kodari.bountyhunter;

import com.kodari.bountyhunter.command.BountyCommand;
import com.kodari.bountyhunter.listener.MenuListener;
import com.kodari.bountyhunter.listener.PlayerListener;
import com.kodari.bountyhunter.manager.BountyManager;
import com.kodari.bountyhunter.storage.SqliteDatabase;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
import java.util.Map;

public final class BountyHunterPlugin extends JavaPlugin {
    private SqliteDatabase database;
    private BountyManager bountyManager;
    private BountyCommand commandHandler;
    private Economy economy;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        String databaseName = getConfig().getString("database.file", "bountyhunter.db");
        database = new SqliteDatabase(new java.io.File(getDataFolder(), databaseName));
        bountyManager = new BountyManager(this, database);
        if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
            RegisteredServiceProvider<Economy> registration = Bukkit.getServicesManager().getRegistration(Economy.class);
            if (registration != null) economy = registration.getProvider();
        }
        if (economy == null) getLogger().warning("Vault economy not found. Bounty payouts and configured manual withdrawals are unavailable.");

        commandHandler = new BountyCommand(this);
        for (String name : new String[]{"bounty", "crime", "mostwanted", "wanted", "wantedposter", "hunt", "hunterstats"}) {
            if (getCommand(name) != null) {
                getCommand(name).setExecutor(commandHandler);
                getCommand(name).setTabCompleter(commandHandler);
            }
        }
        Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
        Bukkit.getPluginManager().registerEvents(new MenuListener(this), this);
        for (Player player : Bukkit.getOnlinePlayers()) bountyManager.ensureProfile(player.getUniqueId(), player.getName(), profile -> { });

        long interval = Math.max(1L, getConfig().getLong("tracking.update-seconds", 2L)) * 20L;
        Bukkit.getScheduler().runTaskTimer(this, bountyManager::updateTrackers, interval, interval);
        getLogger().info("BountyHunter enabled.");
    }

    @Override
    public void onDisable() {
        if (bountyManager != null) {
            for (Player player : Bukkit.getOnlinePlayers()) {
                com.kodari.bountyhunter.model.PlayerProfile profile = bountyManager.getCached(player.getUniqueId());
                if (profile != null) database.save(profile);
            }
        }
        if (database != null) database.close();
    }

    public SqliteDatabase getDatabase() {
        return database;
    }

    public BountyManager getBountyManager() {
        return bountyManager;
    }

    public BountyCommand getCommandHandler() {
        return commandHandler;
    }

    public Economy getEconomy() {
        return economy;
    }

    public String configText(String path) {
        return getConfig().getString(path, "&cMissing message: " + path);
    }

    public String color(String text) {
        return ChatColor.translateAlternateColorCodes('&', text);
    }

    public void send(CommandSender sender, String path, Map<String, String> replacements) {
        String message = configText(path);
        for (Map.Entry<String, String> entry : replacements.entrySet()) message = message.replace("{" + entry.getKey() + "}", entry.getValue());
        sender.sendMessage(color(message));
    }

    public void broadcast(String path, Map<String, String> replacements) {
        if (path.equals("messages.bounty-claim-broadcast") && !getConfig().getBoolean("notifications.broadcast-claims", true)) return;
        String message = configText(path);
        for (Map.Entry<String, String> entry : replacements.entrySet()) message = message.replace("{" + entry.getKey() + "}", entry.getValue());
        Bukkit.broadcastMessage(color(message));
    }

    public String formatMoney(double amount) {
        String pattern = getConfig().getString("format.currency-pattern", "#,##0.##");
        DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(Locale.US);
        String formatted;
        try {
            formatted = new DecimalFormat(pattern, symbols).format(amount);
        } catch (IllegalArgumentException exception) {
            formatted = new DecimalFormat("#,##0.##", symbols).format(amount);
        }
        return getConfig().getString("format.currency-symbol", "$") + formatted;
    }
}