bipnix_fr

NaitikCitizenPlugin — Complete Master Coding Prompt

You are an expert Minecraft Java server-plugin developer specializing in NMS, packet systems, fake players, NPC frameworks, entity tracking, and modern Minecraft server architecture.

Build a production-ready Minecraft plugin named "NaitikCitizenPlugin".

The goal is to create an original Citizens-style NPC framework using genuine player-type fake NPCs.

Do not copy Citizens source code or proprietary implementation.

---

  1. CRITICAL NPC REQUIREMENT

The NPC MUST appear as a real Minecraft player/fake player.

NEVER use:

  • Armor Stands
  • Zombies
  • Skeletons
  • Villagers
  • Player heads attached to Armor Stands
  • Invisible mobs
  • Any mob-based replacement

The NPC must be implemented using the correct player entity / ServerPlayer / NMS / packet-based approach for the exact Minecraft server version used by this project.

When a normal player sees the NPC, it should visually appear as another Minecraft player.

It must support:

  • Player model
  • Player skin
  • Player name
  • Player UUID/profile
  • Head
  • Body
  • Arms
  • Legs
  • Player rotation
  • Player movement
  • Player animations
  • Armor
  • Main-hand item
  • Off-hand item
  • Sneaking
  • Swing animation
  • Damage animation

---

  1. IMPORTANT FAKE-PLAYER CONNECTION RULE

A fake player does NOT have a real client connection.

Therefore, NEVER assume that the fake player has a valid:

"ServerGamePacketListenerImpl"

or:

"playerConnection"

The previous implementation produced:

"java.lang.NullPointerException: Cannot invoke "net.minecraft.server.network.ServerGamePacketListenerImpl.latency()" because "playerConnection" is null"

This MUST be completely fixed.

Never directly call connection-dependent methods on the fake NPC such as:

"playerConnection.latency()"

"playerConnection.send(...)"

or any equivalent connection API.

The fake NPC must not require a real network connection.

When packets need to be sent, send them through the real online players' connections, not through the fake NPC's nonexistent client connection.

Do not hide the problem with random null checks.

Redesign the affected code path correctly.

---

  1. VERSION-SPECIFIC NMS

First determine the exact Minecraft server version used by the project.

Use only the correct NMS/API classes for that version.

Do NOT copy NMS code from another Minecraft version.

If Mojang mappings, Paper mappings, Spigot mappings, or another mapping system is being used, follow the project's existing mapping system consistently.

Do not mix incompatible mappings.

Keep version-dependent code isolated where possible.

---

  1. NPC CREATION

Implement:

"/npc create <name>"

Creating an NPC should:

  1. Validate the NPC name.
  2. Generate/create the appropriate game profile.
  3. Create the correct player-type NPC entity.
  4. Place it at the administrator's current location.
  5. Spawn it for nearby/online players using the appropriate packets/entity-tracking system.
  6. Register it with the NPC manager.
  7. Save its data.
  8. Apply its default configuration.
  9. Ensure it does not require a real client connection.

The NPC must spawn without throwing a NullPointerException.

---

  1. NPC COMMAND SYSTEM

Implement a professional command system:

"/npc create <name>"

"/npc remove <name>"

"/npc removeall"

"/npc list"

"/npc select <name>"

"/npc deselect"

"/npc rename <name>"

"/npc skin <skin>"

"/npc teleport"

"/npc move <x> <y> <z>"

"/npc look"

"/npc lookat <player>"

"/npc follow <player>"

"/npc speed <value>"

"/npc equip"

"/npc behavior <type>"

"/npc action"

"/npc reload"

Provide complete tab completion.

Use proper permission nodes.

Give clear error messages for invalid commands, missing NPCs, invalid players, and invalid arguments.

---

  1. NPC SELECTION

Implement a proper selection system.

Example:

"/npc select TestNPC"

After selecting an NPC, commands should be able to operate on the selected NPC without requiring its name every time.

Support:

"/npc deselect"

Show the administrator which NPC is currently selected.

Selections must be stored per administrator and cleaned up safely when necessary.

---

  1. PLAYER SKINS

Support real Minecraft player skins.

Allow:

"/npc skin <skin>"

The implementation should support appropriate player skin texture/profile properties for the target server version.

Skin changes should update the NPC for currently connected players without requiring a server restart.

If a skin cannot be loaded, handle the failure gracefully and do not crash the server.

---

  1. PLAYER APPEARANCE

NPCs must support:

  • Custom name
  • Skin
  • Player model
  • Head rotation
  • Body rotation
  • Sneaking
  • Equipment
  • Armor
  • Main-hand item
  • Off-hand item
  • Player animations
  • Swing animation
  • Damage animation
  • Basic player poses

Do not simulate these using Armor Stands.

---

  1. EQUIPMENT

NPCs must support normal player equipment:

  • Helmet
  • Chestplate
  • Leggings
  • Boots
  • Main-hand
  • Off-hand

Equipment should visually appear correctly to real players.

Provide commands or configuration to modify equipment.

---

  1. MOVEMENT

Implement player-style NPC movement.

Support:

  • Walking
  • Running
  • Jumping
  • Looking around
  • Looking at players
  • Moving to coordinates
  • Following players
  • Returning to a location
  • Configurable movement speed
  • Idle movement
  • Wander behavior

The NPC must NOT have an artificial speed reduction.

If the administrator sets a normal player movement speed, the NPC should move at normal player speed.

Do not add unnecessary delays or tick throttling that makes NPC movement visibly slower than real players.

---

  1. NPC AI / BEHAVIOR

Implement a modular behavior system.

Support:

  • Stationary
  • Idle
  • Wander
  • Follow
  • Look-at-player
  • Move-to-location
  • Return-to-location

The architecture should allow additional behaviors to be added later without rewriting the entire plugin.

AI calculations must be optimized.

Do not perform expensive pathfinding unnecessarily every tick.

---

  1. NPC INTERACTION

Allow real players to interact with NPCs.

Support:

  • Right-click
  • Left-click
  • Interaction actions
  • Messages
  • Sounds
  • Effects
  • Commands
  • Server commands
  • Multiple actions

Example:

"/npc action add <action>"

"/npc action remove <action>"

"/npc action list"

Actions should be stored with the NPC.

---

  1. NPC PERSISTENCE

NPCs must survive server restarts.

Save:

  • NPC name
  • UUID/internal identifier
  • World
  • X/Y/Z
  • Rotation
  • Skin/profile data
  • Equipment
  • Movement speed
  • Behavior
  • Actions
  • Appearance settings

When the server starts:

  1. Load saved NPC data.
  2. Validate the data.
  3. Recreate the player-type NPC.
  4. Spawn it correctly.
  5. Restore its skin.
  6. Restore equipment.
  7. Restore behavior.
  8. Restore actions.

Do not create duplicate NPCs during reload/restart.

---

  1. PACKET SYSTEM

Implement a clean packet abstraction.

The fake NPC should be visible to real players through the appropriate player/entity packets.

Handle:

  • Player-info/tab-list related packets where required
  • Entity spawn packets
  • Entity movement packets
  • Rotation packets
  • Equipment packets
  • Metadata packets
  • Animation packets
  • Remove/despawn packets

Do not use the fake NPC's nonexistent connection to send packets.

Always distinguish between:

Fake NPC → no real network connection

and

Real player → valid network connection

---

  1. ENTITY TRACKING

Implement correct tracking for fake NPCs.

When a player enters the appropriate viewing range:

  • Show the NPC.

When a player leaves the viewing range:

  • Stop unnecessary updates where appropriate.

When an NPC is removed:

  • Remove it from all relevant tracking structures.
  • Send appropriate destroy/removal packets.
  • Cancel its tasks.
  • Clear references.

Avoid memory leaks.

---

  1. PERFORMANCE

The plugin must be suitable for production SMP servers.

Avoid:

  • Unnecessary per-tick loops
  • Expensive calculations every tick
  • Repeated skin downloads
  • Unnecessary packet spam
  • Unbounded collections
  • Memory leaks
  • Orphaned scheduled tasks

Use efficient scheduling, caching, tracking, and pathfinding.

Multiple NPCs should be supported without causing unnecessary server lag.

Do not sacrifice movement quality just to hide performance problems.

---

  1. PROFESSIONAL ARCHITECTURE

Use a modular architecture such as:

  • "NaitikCitizenPlugin"
  • "NPCManager"
  • "NPC"
  • "FakePlayerController"
  • "NPCRegistry"
  • "NPCSelectionManager"
  • "SkinManager"
  • "EquipmentManager"
  • "MovementManager"
  • "BehaviorManager"
  • "InteractionManager"
  • "PacketManager"
  • "NPCDataManager"
  • "CommandManager"
  • Event listeners
  • Configuration manager
  • Version-specific/NMS implementation layer

Do not put everything inside one class.

Keep version-specific NMS code isolated.

---

  1. ERROR HANDLING

The plugin must never crash the server because of:

  • Missing NPC
  • Invalid NPC name
  • Invalid player
  • Invalid location
  • Invalid world
  • Missing skin
  • Invalid configuration
  • Failed packet operation
  • NPC removal
  • World unload
  • Server reload
  • Fake-player connection being null

Handle all errors safely and provide useful administrator messages.

---

  1. NULL-SAFETY REQUIREMENT

Search the ENTIRE project for:

"playerConnection"

"ServerGamePacketListenerImpl"

"latency()"

"connection"

and every other connection-dependent API.

For every occurrence, determine whether the object is a real online player or a fake NPC.

A fake NPC must NEVER call a method that requires a real client connection.

Do not simply suppress the exception.

Fix the underlying architecture.

---

  1. CONFIGURATION

Create a professional "config.yml".

Include configurable options for:

  • Default NPC speed
  • NPC viewing distance
  • Default behavior
  • Skin settings
  • Interaction settings
  • Persistence
  • Packet settings where appropriate
  • Performance settings
  • Debug logging

Do not hard-code settings that administrators reasonably need to change.

---

  1. BUILD REQUIREMENTS

Provide a complete buildable project.

Include:

  • Main plugin class
  • All Java source files
  • "plugin.yml"
  • "config.yml"
  • Build configuration
  • Commands
  • Permissions
  • Listeners
  • NPC storage
  • NMS/version-specific implementation
  • README

There must be no:

  • TODO
  • Placeholder implementation
  • Fake implementation
  • Missing class
  • Broken import
  • Unregistered command
  • Unregistered listener
  • Armor Stand fallback

---

  1. FINAL TESTING

Before declaring the project complete, actually verify:

  1. Project compiles.
  2. "/npc create TestNPC" works.
  3. No "playerConnection" NullPointerException occurs.
  4. NPC is a player-type fake NPC.
  5. NPC is NOT an Armor Stand.
  6. NPC is NOT a mob.
  7. NPC appears as a player model.
  8. NPC skin works.
  9. NPC name works.
  10. NPC can move.
  11. NPC movement speed is not artificially reduced.
  12. NPC can rotate.
  13. NPC can look at players.
  14. NPC can follow players.
  15. NPC can jump.
  16. Armor works.
  17. Held items work.
  18. Player animations work.
  19. NPC interactions work.
  20. Multiple NPCs work.
  21. NPCs save correctly.
  22. NPCs restore after restart.
  23. NPC removal works.
  24. "/npc removeall" works.
  25. Tasks are properly cancelled.
  26. No memory leaks are introduced.
  27. No unnecessary console errors occur.
  28. No fake-player connection is accessed.
  29. No Armor Stand fallback exists anywhere in the code.
  30. The final plugin is production-ready.

FINAL NON-NEGOTIABLE RULE

The most important requirement is:

NaitikCitizenPlugin must create genuine player-style fake NPCs, not Armor Stands or mobs.

If the current API does not directly support fake player entities, use the correct NMS/packet-based implementation for the exact Minecraft version.

Never replace the NPC with an Armor Stand just because implementing a fake player is difficult.

Fix all NMS/API compatibility issues before finishing the project.

Kodari AI
KodariAug 16 at 5:00 am 3
NaitikCitizenPlugin
A production-ready Minecraft plugin creating genuine player-type fake NPCs using NMS/packet-based implementation. Features include NPC creation, removal, selection, renaming, skin management, teleportation, movement, equipment, behaviors, and interactions. Implements modular architecture with NPCManager, SkinManager, MovementManager, BehaviorManager, and PacketManager. Supports persistence across restarts, player tracking, animations, armor, held items, and configurable settings. Ensures null-safe operations without requiring fake player connections, preventing NPEs. Includes comprehensive command system with tab completion, permission nodes, and error handling. Optimized for performance with efficient scheduling and caching. No Armor Stand fallbacks, only authentic player entity NPCs.
  1. Build a Java 17 Paper 1.20.4 plugin with reflection-isolated NMS fake-player packets.

  2. Add NPC data, persistence, skin loading, equipment, behaviors, interactions, tracking, and cleanup.

  3. Register the /npc command suite, tab completion, listeners, configuration, permissions, and README.

Created the initial NaitikCitizenPlugin project with:

  • Paper 1.20.4 / Java 17 Gradle setup

  • Player-type NMS ServerPlayer NPC architecture

  • Packet delivery exclusively through real online players

  • NPC creation, removal, selection, persistence, skins, equipment, movement, behaviors, and interactions

  • /npc command suite with tab completion and permissions

  • Configuration, plugin metadata, and README

  • No armor stands or mob-based NPC fallbacks

  • Fake NPCs never use connection-dependent APIs such as latency() or fake-player packet connections

The project files are now in place.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
README.md
settings.gradle
Code
19 1,015
src/main/java/com/naitik/naitikcitizenplugin/NaitikCitizenPlugin.java
package com.naitik.naitikcitizenplugin;

import com.naitik.naitikcitizenplugin.behavior.BehaviorManager;
import com.naitik.naitikcitizenplugin.command.NPCCommand;
import com.naitik.naitikcitizenplugin.data.NPCDataManager;
import com.naitik.naitikcitizenplugin.interaction.InteractionManager;
import com.naitik.naitikcitizenplugin.npc.NPCManager;
import com.naitik.naitikcitizenplugin.npc.NPCSelectionManager;
import com.naitik.naitikcitizenplugin.packet.PacketManager;
import com.naitik.naitikcitizenplugin.skin.SkinManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class NaitikCitizenPlugin extends JavaPlugin {
    private PacketManager packetManager;
    private NPCDataManager dataManager;
    private NPCSelectionManager selectionManager;
    private SkinManager skinManager;
    private InteractionManager interactionManager;
    private NPCManager npcManager;
    private BehaviorManager behaviorManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        packetManager = new PacketManager(this);
        dataManager = new NPCDataManager(this);
        selectionManager = new NPCSelectionManager();
        skinManager = new SkinManager(this);
        interactionManager = new InteractionManager(this);
        npcManager = new NPCManager(this);
        behaviorManager = new BehaviorManager(this);

        npcManager.load(dataManager.load());
        Bukkit.getPluginManager().registerEvents(interactionManager, this);
        NPCCommand command = new NPCCommand(this);
        getCommand("npc").setExecutor(command);
        getCommand("npc").setTabCompleter(command);
        npcManager.startTracking();
        behaviorManager.start();
    }

    @Override
    public void onDisable() {
        if (behaviorManager != null) behaviorManager.stop();
        if (npcManager != null) {
            if (getConfig().getBoolean("persistence.enabled", true)) npcManager.save();
            npcManager.shutdown();
        }
    }

    public PacketManager getPacketManager() { return packetManager; }
    public NPCDataManager getDataManager() { return dataManager; }
    public NPCSelectionManager getSelectionManager() { return selectionManager; }
    public SkinManager getSkinManager() { return skinManager; }
    public InteractionManager getInteractionManager() { return interactionManager; }
    public NPCManager getNpcManager() { return npcManager; }
    public BehaviorManager getBehaviorManager() { return behaviorManager; }
}