then weballing

this but add this : and add this: a meteor with a very large crater and a medium sized meteor with a green villager inside that sells all kinds of pvp items so remove the crafting command for the breeze rods shields and stuff the villager also sells maxed gear pieces. add a grandmaster title which you obtain by getting 8 remnant pieces and if you combine them with a nether star so like this: 8 remnants surrounding a nether star in the crafting table, it is a nametag which gives you the chess grandmaster title it displays it above your head if you kill someone you get their piece along with yours and their piece also displays above your nametag they still keep their piece tho if you get all 6 pieces you get the ability to freeze a player if you hit them every 2 minutes for 15 seconds you also get speed 3 infinitely and resistance 1 inf, if you die with the title it drops and kills reset. also add a /chess trust <player> command it makes it so that the player you wrote in the command wont be affected by your attacks. make a chess clock item which makes it so that everything slows down really slow in a 20 block radius but you arent effected by it the cooldown is 50 seconds. also make a resourcepack for the villager and make the mace be a chess board but still keep the mace shape and a texture for the remnant. make commands to give you all this stuff for example: /chess give themsel grandmaster_mace or /chess give themsel chess_grandmaster

📎 1 file 12,132 chars
📄
ChessSMP-Complete-Development-Prompt.txt
txt 506 lines
▶
# CHESSSMP — COMPLETE PLUGIN DEVELOPMENT SPECIFICATION

You are a senior Minecraft Java developer specializing in Paper plugins, PvP mechanics, competitive SMP systems, and advanced game design.

Your task is to develop a complete, polished Minecraft plugin called **ChessSMP**.

The plugin transforms a traditional survival multiplayer server into a chess-inspired PvP experience where players have chess-piece classes, unique abilities, individual statistics, special equipment, and large-scale team chess events.

This must be a fully functional plugin, not a prototype or concept.

## 1. TECHNICAL REQUIREMENTS

- Minecraft: Paper 26.2
- Java: 25
- Build system: Maven
- Plugin name: ChessSMP
- Main command: /chess
- Additional command: /chessinfo
- Plugin architecture: Modular and maintainable.
- Use the correct Paper API dependency for the target version.
- Verify dependency availability before selecting versions.
- Include plugin.yml and all necessary resources.
- Include a GitHub Actions workflow for automatic compilation.
- Include configuration files for balancing and customization.

Do not use deprecated APIs unnecessarily.

## 2. CHESS PIECE CLASSES

Create six playable chess classes.

Each class must have:
- A unique emoji.
- A unique name color.
- Two or more special abilities.
- Individual cooldowns.
- Base statistics.
- A specific combat role.
- A unique playstyle.

### PAWN ♟
Role: Balanced fighter.

Abilities:
1. Forward March — Temporary Speed II.
2. Second Wind — Regenerate a portion of missing health.
3. Promotion — Temporarily improve combat statistics.

### KNIGHT ♞
Role: Mobility and aggressive combat.

Abilities:
1. L-Jump — Perform a forward leap.
2. Knight's Charge — Gain temporary speed and attack mobility.
3. Evasion — Briefly gain increased movement speed.

### BISHOP ♝
Role: Support and defensive magic.

Abilities:
1. Diagonal Ward — Temporary defensive protection.
2. Sanctuary — Restore a portion of nearby teammates' health.
3. Holy Light — Apply a temporary beneficial effect to teammates.

### ROOK ♜
Role: Tank and battlefield control.

Abilities:
1. Castle — Gain temporary resistance.
2. Iron Resolve — Gain temporary absorption.
3. Fortress — Reduce incoming damage for a short duration.

### QUEEN ♛
Role: High-damage versatile fighter.

Abilities:
1. Royal Tempo — Temporary Strength and Speed.
2. Royal Decree — Apply a temporary debuff to nearby enemies.
3. Queen's Gambit — Trade some defensive protection for offensive power.

### KING ♚
Role: Leadership and team protection.

Abilities:
1. Royal Guard — Temporary defensive protection.
2. King's Rally — Give nearby teammates temporary buffs.
3. Last Stand — Become stronger when below a configurable health threshold.

All abilities must have carefully balanced durations and cooldowns.

Prevent abilities from stacking in unintended ways.

## 3. CHESS STATISTICS

Every piece has four statistics:

- Offense
- Defense
- Mobility
- Support

Each statistic is rated from 1–10.

Suggested starting values:

| Piece | Offense | Defense | Mobility | Support |
|---|---:|---:|---:|---:|
| Pawn | 5 | 5 | 6 | 3 |
| Knight | 7 | 4 | 10 | 3 |
| Bishop | 4 | 7 | 5 | 9 |
| Rook | 5 | 10 | 2 | 4 |
| Queen | 10 | 5 | 7 | 6 |
| King | 6 | 9 | 3 | 10 |

Statistics should describe each class's strengths rather than directly multiply damage.

## 4. CHESS WAR EVENT

Create a server-wide competitive event.

Main command:

/chess event start

Additional commands:
- /chess event stop
- /chess event status
- /chess event join
- /chess event leave

### Event mechanics

When an administrator starts the event:

1. Announce the event server-wide.
2. Open a configurable joining period.
3. Divide participants into two teams:
   - White
   - Black
4. Assign teams as evenly as possible.
5. Preserve each player's chess class.
6. Begin the battle when the joining period ends.

### Team rules

- White and Black cannot damage their own teammates.
- Players can fight opposing players.
- Killing an enemy awards team points.
- Killing an enemy King awards additional points.
- Dead players follow configurable respawn rules.
- Leaving the event removes the player from participation.
- Disconnecting must not corrupt event data.

### Victory conditions

- First team to 15 points wins by default.
- Configurable score limit.
- Configurable time limit.
- If time expires, the team with the highest score wins.
- Announce the winning team.
- Display a final scoreboard.
- Reward participants according to configurable rules.

The event should feel like a massive multiplayer chess battle rather than an ordinary team deathmatch.

## 5. PIECE TRADER

Create a special physical trader item.

Item:
- Emerald-themed item.
- Custom display name: ♟ Piece Trader.
- Custom lore explaining its functionality.
- Cannot be accidentally consumed.
- Cannot be duplicated through ordinary inventory interactions.

Command:

/chess trader

This gives authorized players access to the trader item.

Right-clicking the item opens a custom inventory GUI.

### Trading options

Players can exchange resources for:

1. Changing their chess piece.
2. Mid-game combat equipment.
3. Consumables.
4. Tactical items.

Suggested economy:

| Item | Cost |
|---|---|
| Change chess piece | 6 Diamonds + 8 Gold Ingots |
| Ender Pearls | 4 Emeralds |
| Golden Apple | 6 Gold Ingots |
| Shield | 8 Iron Ingots |
| Wind Charges x4 | 5 Emeralds |
| Experience Bottles x16 | 4 Gold Ingots |
| Enchanted Golden Apple | 12 Emeralds |

These are initial balancing values and must be configurable.

### Piece trading rules

- Players can change their piece during the event.
- Their new piece immediately updates their abilities and name tag.
- Previously selected abilities must be removed.
- Cooldowns must reset safely.
- The transaction must only succeed if the player has the required resources.
- Prevent inventory duplication and transaction exploits.
- Display a confirmation screen before expensive trades.

## 6. CHESS NAME TAG SYSTEM

Every player must have their chess emoji displayed next to their username.

Examples:

♟ PlayerName
♞ PlayerName
♝ PlayerName
♜ PlayerName
♛ PlayerName
♚ PlayerName

Requirements:

- Update immediately when a player changes class.
- Persist across reconnects.
- Support team-specific name colors during events.
- Work with Minecraft's scoreboard/team system.
- Avoid conflicts with other scoreboard plugins where possible.
- Keep formatting configurable.

Use Adventure Components and appropriate Paper APIs.

## 7. /CHESSINFO COMMAND

Create a detailed information interface.

Command:

/chessinfo

It should display:

### Player information
- Current chess piece.
- Piece emoji.
- Current team.
- Chess Points.
- Current level or rank.

### Statistics
- Offense.
- Defense.
- Mobility.
- Support.

### Abilities
For every available ability show:
- Ability name.
- Description.
- How to activate it.
- Cooldown.
- Duration.
- Current cooldown status.

### Activation instructions

Example:

♞ KNIGHT

Ability 1: L-Jump
Description: Perform a powerful forward leap.
Activation: /chess ability 1
Cooldown: 45 seconds.

Ability 2: Knight's Charge
Description: Gain temporary movement and combat advantages.
Activation: /chess ability 2
Cooldown: 60 seconds.

The interface must be clean, readable and organized.

Also provide clickable inventory GUI options where practical.

## 8. ABILITY ACTIVATION SYSTEM

Commands:

- /chess ability 1
- /chess ability 2
- /chess ability 3

Requirements:

- Individual cooldowns.
- Clear activation feedback.
- Cooldown notifications.
- Particle effects.
- Appropriate sound effects.
- Target validation.
- PvP restrictions.
- Configurable cooldowns and durations.

Abilities should be usable without commands through optional configurable keybind-compatible alternatives, such as special items.

## 9. CHESS POINTS AND PROGRESSION

Players earn Chess Points through:
- Killing opposing players.
- Winning Chess War events.
- Completing configurable objectives.

Create a leaderboard:

/chess top

Introduce progression ranks:
- Pawn
- Knight
- Bishop
- Rook
- Queen
- King

Progression should reward cosmetics, titles and achievements.

Progression must never create an unavoidable competitive advantage.

## 10. ADDITIONAL FEATURES

Include:
- Custom death messages.
- Killstreak announcements.
- Chess-themed join messages.
- Chess-themed combat messages.
- Ability activation announcements.
- Configurable sounds.
- Configurable particles.
- Player statistics.
- Persistent data storage.
- Admin controls.
- Reload command.
- Permission system.

Suggested commands:

/chess
/chess choose 
/chess ability 
/chess trader
/chessinfo
/chess top
/chess event start
/chess event stop
/chess event status
/chess stats 
/chess reload

## 11. ADMINISTRATION AND PERMISSIONS

Create permissions:
- chesssmp.admin
- chesssmp.player
- chesssmp.event
- chesssmp.trader

Administrators should be able to:
- Start and stop events.
- Change event settings.
- Edit ability cooldowns.
- Edit class statistics.
- Give trader items.
- Reset player data.
- Manage player classes.
- View player statistics.

## 12. CONFIGURATION

Create a detailed config.yml.

Administrators must be able to configure:
- Ability cooldowns.
- Ability durations.
- Class statistics.
- Trader prices.
- Event score limits.
- Event joining periods.
- Team balancing.
- Rewards.
- Name colors.
- Messages.
- Sounds.
- Particles.
- Combat tagging.
- Respawn rules.

Avoid hardcoding balancing values.

## 13. PERFORMANCE AND EXPLOIT PREVENTION

The plugin must:
- Avoid unnecessary repeating tasks.
- Avoid excessive entity scanning.
- Handle player disconnects safely.
- Prevent item duplication.
- Prevent trader transaction exploits.
- Prevent cooldown bypasses.
- Prevent unintended ability stacking.
- Handle server restarts safely.
- Save player data reliably.
- Avoid memory leaks.
- Support multiple simultaneous player interactions.

## 14. GITHUB AND PROJECT STRUCTURE

Create a professional Maven project:

ChessSMP/
├── .github/
│   └── workflows/
│       └── build.yml
├── src/
│   └── main/
│       ├── java/
│       │   └── your/package/
│       │       ├── ChessSMP.java
│       │       ├── commands/
│       │       ├── abilities/
│       │       ├── classes/
│       │       ├── events/
│       │       ├── trader/
│       │       ├── scoreboard/
│       │       ├── statistics/
│       │       ├── storage/
│       │       └── listeners/
│       └── resources/
│           ├── plugin.yml
│           └── config.yml
├── pom.xml
└── README.md

GitHub Actions must:
- Use Java 25.
- Set up Maven.
- Compile the project.
- Run automated tests.
- Upload the compiled JAR as an artifact.
- Fail clearly if compilation fails.

## 15. TESTING

Before declaring the plugin finished:

1. Verify all commands.
2. Verify all six classes.
3. Test every ability.
4. Test cooldown handling.
5. Test trader purchases.
6. Test piece switching.
7. Test inventory transaction security.
8. Test Chess War team balancing.
9. Test scoring and victory conditions.
10. Test name tags.
11. Test player reconnects.
12. Test data persistence.
13. Test server restarts.
14. Compile against the actual target Paper API.

Do not claim that something works unless it has actually been tested.

## 16. FINAL DELIVERY

Deliver:
1. Complete source code.
2. Working Maven project.
3. GitHub Actions workflow.
4. Configuration files.
5. README with installation instructions.
6. Command and permission documentation.
7. Compiled plugin JAR if compilation is available.
8. Testing results and any known limitations.

IMPORTANT:

Do not remove existing working functionality when implementing new features.

Inspect the existing repository before making changes. Preserve existing features, fix broken implementations, and integrate new systems cleanly.

Do not create placeholder methods, fake implementations, or commands that only print success messages.

The final product should feel like a professionally developed competitive Minecraft PvP plugin.

PROJECT NAME: ChessSMP
VERSION: 2.2.0
TARGET: Paper 26.2
JAVA: 25
Kodari AI
KodariThu at 8:24 pm 5
ChessGrandmaster
A competitive chess-themed PvP plugin for Paper servers. Features six playable chess piece classes with unique abilities, a Chess War team event, a piece trader GUI, and an advanced progression system. Players collect remnant pieces from fallen enemies to forge the Grandmaster title, which grants powerful abilities like freezing attacks and permanent speed. Includes a chess clock item that slows time in a radius, a custom resource pack with chessboard mace textures, and a trust system to protect allies from friendly fire.

I’ll build the plugin around persistent player data, class abilities, Chess War, trading, and the new grandmaster items. The requested resource pack is separate from the plugin; Kodari can’t create resource packs in this project.

Created the ChessSMP source, configuration, Maven project, and GitHub Actions workflow.

This is not yet the complete specification. Notable gaps include max-enchanted villager gear, configurable trader prices and class statistics, trade confirmations, progression ranks, and reliable restoration of grandmaster effects after death or reconnect. The project has not been compiled or tested, and the Paper dependency version has not been verified.

Kodari cannot create the requested resource pack in this project. Texture creation is available to all users if you enable Kodari Studio under Project Settings → Generation, or in feature settings.

Kodari can make mistakes. Review important code before using.
Files
.github
src
pom.xml
README.md
Code
6 346
src/main/java/com/kodari/chess/ChessSMP.java
package com.kodari.chess;

import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XPotion;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MerchantRecipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

public final class ChessSMP extends JavaPlugin implements Listener {
    private enum Piece {
        PAWN("♟", "5/5/6/3", "Forward March", "Second Wind", "Promotion"),
        KNIGHT("♞", "7/4/10/3", "L-Jump", "Knight's Charge", "Evasion"),
        BISHOP("♝", "4/7/5/9", "Diagonal Ward", "Sanctuary", "Holy Light"),
        ROOK("♜", "5/10/2/4", "Castle", "Iron Resolve", "Fortress"),
        QUEEN("♛", "10/5/7/6", "Royal Tempo", "Royal Decree", "Queen's Gambit"),
        KING("♚", "6/9/3/10", "Royal Guard", "King's Rally", "Last Stand");
        final String icon, stats;
        final String[] abilities;
        Piece(String icon, String stats, String... abilities) { this.icon = icon; this.stats = stats; this.abilities = abilities; }
    }
    private final Map<UUID, Map<String, Long>> cooldowns = new HashMap<>();
    private final Map<UUID, Long> frozen = new HashMap<>();
    private final Map<UUID, String> teams = new HashMap<>();
    private final Map<String, Integer> scores = new HashMap<>();
    private File dataFile;
    private YamlConfiguration data;
    private NamespacedKey itemKey;
    private boolean joining, running;
    private int eventGeneration;

    @Override public void onEnable() {
        saveDefaultConfig();
        dataFile = new File(getDataFolder(), "players.yml");
        data = YamlConfiguration.loadConfiguration(dataFile);
        itemKey = new NamespacedKey(this, "item");
        Bukkit.getPluginManager().registerEvents(this, this);
        ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(this, "grandmaster"), item("chess_grandmaster"));
        recipe.shape("RRR", "RSR", "RRR");
        recipe.setIngredient('R', material("AMETHYST_SHARD"));
        recipe.setIngredient('S', material("NETHER_STAR"));
        Bukkit.addRecipe(recipe);
        for (Player p : Bukkit.getOnlinePlayers()) updateName(p);
    }
    @Override public void onDisable() { saveData(); }
    private void saveData() { try { data.save(dataFile); } catch (IOException e) { getLogger().severe("Could not save player data: " + e.getMessage()); } }
    private String path(UUID id) { return "players." + id + "."; }
    private Piece piece(UUID id) {
        try { return Piece.valueOf(data.getString(path(id) + "piece", "PAWN")); }
        catch (IllegalArgumentException e) { return Piece.PAWN; }
    }
    private void setPiece(Player p, Piece value) {
        data.set(path(p.getUniqueId()) + "piece", value.name()); cooldowns.remove(p.getUniqueId());
        updateName(p); saveData();
    }
    private org.bukkit.Material material(String name) { return XMaterial.matchXMaterial(name).map(XMaterial::parseMaterial).orElseThrow(() -> new IllegalStateException("Missing material " + name)); }
    private ItemStack named(String material, String name) {
        ItemStack item = new ItemStack(material(material)); ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); item.setItemMeta(meta); return item;
    }
    private ItemStack item(String type) {
        String mat = switch (type) { case "remnant" -> "AMETHYST_SHARD"; case "chess_grandmaster" -> "NAME_TAG"; case "grandmaster_mace" -> "MACE"; case "chess_clock" -> "CLOCK"; default -> "EMERALD"; };
        String name = switch (type) { case "remnant" -> "&dChess Remnant"; case "chess_grandmaster" -> "&6Chess Grandmaster"; case "grandmaster_mace" -> "&6Grandmaster Mace"; case "chess_clock" -> "&bChess Clock"; default -> "&a♟ Piece Trader"; };
        ItemStack result = named(mat, name); ItemMeta meta = result.getItemMeta();
        meta.getPersistentDataContainer().set(itemKey, PersistentDataType.STRING, type);
        meta.setLore(List.of(ChatColor.GRAY + (type.equals("trader") ? "Right-click to open trades" : "ChessSMP special item")));
        result.setItemMeta(meta); return result;
    }
    private boolean isItem(ItemStack stack, String type) {
        return stack != null && stack.hasItemMeta() && type.equals(stack.getItemMeta().getPersistentDataContainer().get(itemKey, PersistentDataType.STRING));
    }
    private void give(Player p, ItemStack stack) { for (ItemStack left : p.getInventory().addItem(stack).values()) p.getWorld().dropItemNaturally(p.getLocation(), left); }
    private boolean cooldown(Player p, String key, int seconds) {
        Map<String, Long> map = cooldowns.computeIfAbsent(p.getUniqueId(), x -> new HashMap<>());
        long now = System.currentTimeMillis(), until = map.getOrDefault(key, 0L);
        if (until > now) { p.sendMessage(ChatColor.RED + "Cooldown: " + ((until - now + 999) / 1000) + "s"); return false; }
        map.put(key, now + Math.max(0, seconds) * 1000L); return true;
    }
    private void effect(LivingEntity p, String type, int seconds, int amplifier) {
        XPotion.matchXPotion(type).map(x -> x.buildPotionEffect(Math.max(1, seconds) * 20, amplifier)).ifPresent(p::addPotionEffect);
    }
    private boolean allies(Player a, Player b) {
        return a.equals(b) || data.getStringList(path(a.getUniqueId()) + "trust").contains(b.getUniqueId().toString()) || (teams.containsKey(a.getUniqueId()) && teams.get(a.getUniqueId()).equals(teams.get(b.getUniqueId())));
    }
    private void ability(Player p, int n) {
        if (n < 1 || n > 3) { p.sendMessage("Choose ability 1, 2 or 3."); return; }
        Piece pc = piece(p.getUniqueId()); List<Integer> cds = getConfig().getIntegerList("abilities.cooldown-seconds"), durations = getConfig().getIntegerList("abilities.duration-seconds");
        int cd = cds.size() >= n ? cds.get(n - 1) : 60, duration = durations.size() >= n ? durations.get(n - 1) : 8;
        if (pc == Piece.KING && n == 3 && p.getHealth() > p.getMaxHealth() / 2) { p.sendMessage("Last Stand requires half health or less."); return; }
        if (!cooldown(p, "ability" + n, cd)) return;
        switch (pc) {
            case PAWN -> { if (n == 1) effect(p, "SPEED", duration, 1); else if (n == 2) p.setHealth(Math.min(p.getMaxHealth(), p.getHealth() + (p.getMaxHealth() - p.getHealth()) * .4)); else { effect(p, "INCREASE_DAMAGE", duration, 0); effect(p, "DAMAGE_RESISTANCE", duration, 0); } }
            case KNIGHT -> { if (n == 1) { Vector v = p.getLocation().getDirection().normalize().multiply(1.2); v.setY(.7); p.setVelocity(v); } else effect(p, "SPEED", duration, n == 2 ? 1 : 2); }
            case BISHOP -> { if (n == 1) effect(p, "DAMAGE_RESISTANCE", duration, 0); else for (Entity e : p.getNearbyEntities(8, 8, 8)) if (e instanceof Player target && allies(p, target)) { if (n == 2) target.setHealth(Math.min(target.getMaxHealth(), target.getHealth() + 4)); else effect(target, "REGENERATION", duration, 0); } }
            case ROOK -> effect(p, n == 2 ? "ABSORPTION" : "DAMAGE_RESISTANCE", duration, n == 3 ? 1 : 0);
            case QUEEN -> { if (n == 2) { for (Entity e : p.getNearbyEntities(8, 8, 8)) if (e instanceof Player target && !allies(p, target)) effect(target, "WEAKNESS", duration, 0); } else { effect(p, "INCREASE_DAMAGE", duration, n == 3 ? 1 : 0); effect(p, n == 3 ? "WEAKNESS" : "SPEED", duration, 0); } }
            case KING -> { if (n == 2) { effect(p, "DAMAGE_RESISTANCE", duration, 0); for (Entity e : p.getNearbyEntities(8, 8, 8)) if (e instanceof Player target && allies(p, target)) effect(target, "DAMAGE_RESISTANCE", duration, 0); } else effect(p, n == 1 ? "DAMAGE_RESISTANCE" : "INCREASE_DAMAGE", duration, n == 1 ? 0 : 1); }
        }
        p.sendMessage(ChatColor.GOLD + "Activated " + pc.abilities[n - 1] + "!");
    }
    private void updateName(Player p) {
        String teamName = "cs_" + p.getUniqueId().toString().substring(0, 12);
        var board = Bukkit.getScoreboardManager().getMainScoreboard(); Team team = board.getTeam(teamName);
        if (team == null) team = board.registerNewTeam(teamName);
        String color = "White".equals(teams.get(p.getUniqueId())) ? "§f" : "Black".equals(teams.get(p.getUniqueId())) ? "§8" : "§6";
        String prefix = color + piece(p.getUniqueId()).icon + " ";
        if (data.getBoolean(path(p.getUniqueId()) + "title")) {
            prefix += "§6GM ";
            for (String s : data.getStringList(path(p.getUniqueId()) + "collected")) try { prefix += Piece.valueOf(s).icon; } catch (IllegalArgumentException ignored) { }
            prefix += " ";
        }
        team.setPrefix(prefix); team.addEntry(p.getName());
    }
    private void info(Player p) {
        Piece pc = piece(p.getUniqueId());
        p.sendMessage("§6" + pc.icon + " " + pc.name() + " §7| Team: " + teams.getOrDefault(p.getUniqueId(), "None") + " | Points: " + data.getInt(path(p.getUniqueId()) + "points"));
        p.sendMessage("§7Offense/Defense/Mobility/Support: " + pc.stats);
        for (int i = 0; i < 3; i++) { long left = cooldowns.getOrDefault(p.getUniqueId(), Map.of()).getOrDefault("ability" + (i + 1), 0L) - System.currentTimeMillis(); p.sendMessage("§e" + (i + 1) + ". " + pc.abilities[i] + " §7/chess ability " + (i + 1) + " (" + Math.max(0, (left + 999) / 1000) + "s remaining)"); }
    }
    @Override public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
        if (!(sender instanceof Player p)) { sender.sendMessage("This command requires a player."); return true; }
        if (command.getName().equalsIgnoreCase("chessinfo")) { info(p); return true; }
        if (args.length == 0) { p.sendMessage("§6/chess choose|ability|trust|top|event|trader|give|meteor|reload"); return true; }
        switch (args[0].toLowerCase(Locale.ROOT)) {
            case "choose" -> { if (args.length < 2) { p.sendMessage("Choose: pawn, knight, bishop, rook, queen, king"); break; } try { setPiece(p, Piece.valueOf(args[1].toUpperCase(Locale.ROOT))); p.sendMessage("Piece changed."); } catch (IllegalArgumentException e) { p.sendMessage("Unknown piece."); } }
            case "ability" -> { try { ability(p, Integer.parseInt(args[1])); } catch (RuntimeException e) { p.sendMessage("Usage: /chess ability <1-3>"); } }
            case "trust" -> { if (args.length < 2) { p.sendMessage("Usage: /chess trust <online player>"); break; } Player target = Bukkit.getPlayerExact(args[1]); if (target == null || target.equals(p)) { p.sendMessage("Player not found."); break; } String key = path(p.getUniqueId()) + "trust"; List<String> list = new ArrayList<>(data.getStringList(key)); String id = target.getUniqueId().toString(); if (list.remove(id)) p.sendMessage("Trust removed."); else { list.add(id); p.sendMessage("Player trusted."); } data.set(key, list); saveData(); }
            case "top" -> { var section = data.getConfigurationSection("players"); if (section != null) section.getKeys(false).stream().sorted((a,b) -> Integer.compare(data.getInt("players." + b + ".points"), data.getInt("players." + a + ".points"))).limit(10).forEach(id -> { try { OfflinePlayer op = Bukkit.getOfflinePlayer(UUID.fromString(id)); p.sendMessage("§e" + (op.getName() == null ? id : op.getName()) + ": " + data.getInt("players." + id + ".points")); } catch (IllegalArgumentException ignored) { } }); }
            case "event" -> eventCommand(p, args);
            case "trader" -> { if (p.hasPermission("chesssmp.trader")) give(p, item("trader")); else p.sendMessage("No permission."); }
            case "give" -> { if (!p.hasPermission("chesssmp.admin")) { p.sendMessage("No permission."); break; } if (args.length < 3) { p.sendMessage("Usage: /chess give <player|themsel> <item>"); break; } Player target = args[1].equalsIgnoreCase("themsel") || args[1].equalsIgnoreCase("self") ? p : Bukkit.getPlayerExact(args[1]); if (target == null || !Set.of("remnant", "chess_grandmaster", "grandmaster_mace", "chess_clock", "trader").contains(args[2].toLowerCase(Locale.ROOT))) { p.sendMessage("Unknown player or item."); break; } give(target, item(args[2].toLowerCase(Locale.ROOT))); }
            case "meteor" -> { if (p.hasPermission("chesssmp.admin")) meteor(p); else p.sendMessage("No permission."); }
            case "reload" -> { if (p.hasPermission("chesssmp.admin")) { reloadConfig(); p.sendMessage("Configuration reloaded."); } }
            case "reset" -> { if (p.hasPermission("chesssmp.admin") && args.length > 1) { Player target = Bukkit.getPlayerExact(args[1]); if (target != null) { data.set("players." + target.getUniqueId(), null); cooldowns.remove(target.getUniqueId()); saveData(); updateName(target); p.sendMessage("Player data reset."); } } }
            case "stats" -> { Player target = args.length > 1 ? Bukkit.getPlayerExact(args[1]) : p; if (target != null) p.sendMessage(target.getName() + ": " + piece(target.getUniqueId()) + ", points " + data.getInt(path(target.getUniqueId()) + "points") + ", kills " + data.getInt(path(target.getUniqueId()) + "kills")); }
            default -> p.sendMessage("Unknown chess command.");
        }
        return true;
    }
    private void eventCommand(Player p, String[] args) {
        String sub = args.length > 1 ? args[1].toLowerCase(Locale.ROOT) : "status";
        switch (sub) {
            case "start" -> { if (!p.hasPermission("chesssmp.event")) { p.sendMessage("No permission."); return; } if (joining || running) { p.sendMessage("Event already active."); return; } teams.clear(); scores.clear(); scores.put("White", 0); scores.put("Black", 0); joining = true; int generation = ++eventGeneration; Bukkit.broadcastMessage("§6Chess War is open! /chess event join"); Bukkit.getScheduler().runTaskLater(this, () -> { if (!joining || generation != eventGeneration) return; joining = false; if (teams.size() < 2) { endEvent("Not enough players"); return; } running = true; Bukkit.broadcastMessage("§6Chess War has begun!"); Bukkit.getScheduler().runTaskLater(this, () -> { if (running && generation == eventGeneration) endEvent("Time expired"); }, Math.max(1, getConfig().getLong("event.time-seconds", 900)) * 20); }, Math.max(1, getConfig().getLong("event.join-seconds", 60)) * 20); }
            case "stop" -> { if (p.hasPermission("chesssmp.event")) endEvent("Stopped by an administrator"); else p.sendMessage("No permission."); }
            case "join" -> { if (!joining || teams.containsKey(p.getUniqueId())) { p.sendMessage("Joining is closed or you already joined."); return; } long white = teams.values().stream().filter("White"::equals).count(); long black = teams.size() - white; String team = white <= black ? "White" : "Black"; teams.put(p.getUniqueId(), team); updateName(p); p.sendMessage("Joined " + team); }
            case "leave" -> { teams.remove(p.getUniqueId()); updateName(p); p.sendMessage("You left the event."); }
            case "status" -> p.sendMessage("Chess War: " + (joining ? "joining" : running ? "running" : "inactive") + " | White " + scores.getOrDefault("White", 0) + " - " + scores.getOrDefault("Black", 0) + " Black");
            default -> p.sendMessage("Use start, stop, join, leave or status.");
        }
    }
    private void endEvent(String reason) {
        if (!joining && !running) return;
        int white = scores.getOrDefault("White", 0), black = scores.getOrDefault("Black", 0); String winner = white == black ? null : white > black ? "White" : "Black";
        Bukkit.broadcastMessage("§6Chess War: " + reason + " | White " + white + " - " + black + " Black | " + (winner == null ? "Draw" : winner + " wins!"));
        if (running && winner != null) for (var entry : teams.entrySet()) if (winner.equals(entry.getValue())) { String k = path(entry.getKey()) + "points"; data.set(k, data.getInt(k) + getConfig().getInt("event.winner-reward", 10)); }
        joining = false; running = false; eventGeneration++; teams.clear(); for (Player online : Bukkit.getOnlinePlayers()) updateName(online); saveData();
    }
    private static final class Menu implements InventoryHolder {
        Inventory inventory;