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.
---
- 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
---
- 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.
---
- 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.
---
- NPC CREATION
Implement:
"/npc create <name>"
Creating an NPC should:
- Validate the NPC name.
- Generate/create the appropriate game profile.
- Create the correct player-type NPC entity.
- Place it at the administrator's current location.
- Spawn it for nearby/online players using the appropriate packets/entity-tracking system.
- Register it with the NPC manager.
- Save its data.
- Apply its default configuration.
- Ensure it does not require a real client connection.
The NPC must spawn without throwing a NullPointerException.
---
- 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.
---
- 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.
---
- 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.
---
- 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.
---
- 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.
---
- 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.
---
- 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.
---
- 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.
---
- 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:
- Load saved NPC data.
- Validate the data.
- Recreate the player-type NPC.
- Spawn it correctly.
- Restore its skin.
- Restore equipment.
- Restore behavior.
- Restore actions.
Do not create duplicate NPCs during reload/restart.
---
- 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
---
- ENTITY TRACKING
Implement correct tracking for fake NPCs.
When a player enters the appropriate viewing range:
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.
---
- 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.
---
- 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.
---
- 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.
---
- 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.
---
- 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.
---
- 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
---
- FINAL TESTING
Before declaring the project complete, actually verify:
- Project compiles.
- "/npc create TestNPC" works.
- No "playerConnection" NullPointerException occurs.
- NPC is a player-type fake NPC.
- NPC is NOT an Armor Stand.
- NPC is NOT a mob.
- NPC appears as a player model.
- NPC skin works.
- NPC name works.
- NPC can move.
- NPC movement speed is not artificially reduced.
- NPC can rotate.
- NPC can look at players.
- NPC can follow players.
- NPC can jump.
- Armor works.
- Held items work.
- Player animations work.
- NPC interactions work.
- Multiple NPCs work.
- NPCs save correctly.
- NPCs restore after restart.
- NPC removal works.
- "/npc removeall" works.
- Tasks are properly cancelled.
- No memory leaks are introduced.
- No unnecessary console errors occur.
- No fake-player connection is accessed.
- No Armor Stand fallback exists anywhere in the code.
- 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.