King

Make thia plugin

๐Ÿ“Ž 1 file 14,149 chars
๐Ÿ“„
shadowthebot_spec.txt
txt 848 lines
โ–ถ
You are a senior Minecraft Paper 26.2 / Minecraft 1.21.11 Java plugin engineer specializing in player-like PvP bots, AI combat systems, NMS/internal Minecraft architecture, and configurable inventory GUIs.

Your task is to COMPLETE and FIX the Shadowthebot plugin.

==================================================
PROJECT

Name: Shadowthebot
Plugin ID: shadowthebot
Author: shadow
Main package: shadow.shadowthebot
Main class: shadow.shadowthebot.ShadowthebotPlugin
Jar: Shadowthebot-1.0.0.jar

Target:
Paper 26.2
Minecraft 1.21.11
Java 25

BUILD REQUIREMENT:
JAVAC ONLY.

DO NOT use:

- Maven
- Gradle
- Gradle wrapper
- Maven wrapper

The final source must compile into a working JAR using javac.

==================================================
MOST IMPORTANT OBJECTIVE

A previous version successfully created a GUI, but clicking Spawn Bot does NOT actually spawn a working bot.

The previous Target GUI also shows other online players.

FIX THE ACTUAL BOT ENGINE FIRST.

The GUI is secondary.

SUCCESS means:

PLAYER CLICKS SPAWN BOT
โ†“
A REAL BOT IS CREATED
โ†“
BOT APPEARS IN THE WORLD
โ†“
BOT HAS THE OWNER AS ITS ONLY TARGET
โ†“
BOT MOVES TOWARD OWNER
โ†“
BOT CAN FIGHT OWNER
โ†“
BOT TAKES DAMAGE
โ†“
BOT USES ITS COMBAT AI
โ†“
BOT CAN DIE
โ†“
BOT IS CLEANLY REMOVED

A GUI that works while the bot does not work is FAILURE.

==================================================

1. REAL PLAYER-LIKE BOT
   ==================================================

Implement a genuine player-like PvP bot using the strongest technically reliable architecture available for Paper 26.2.

DO NOT make a fake bot using:

- ArmorStand
- Zombie
- Skeleton
- Villager
- arbitrary mob
- decorative NPC
- renamed entity

Do not create a mob and pretend it is a player.

If Paper's public API is insufficient, use the appropriate compatible NMS/internal implementation.

Keep version-specific code isolated.

Suggested architecture:

Bot
BotManager
BotEntity
BotAI
BotState
BotTargetController
BotMovementController
BotCombatController
BotEquipmentController
BotNavigationController
BotDifficulty
BotCombatMode

==================================================
2. BOT OWNERSHIP

Every bot belongs to exactly ONE player.

Example:

Player A โ†’ Bot A
Player B โ†’ Bot B

Bot A:
Owner = Player A
Target = Player A ONLY

Bot B:
Owner = Player B
Target = Player B ONLY

The owner is automatically assigned when the bot is spawned.

Do not allow Bot A to randomly attack Player B.

Do not use one global target for all bots.

Use UUID-based ownership internally.

==================================================
3. TARGET GUI FIX

The current target GUI is wrong.

Players DO NOT need to select another player.

The target menu must NOT show a list of online players.

Instead show only:

Target
Yourself


or:

Target: You

The bot automatically targets the player who spawned it.

For example:

PlayerA opens Target GUI
โ†’ Target: PlayerA

PlayerB opens Target GUI
โ†’ Target: PlayerB

PlayerA's bot never changes to PlayerB.

==================================================
4. MULTIPLE PLAYERS / MULTIPLE BOTS

The plugin is global.

Each player can have their own independent bot, subject to configurable limits.

Example:

PlayerA โ†’ BotA โ†’ targets PlayerA
PlayerB โ†’ BotB โ†’ targets PlayerB
PlayerC โ†’ BotC โ†’ targets PlayerC

All bots must maintain independent:

- owner
- target
- AI state
- difficulty
- combat mode
- equipment
- cooldowns
- movement
- navigation
- combat decisions

Do not use static/global target variables that cause bots to interfere with one another.

==================================================
5. BOT MANAGER

Create a proper BotManager.

Required functionality:

spawnBot(Player owner)
removeBot(Player owner)
removeBot(Bot bot)
getBot(Player owner)
getAllBots()
hasBot(Player owner)
isBotEntity(Entity entity)

Handle:

- player disconnect
- player death
- bot death
- plugin disable
- world unload
- bot removal
- invalid entity references

No orphaned bots.
No memory leaks.

==================================================
6. ACTUAL SPAWN PIPELINE

When Spawn Bot is clicked:

1. Identify player.
2. Validate permission.
3. Check bot limit.
4. Check whether player already owns a bot.
5. Create bot instance.
6. Create actual bot entity.
7. Spawn entity.
8. Register entity in BotManager.
9. Assign owner UUID.
10. Assign owner as target.
11. Apply selected combat mode.
12. Apply selected difficulty.
13. Apply equipment.
14. Initialize AI.
15. Start AI scheduler.
16. Send success message.

If ANY stage fails:

- remove partial entity
- unregister bot
- cancel AI
- log complete exception
- tell player spawning failed

NEVER silently do nothing.

==================================================
7. DEBUGGING

Add configurable debug mode.

When enabled, log:

[Shadowthebot] Creating bot for PlayerName
[Shadowthebot] Entity created
[Shadowthebot] Owner assigned
[Shadowthebot] Target assigned
[Shadowthebot] Equipment applied
[Shadowthebot] AI started

Also log exceptions with full stack traces.

The old plugin silently failed. This MUST NOT happen again.

==================================================
8. AI ENGINE

Create a real continuously running AI engine.

The bot must:

- track its owner
- look at owner
- move toward owner
- maintain combat distance
- attack when appropriate
- react to damage
- reposition
- strafe
- chase
- retreat
- jump when appropriate
- navigate basic obstacles

Do NOT constantly teleport the bot.

Movement should resemble a Minecraft player.

==================================================
9. TARGET TRACKING

Continuously track the owner.

Read relevant state such as:

- position
- distance
- health
- movement
- vertical position
- line of sight
- airborne state
- equipment where technically available

If owner moves:
โ†’ bot follows.

If owner enters combat range:
โ†’ bot fights.

If owner moves behind an obstacle:
โ†’ bot attempts navigation.

==================================================
10. COMBAT ENGINE

Implement a reusable CombatController.

It must support:

- attack range
- attack cooldown
- rotation toward target
- legitimate attacks
- weapon selection
- weapon switching
- defensive reactions
- combat positioning

Do not use:

- infinite attack speed
- impossible reach
- instant kills
- teleport attacks
- fake damage

==================================================
11. DIFFICULTIES

Support:

EASY
MEDIUM
HARD
EXTREME

Difficulty must affect AI decisions, not merely damage.

EASY:

- slower reactions
- basic movement
- simple attacks

MEDIUM:

- better tracking
- basic strafing
- weapon selection

HARD:

- faster reactions
- improved positioning
- better defensive behavior

EXTREME:

- advanced reactions
- better movement
- prediction
- resource management
- tactical combat

No cheating-based difficulty.

==================================================
12. COMBAT MODES

Architecture must support:

Sword
Axe
Shield
Crystal
Anchor
Mace
Elytra Mace
Spear
Spear + Mace
Trident
Bow
Crossbow
Cobweb
UHC
Diamond SMP
SMP

Use separate strategy/controller classes where appropriate.

Examples:

SwordCombatAI
CrystalCombatAI
AnchorCombatAI
MaceCombatAI
SpearCombatAI
RangedCombatAI
ElytraCombatAI

Do not put all combat logic into one giant class.

==================================================
13. EQUIPMENT

Bots must receive real equipment.

Support:

- armor
- main hand
- offhand
- weapons
- shield
- food
- healing
- pearls
- blocks
- arrows
- potions
- mode-specific items

Equipment should be configurable where practical.

==================================================
14. ADVANCED AI

Support advanced behaviors where technically possible:

- healing
- eating
- shield reactions
- weapon switching
- pearl usage
- block placement
- mending
- inventory management
- regear
- shulker regear
- Ender Chest interaction
- mode-specific tactics

Do not fake unavailable functionality.

If a feature requires NMS/internal access, implement it properly or clearly isolate it as unsupported.

==================================================
15. DAMAGE / DEATH

The bot must participate in real combat.

It must:

- have real health
- receive damage
- react to damage
- die normally
- trigger cleanup
- unregister from BotManager
- remove its entity

No immortality.
No automatic health reset after every hit.

==================================================
16. PLAYER DISCONNECT

When owner disconnects:

- stop AI
- remove bot
- unregister bot
- release resources

No orphaned bots.

==================================================
17. PERFORMANCE

The system must support multiple simultaneous bots.

Avoid:

- expensive work every tick
- unnecessary entity scans
- excessive ray tracing
- expensive pathfinding every tick
- memory leaks
- unsafe asynchronous Bukkit API usage

Use controlled AI intervals.

==================================================
18. FULLY CONFIGURABLE GUI

NOW implement the GUI as a separate configurable system.

Create:

plugins/Shadowthebot/gui.yml

The GUI must NOT require Java recompilation for normal visual changes.

gui.yml should control as much as reasonably possible:

- GUI title
- size
- slots
- item materials
- item names
- item lore
- sounds
- enabled/disabled appearance
- button positions
- messages
- mode buttons
- difficulty buttons
- target display
- spawn button
- remove button
- back button
- navigation buttons

Example structure:

main:
title: "&8Shadowthebot"
size: 54

buttons:

spawn:
  slot: 22
  material: DIAMOND_SWORD
  name: "&aSpawn Bot"
  lore:
    - "&7Spawn your personal PvP bot."

remove:
  slot: 31
  material: BARRIER
  name: "&cRemove Bot"

target:
  slot: 20
  material: PLAYER_HEAD
  name: "&bTarget"
  lore:
    - "&7Target: &f{player}"

difficulty:
  slot: 24
  material: NETHER_STAR
  name: "&eDifficulty"
  lore:
    - "&7Current: &f{difficulty}"

mode:
  slot: 29
  material: DIAMOND_SWORD
  name: "&cCombat Mode"
  lore:
    - "&7Current: &f{mode}"

Do NOT assume this exact design must be used.
Make the GUI system flexible.

==================================================
19. GUI PLACEHOLDERS

Support placeholders such as:

{player}
{uuid}
{difficulty}
{mode}
{target}
{bot_status}
{bot_health}
{bot_name}

Example:

"&7Target: &f{target}"
"&7Difficulty: &f{difficulty}"
"&7Mode: &f{mode}"

==================================================
20. GUI CONFIG RELOAD

Implement:

/shadowthebot reload

or equivalent admin reload command.

Reload:

- gui.yml
- config.yml
- messages.yml if used

Do not require server restart for GUI changes.

If gui.yml is invalid:

- log the configuration error
- keep the previous valid configuration if possible
- do not crash the plugin

==================================================
21. GUI MUST CALL REAL ENGINE

The GUI must never contain fake functionality.

Spawn button:

โ†’ BotManager.spawnBot(player)

Remove button:

โ†’ BotManager.removeBot(player)

Target:

โ†’ automatically owner

Difficulty:

โ†’ update the owner's Bot configuration

Combat mode:

โ†’ update the owner's Bot configuration

The GUI is only a control panel for the actual engine.

==================================================
22. CONFIG FILES

Recommended files:

config.yml
gui.yml
messages.yml

Keep responsibilities separated.

config.yml:

- bot limits
- permissions
- AI intervals
- debug
- default difficulty
- default combat mode
- cleanup behavior

gui.yml:

- GUI design
- slots
- materials
- names
- lore
- sounds

messages.yml:

- spawn success
- spawn failure
- bot removed
- already spawned
- limit reached
- permission errors
- debug/admin messages

==================================================
23. COMMANDS

Preserve:

/shadowthebot
/stb
/shadowbot
/bot

Provide useful subcommands where appropriate:

/stb spawn
/stb remove
/stb status
/stb reload
/stb debug

Do not break existing commands.

==================================================
24. PERMISSIONS

Use configurable permissions such as:

shadowthebot.use
shadowthebot.spawn
shadowthebot.admin
shadowthebot.reload
shadowthebot.debug

Allow configurable bot limits.

==================================================
25. TEST PROCEDURE

Before declaring completion, test:

TEST 1:
PlayerA joins.

TEST 2:
PlayerA opens GUI.

TEST 3:
Target menu shows ONLY PlayerA/You.

TEST 4:
PlayerA clicks Spawn Bot.

TEST 5:
REAL bot appears.

TEST 6:
Bot follows PlayerA.

TEST 7:
PlayerA enters attack range.

TEST 8:
Bot attacks PlayerA.

TEST 9:
PlayerA attacks bot.

TEST 10:
Bot takes damage and reacts.

TEST 11:
Bot dies.

TEST 12:
Bot is removed from BotManager.

TEST 13:
PlayerA spawns another bot.

TEST 14:
PlayerB joins and spawns a bot.

TEST 15:
PlayerB's bot targets PlayerB.

TEST 16:
PlayerA's bot continues targeting PlayerA.

TEST 17:
Changing GUI text/material/slot in gui.yml works after reload.

TEST 18:
Changing difficulty/mode through GUI actually changes the bot's AI configuration.

==================================================
26. JAVAC BUILD

Provide the complete project source.

Include:

src/
plugin.yml
config.yml
gui.yml
messages.yml
all Java classes

Provide exact javac compilation instructions.

No Maven.
No Gradle.

==================================================
27. FINAL RULE

DO NOT declare the project finished because:

- GUI opens
- buttons exist
- configuration exists
- plugin loads

The plugin is finished ONLY when:

REAL BOT SPAWNING WORKS
+
REAL TARGETING WORKS
+
REAL MOVEMENT WORKS
+
REAL COMBAT WORKS
+
REAL DAMAGE/DEATH WORKS
+
MULTIPLE PLAYERS WORK INDEPENDENTLY
+
GUI CONTROLS THE REAL BOT ENGINE
+
GUI IS CONFIGURABLE THROUGH gui.yml

Prioritize functionality in this order:

1. Bot entity creation
2. Bot spawning
3. Owner/target assignment
4. Movement
5. Combat
6. Damage/death
7. Multi-player isolation
8. Advanced AI
9. Configurable GUI
10. Cosmetic improvements

If an existing class is preventing the bot engine from working, rewrite it.

Do not preserve broken architecture merely to avoid changing existing code.

Return the COMPLETE working source code, all configuration files, build commands, and a concise explanation of the final bot architecture.
Kodari AI
KodariSep 25 at 10:35 am 4
ShadowBotEngine
Creates real player-like PvP bots on Paper 26.2 using NMS-based entity creation. Each bot is owned by exactly one player, targets only its owner, and features a full AI engine with movement, navigation, combat strategies for 16 modes, difficulty tiers, equipment, damage/death handling, and multi-player isolation. Includes a configurable GUI system driven by gui.yml with reload support, plus BotManager for lifecycle management and cleanup.
  1. Verify Paper 26.2โ€™s real-player entity construction, world insertion, damage, and removal APIs.

  2. Build the bot engine and owner-isolated AI against those signatures.

  3. Add the configurable GUI, commands, permissions, and default configuration.

  4. Include javac instructions and be explicit about any limits that cannot be honestly guaranteed without a server test.

Created the plugin source and configuration under src/, plus javac-only build instructions in README.md.

The bot is an NMS ServerPlayer with a per-owner target, entity tracking, server-ticked movement, melee attacks, and real arrow projectiles for bow/crossbow modes. The GUI and messages are configurable and reloadable; difficulty and mode changes apply to an active bot.

This is not a fully verified implementation of every requested feature. Crystal, anchor, shield reactions, elytra flight, and other advanced tactics are not implemented; several modes currently provide equipment rather than their named combat strategy. Synthetic players also bypass normal PlayerList login bookkeeping, so the NMS integration needs in-server validation. I did not run javac or a Paper server test.

King

The compilation failed with this error:

code
Compilation failed with 2 error(s):

ERROR in src/main/java/shadow/shadowthebot/bot/BotManager.java at line 29: cannot find symbol
import org.bukkit.entity.EntityDeathEvent;
                        ^
  symbol: class EntityDeathEvent
  location: package org.bukkit.entity

ERROR in src/main/java/shadow/shadowthebot/bot/BotManager.java at line 208: cannot find symbol
    public void onBotDeath(EntityDeathEvent event) {
                           ^
  symbol: class EntityDeathEvent
  location: class BotManager


=== COMPILATION ERROR ANALYSIS ===

MISSING CLASSES:
  - EntityDeathEvent
ACTION: Create these classes or check imports

FILES TO INVESTIGATE:
  - src/main/java/shadow/shadowthebot/bot/BotManager.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariSep 25 at 10:36 am 1
  1. Correct EntityDeathEvent to the Bukkit event package.

  2. Keep the existing handler logic unchanged.

  3. Apply the focused import fix.

Fixed the compilation error in BotManager.java by importing EntityDeathEvent from org.bukkit.event.entity. The death handler is unchanged.

King

The compilation failed with this error:

code
Compilation failed with 5 error(s):

ERROR in src/main/java/shadow/shadowthebot/command/ShadowCommand.java at line 61: cannot find symbol
            plugin.sendMessage(player, "spawn-success", Map.of("bot_name", bot.entity().getGameProfile().getName()));
                                                                                                        ^
  symbol: method getName()
  location: class GameProfile

ERROR in src/main/java/shadow/shadowthebot/command/ShadowCommand.java at line 86: cannot find symbol
                "bot_name", bot.entity().getGameProfile().getName(),
                                                         ^
  symbol: method getName()
  location: class GameProfile

ERROR in src/main/java/shadow/shadowthebot/bot/BotManager.java at line 148: cannot find symbol
            plugin.severe("Failed to remove bot " + bot.entity().getGameProfile().getName(), throwable);
                                                                                 ^
  symbol: method getName()
  location: class GameProfile

ERROR in src/main/java/shadow/shadowthebot/gui/GuiManager.java at line 107: cannot find symbol
                plugin.sendMessage(player, "spawn-success", Map.of("bot_name", bot.entity().getGameProfile().getName()));
                                                                                                            ^
  symbol: method getName()
  location: class GameProfile

ERROR in src/main/java/shadow/shadowthebot/gui/GuiManager.java at line 209: cannot find symbol
                "bot_name", bot == null ? "-" : bot.entity().getGameProfile().getName());
                                                                             ^
  symbol: method getName()
  location: class GameProfile


=== COMPILATION ERROR ANALYSIS ===

MISSING METHODS:
  - getName()
ACTION: Check method names and signatures

FILES TO INVESTIGATE:
  - src/main/java/shadow/shadowthebot/command/ShadowCommand.java
  - src/main/java/shadow/shadowthebot/bot/BotManager.java
  - src/main/java/shadow/shadowthebot/gui/GuiManager.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariSep 25 at 10:41 am 1
  1. Verify the GameProfile name accessor in Paper 26.2.

  2. Read the affected call sites and replace the invalid accessor consistently.

Replaced all five invalid GameProfile.getName() calls with the Paper 26.2 accessor name() in ShadowCommand, BotManager, and GuiManager.

Kodari can make mistakes. Review important code before using.
Files
src
README.md
Code
14 1,340
src/main/java/shadow/shadowthebot/ShadowthebotPlugin.java
package shadow.shadowthebot;

import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.logging.Level;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import shadow.shadowthebot.bot.BotManager;
import shadow.shadowthebot.command.ShadowCommand;
import shadow.shadowthebot.gui.GuiManager;

public final class ShadowthebotPlugin extends JavaPlugin {
    private YamlConfiguration guiConfig;
    private YamlConfiguration messagesConfig;
    private BotManager botManager;
    private GuiManager guiManager;
    private boolean debugEnabled;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        saveResourceIfMissing("gui.yml");
        saveResourceIfMissing("messages.yml");
        loadExternalConfigurations();
        debugEnabled = getConfig().getBoolean("debug", false);

        botManager = new BotManager(this);
        guiManager = new GuiManager(this, botManager);
        getServer().getPluginManager().registerEvents(botManager, this);
        getServer().getPluginManager().registerEvents(guiManager, this);
        botManager.start();

        ShadowCommand command = new ShadowCommand(this, botManager, guiManager);
        getCommand("shadowthebot").setExecutor(command);
        getCommand("shadowthebot").setTabCompleter(command);
        debug("Plugin enabled.");
    }

    @Override
    public void onDisable() {
        if (botManager != null) {
            botManager.shutdown();
        }
    }

    public void reloadPluginConfigurations() {
        reloadConfig();
        loadExternalConfigurations();
        debugEnabled = getConfig().getBoolean("debug", false);
    }

    private void saveResourceIfMissing(String name) {
        File file = new File(getDataFolder(), name);
        if (!file.exists()) {
            saveResource(name, false);
        }
    }

    private void loadExternalConfigurations() {
        guiConfig = loadYaml("gui.yml", guiConfig);
        messagesConfig = loadYaml("messages.yml", messagesConfig);
    }

    private YamlConfiguration loadYaml(String name, YamlConfiguration previous) {
        File file = new File(getDataFolder(), name);
        YamlConfiguration candidate = new YamlConfiguration();
        try {
            candidate.load(file);
            return candidate;
        } catch (IOException | InvalidConfigurationException exception) {
            getLogger().log(Level.SEVERE, "Could not load " + name + "; retaining the previous valid configuration.", exception);
            return previous == null ? new YamlConfiguration() : previous;
        }
    }

    public YamlConfiguration guiConfig() {
        return guiConfig;
    }

    public BotManager botManager() {
        return botManager;
    }

    public boolean isDebugEnabled() {
        return debugEnabled;
    }

    public void setDebugEnabled(boolean debugEnabled) {
        this.debugEnabled = debugEnabled;
    }

    public String permission(String key) {
        return getConfig().getString("permissions." + key, "shadowthebot." + key);
    }

    public boolean hasPermission(CommandSender sender, String key) {
        return sender.hasPermission(permission(key));
    }

    public String message(String key, Map<String, String> placeholders) {
        String text = messagesConfig == null
                ? key
                : messagesConfig.getString(key, key);
        for (Map.Entry<String, String> entry : placeholders.entrySet()) {
            text = text.replace("{" + entry.getKey() + "}", entry.getValue());
        }
        return ChatColor.translateAlternateColorCodes('&', text);
    }

    public void sendMessage(CommandSender sender, String key) {
        sendMessage(sender, key, Map.of());
    }

    public void sendMessage(CommandSender sender, String key, Map<String, String> placeholders) {
        sender.sendMessage(message(key, placeholders));
    }

    public void debug(String message) {
        if (debugEnabled) {
            getLogger().info("[Shadowthebot] " + message);
        }
    }

    public void severe(String message, Throwable throwable) {
        getLogger().log(Level.SEVERE, "[Shadowthebot] " + message, throwable);
    }
}