فلتقوم ببرمجة بلوجن
📄
pasted-code-1791380739479.txt
txt
3508 lines
▶
# BotControl + FakePlayerEngine
## Compact Technical Design & Implementation Specification
**Target Platform:** Paper 1.21.11
**Primary Scripting Layer:** Skript
**Engine Layer:** Java FakePlayerEngine
**Packet Layer:** PacketEvents preferred, ProtocolLib-compatible adapter optional
**Purpose:** Add reliable fake-player creation and management to BotControl without requiring real Minecraft accounts.
---
# 1. CORE REQUIREMENT
BotControl must support simulated Minecraft players called **Bots**.
A Bot must be capable of appearing to players as a normal Minecraft player:
- Player model
- Player skin
- Username
- UUID
- Head rotation
- Body rotation
- Walking
- Sprinting
- Sneaking
- Jumping
- Equipment
- Arm animations
- Damage animation
- Teleportation
- Visibility control
- Optional tab-list presence
- Optional interaction/combat handling
The implementation must NOT pretend that Skript alone can create a native Bukkit `Player`.
A real connected Minecraft `Player` requires a network connection and authenticated login. Therefore:
**BotControl = management/logic layer.**
**FakePlayerEngine = Java-side fake-player implementation layer.**
BotControl communicates with FakePlayerEngine through a stable API/bridge.
---
# 2. ARCHITECTURE
```text
BotControl
│
├── Bot Registry
├── Bot Profiles
├── Bot Groups
├── Bot AI
├── Movement
├── Routes
├── Areas
├── Selection
├── Equipment
├── Persistence
├── Scheduler
└── Skript API
│
▼
FakePlayerEngine
│
├── Profile Manager
├── UUID Manager
├── Skin Manager
├── Fake Player Lifecycle
├── Entity Manager
├── Packet Adapter
├── Viewer Manager
├── Movement Renderer
├── Rotation Renderer
├── Equipment Renderer
├── Animation Manager
├── Interaction Bridge
├── Physics Bridge
├── Tab Manager
└── Recovery/Diagnostics
│
▼
Paper 1.21.11
│
▼
Minecraft Clients
```
---
# 3. FAKE PLAYER MODES
FakePlayerEngine must support three modes.
## 3.1 VISUAL_FAKE_PLAYER
Packet-based player representation.
Capabilities:
- Player appearance
- Skin
- Name
- Movement
- Rotation
- Equipment
- Animations
- Per-player visibility
Limitations:
- Not a native Bukkit Player
- No native Bukkit inventory
- No native permissions
- No normal server-side collision
- Normal combat plugins may not recognize it automatically
Use when the Bot is primarily visual.
---
## 3.2 HYBRID_FAKE_PLAYER
Recommended default.
The bot has:
1. A packet-rendered player representation.
2. A server-side logical/proxy representation for interaction, collision, targeting, and physics where required.
BotControl owns the logical state while FakePlayerEngine synchronizes the visible player.
Use this mode for:
- Combat
- Hit detection
- Collision
- NPC-like interaction
- AI
- Guard bots
- Enemy bots
- Training bots
---
## 3.3 SERVER_PROXY_PLAYER
Optional advanced mode.
A server-side proxy entity handles physics and interactions while FakePlayerEngine provides the player visual representation.
This mode exists because packet-only fake players cannot automatically participate in every Bukkit/Paper mechanic.
---
# 4. IMPORTANT AUTHENTICATION RULE
A fake player is NOT a real authenticated Minecraft account.
The engine must never:
- Log into a player's account.
- Bypass Minecraft authentication.
- Pretend to authenticate an account.
- Steal or request account credentials.
A bot may use a Minecraft-style username and skin profile, but this is only an identity/appearance representation.
---
# 5. BOT IDENTITY
Every bot requires:
```text
botId
uuid
username
displayName
profile
skin
world
location
state
```
Example:
```yaml
botId: bot_000001
uuid: generated-stable-uuid
username: TrainingBot
displayName: "&aTrainingBot"
```
UUIDs must remain stable across restarts.
Entity IDs are NOT persistent and must be regenerated when the bot is spawned.
---
# 6. USERNAME RULES
Validate usernames using Minecraft-compatible rules.
Requirements:
- Maximum 16 characters for actual player-style names.
- Reject illegal characters.
- Detect duplicate usernames.
- Detect duplicate UUIDs.
- Configurable collision policy:
```text
REJECT
SUFFIX
RANDOMIZE
AUTO_GENERATE
```
Example:
```text
TrainingBot
TrainingBot_1
TrainingBot_2
```
The internal `botId` remains unchanged.
---
# 7. PROFILE SYSTEM
Every bot has a profile.
```yaml
profile:
username: TrainingBot
uuid: ...
display-name: "&aTrainingBot"
skin:
source: MOJANG_PROFILE
username: ExamplePlayer
model: CLASSIC
```
Profile sources:
```text
MOJANG_PROFILE
DIRECT_TEXTURE
LOCAL_CACHE
SKIN_POOL
RANDOM_POOL
DEFAULT
```
The engine must cache profiles and skins.
Do not repeatedly request external profile information.
---
# 8. SKIN SYSTEM
FakePlayerEngine must support:
- Skin texture
- Skin signature
- Classic model
- Slim model
- Cached profiles
- Fallback skin
- Skin updates
- Skin reload
Example conceptual structure:
```yaml
skin:
source: MOJANG_PROFILE
username: ExamplePlayer
model: CLASSIC
cache: true
fallback: DEFAULT
```
If a skin cannot be loaded:
```text
Requested skin
↓
Cache
↓
External provider if allowed
↓
Fallback skin
```
The bot must still spawn if the skin fails.
---
# 9. FAKE PLAYER LIFECYCLE
## Creation
1. Validate bot ID.
2. Validate username.
3. Generate/load stable UUID.
4. Load profile.
5. Resolve skin.
6. Register bot.
7. Create engine instance.
## Spawn
1. Validate world.
2. Validate location.
3. Allocate entity ID.
4. Register active entity.
5. Synchronize profile with viewers.
6. Spawn player entity.
7. Apply metadata.
8. Apply skin.
9. Apply equipment.
10. Apply pose.
11. Apply rotation.
12. Start movement/AI updates.
## Despawn
1. Stop movement updates.
2. Stop AI tasks.
3. Remove from viewer tracking.
4. Send entity removal.
5. Remove tab entry if necessary.
6. Release entity ID.
7. Keep persistent bot data.
## Delete
Despawn first, then permanently remove the Bot from registry/persistence.
---
# 10. VIEWER SYNCHRONIZATION
Fake players are client-visible entities.
Each viewer must receive the correct packets.
When a viewer joins:
```text
Player joins
↓
Engine checks visible bots
↓
Profile synchronization
↓
Spawn packets
↓
Metadata
↓
Equipment
↓
Rotation
```
When a viewer changes world:
```text
Old-world bots → remove
New-world bots → spawn
```
When a bot changes world:
```text
Remove bot from old viewers
Move bot logically
Spawn bot for new eligible viewers
```
Viewer visibility must be independently controllable.
---
# 11. VIEW DISTANCE / LOD
The engine must support visibility ranges.
Example:
```yaml
viewer:
max-distance: 96
min-distance: 0
```
Optional LOD:
```text
0-32 blocks:
full updates
32-64:
reduced look/movement updates
64-96:
minimal updates
>96:
despawn from viewer
```
This prevents hundreds of bots from generating unnecessary packets.
---
# 12. PACKET ADAPTER
FakePlayerEngine must not hard-code itself to one packet library.
Use:
```text
FakePlayerEngine
│
└── PacketAdapter
├── PacketEventsAdapter
└── ProtocolLibAdapter
```
Preferred:
```text
PacketEvents
```
Only one packet adapter should be active.
The engine must expose:
```text
PACKETEVENTS
PROTOCOLLIB
AUTO
DISABLED
```
---
# 13. REQUIRED PLAYER PACKETS
The packet implementation must handle the equivalent of:
- Player profile/info synchronization
- Player entity spawn
- Entity metadata
- Equipment
- Relative movement
- Teleport
- Head rotation
- Body rotation
- Animation
- Entity removal
- Player-info removal
- Velocity where required
- Damage/hurt animation where required
Exact packet class names must be implemented against the actual Paper 1.21.11 / selected packet library API rather than copied from older Minecraft versions.
---
# 14. MOVEMENT ARCHITECTURE
BotControl owns logical movement.
FakePlayerEngine renders it.
```text
Bot AI
↓
Target Location
↓
Movement Controller
↓
FakePlayerEngine
↓
Client
```
Supported movement modes:
```text
NONE
DIRECT
WALK
FOLLOW
PATROL
ROUTE
RANDOM
CHASE
FLEE
GUARD
```
---
# 15. MOVEMENT UPDATE RATE
Do NOT update every bot every tick by default.
Recommended configurable rates:
```yaml
updates:
movement-hz: 10
rotation-hz: 5
ai-hz: 5
persistence-seconds: 30
```
The scheduler must batch updates.
---
# 16. ROTATION
Support:
- Yaw
- Pitch
- Head yaw
- Body yaw
The engine must synchronize head and body direction.
Bots may:
```text
look at player
look at target
look at location
look forward
random look
```
---
# 17. BASIC ANIMATIONS
Support:
```text
SWING_MAIN_HAND
SWING_OFF_HAND
HURT
SNEAK
UNSNEAK
SPRINT
UNSPRINT
CRITICAL
```
Animations are client-side visual states unless a server-side bridge is explicitly enabled.
---
# 18. POSES
Support appropriate player poses such as:
```text
STANDING
SNEAKING
SWIMMING
FALL_FLYING
SLEEPING
SPIN_ATTACK
```
Only use poses actually supported by the target protocol/version.
---
# 19. EQUIPMENT
Every bot supports:
```text
HEAD
CHEST
LEGS
FEET
MAIN_HAND
OFF_HAND
```
Example:
```yaml
equipment:
head: DIAMOND_HELMET
chest: DIAMOND_CHESTPLATE
legs: DIAMOND_LEGGINGS
feet: DIAMOND_BOOTS
main-hand: DIAMOND_SWORD
off-hand: SHIELD
```
Equipment must be synchronized to viewers.
---
# 20. LOGICAL INVENTORY
BotControl may maintain a logical inventory:
```text
0-35 inventory slots
armor slots
offhand
```
However, logical inventory does not automatically mean a client can open a normal Bukkit inventory window.
Inventory GUI support requires a dedicated packet interaction bridge.
---
# 21. HEALTH
Bots have logical health.
Example:
```yaml
health:
max: 100
current: 100
```
Health is managed by BotControl.
A packet-only fake player does not automatically have native Bukkit health.
Optional:
```text
name tag health
boss bar
scoreboard
damage animation
```
---
# 22. COMBAT
Combat must be abstracted.
Packet-only mode:
```text
Client attacks visual bot
↓
InteractionBridge
↓
Bot ID
↓
BotControl damage handler
```
Hybrid mode may use a server-side proxy/hitbox.
Supported events:
```text
bot attacked
bot attacks player
bot damaged
bot dies
bot kills player
bot target changed
```
Damage calculation belongs to BotControl.
---
# 23. INTERACTION BRIDGE
Support:
```text
LEFT_CLICK
RIGHT_CLICK
ATTACK
INTERACT
INTERACT_AT
```
The bridge must identify:
```text
viewer
botId
action
hand
target position
```
Then BotControl decides what happens.
---
# 24. COLLISION
Packet-only fake players do not automatically provide normal server collision.
Therefore:
```yaml
physics:
mode: NONE
```
or:
```yaml
physics:
mode: SERVER_PROXY
```
For real collision, use the server-side bridge.
Do not fake collision using packets alone and assume Bukkit will recognize it.
---
# 25. AI
BotControl should contain the behavior system.
Core states:
```text
IDLE
PATROL
FOLLOW
CHASE
FLEE
GUARD
ATTACK
RETURN
WANDER
CUSTOM
```
Each bot has:
```text
current state
target
destination
speed
priority
behavior cooldown
```
---
# 26. TARGETING
Targets may be:
```text
PLAYER
BOT
LOCATION
ENTITY
NONE
```
Target selectors:
```text
NEAREST
RANDOM
LOWEST_HEALTH
HIGHEST_PRIORITY
GROUP_TARGET
MANUAL
```
Filtering:
```text
same group
different group
permission
world
distance
visibility
protected players
```
---
# 27. PATHFINDING
FakePlayerEngine itself should not contain high-level AI.
BotControl may use:
```text
DIRECT
WAYPOINT
GRID
PATHFINDER_ADAPTER
```
Pathfinding must be optional.
If no pathfinder exists, direct movement remains available.
---
# 28. GROUP SYSTEM
Bots can belong to groups.
```yaml
groups:
guards:
members:
- guard_1
- guard_2
```
Group properties:
```text
name
behavior
formation
target rules
visibility
equipment template
spawn point
permissions
```
---
# 29. FORMATIONS
Optional:
```text
LINE
CIRCLE
SQUARE
COLUMN
FOLLOW_LEADER
CUSTOM
```
Formation calculations are handled by BotControl.
FakePlayerEngine only renders resulting locations.
---
# 30. SPAWN POINTS
Support named points:
```yaml
points:
arena:
world: world
x: 100
y: 64
z: 100
yaw: 90
pitch: 0
```
Bots may spawn:
```text
at point
at random point
inside area
around player
around target
```
---
# 31. AREAS
Areas can restrict:
- Spawn
- Movement
- AI
- Visibility
- Combat
- Despawn
Example:
```yaml
areas:
arena:
world: world
min: ...
max: ...
```
---
# 32. BOT TEMPLATES
Templates prevent repetitive configuration.
Example:
```yaml
templates:
guard:
engine-mode: HYBRID_FAKE_PLAYER
health: 100
movement:
mode: PATROL
equipment:
main-hand: IRON_SWORD
```
Creating 50 guards should copy the template, then generate unique bot IDs/UUIDs.
---
# 33. BOT REGISTRY
The registry must maintain:
```text
botId → BotData
uuid → botId
entityId → botId
username → botId
```
All mappings must be cleaned when bots are destroyed.
---
# 34. DUPLICATE PREVENTION
Never allow:
```text
two active instances with same botId
two active instances with same UUID
two active instances using same entity ID
```
Before respawning:
```text
destroy old instance
clear viewer state
allocate new entity ID
spawn new instance
```
---
# 35. RECOVERY
If packet state becomes inconsistent:
```text
detect mismatch
↓
destroy client-side entity
↓
clear viewer state
↓
resynchronize profile
↓
spawn again
↓
restore metadata/equipment
```
Provide:
```text
/bot engine resync
```
---
# 36. TAB LIST
Supported modes:
```text
VISIBLE
HIDDEN
TEMPORARY
AUTO
```
Some clients may require profile synchronization behavior for proper player skin rendering.
The engine may temporarily add a profile to player info, spawn the entity, then remove it when appropriate.
This behavior must be configurable.
---
# 37. CHAT
A fake player cannot provide a real authenticated signed-chat identity.
Therefore bot chat must use:
```text
server/system message
```
Example:
```text
Hello
```
The implementation must not claim that this is authenticated player chat.
---
# 38. COMMANDS
Bots are not real Bukkit players.
Therefore commands require a bridge.
Support:
```text
/bot command
```
The server executes the command through an explicitly configured virtual sender.
Do not automatically grant OP.
---
# 39. PERMISSIONS
Support logical permissions:
```yaml
permissions:
- bot.use
- bot.interact
```
These are not automatically equivalent to Bukkit `Player` permissions.
A permission bridge must be explicitly implemented.
---
# 40. EVENTS
FakePlayerEngine should expose events such as:
```text
FakePlayerSpawnEvent
FakePlayerDespawnEvent
FakePlayerMoveEvent
FakePlayerInteractEvent
FakePlayerDamageEvent
FakePlayerDeathEvent
FakePlayerSkinUpdateEvent
FakePlayerViewerEnterEvent
FakePlayerViewerExitEvent
FakePlayerEngineErrorEvent
```
BotControl listens to these events.
---
# 41. API CONTRACT
Conceptual Java API:
```java
FakePlayer createFakePlayer(BotProfile profile);
void spawn(String botId, Location location);
void despawn(String botId);
void destroy(String botId);
void move(
String botId,
Location location,
float yaw,
float pitch
);
void look(
String botId,
float yaw,
float pitch
);
void setSkin(
String botId,
SkinProfile skin
);
void setEquipment(
String botId,
EquipmentSlot slot,
ItemStack item
);
void setVisibleTo(
String botId,
Player viewer,
boolean visible
);
void playAnimation(
String botId,
Animation animation
);
```
This is an architectural contract, not a claim that these exact method signatures already exist.
---
# 42. SKRIPT BRIDGE
BotControl must expose FakePlayerEngine functions to Skript.
Conceptual syntax:
```text
create fake bot
spawn fake bot
despawn fake bot
destroy fake bot
move fake bot
set fake bot skin
set fake bot equipment
show fake bot to player
hide fake bot from player
play fake bot animation
```
The exact Skript syntax must be implemented by the addon/bridge.
Do NOT invent unsupported Skript syntax and claim it works.
---
# 43. BOTCONTROL COMMANDS
Core commands:
```text
/bot create
/bot delete
/bot spawn
/bot despawn
/bot list
/bot info
/bot select
/bot move
/bot look
/bot reload
```
FakePlayerEngine commands:
```text
/bot skin player
/bot skin texture
/bot show
/bot hide
/bot tab
/bot engine status
/bot engine reload
/bot engine diagnostics
/bot engine resync
```
---
# 44. MASS SPAWN
Support:
```text
/bot spawn amount
```
Optional:
```text
template
group
point
area
```
Example conceptual command:
```text
/bot spawn amount 20 template guard point arena
```
Mass spawning must occur in batches.
Never create hundreds of bots in one synchronous blocking operation.
---
# 45. MASS DESPAWN
Support:
```text
/bot despawn all
/bot despawn group
/bot despawn area
```
Use staged cleanup.
---
# 46. CONFIGURATION
Main configuration:
```yaml
engine:
enabled: true
mode: HYBRID_FAKE_PLAYER
packet-adapter: PACKETEVENTS
profile:
stable-uuid: true
username-policy: VALIDATE
name-conflict-policy: SUFFIX
skin:
cache: true
fallback: DEFAULT
viewer:
enabled: true
max-distance: 96
max-visible-per-player: 100
physics:
mode: SERVER_PROXY
updates:
movement-hz: 10
rotation-hz: 5
ai-hz: 5
persistence-seconds: 30
```
---
# 47. BOT DATA
Example:
```yaml
bot_000001:
uuid: "generated-stable-uuid"
profile:
username: "TrainingBot"
display-name: "&aTrainingBot"
skin:
source: DEFAULT
model: CLASSIC
engine:
mode: HYBRID_FAKE_PLAYER
viewer:
visible: true
tab: false
physics:
mode: SERVER_PROXY
movement:
mode: PATROL
health:
max: 100
current: 100
```
---
# 48. PERSISTENCE
Persist:
```text
bots
profiles
UUIDs
skins
groups
templates
routes
points
areas
loadouts
logical health
logical inventory
AI state where required
```
Do not persist temporary entity IDs.
---
# 49. FILE STRUCTURE
Recommended:
```text
plugins/BotControl/
│
├── config.yml
├── bots.yml
├── profiles.yml
├── skins.yml
├── groups.yml
├── templates.yml
├── routes.yml
├── points.yml
├── areas.yml
├── loadouts.yml
│
└── backups/
```
---
# 50. STARTUP
Startup order:
```text
Paper
↓
FakePlayerEngine
↓
Packet adapter
↓
Profile/Skin manager
↓
BotControl
↓
Load persistent bots
↓
Validate data
↓
Register bots
↓
Spawn configured bots
↓
Start AI scheduler
```
If FakePlayerEngine fails, BotControl must clearly report that fake-player functionality is unavailable instead of silently failing.
---
# 51. SHUTDOWN
On shutdown:
```text
stop AI
stop movement
despawn all fake players
remove viewer state
release packet listeners
release entity mappings
save persistent data
```
No fake-player state should remain registered after plugin shutdown.
---
# 52. WORLD UNLOAD
Before unloading a world:
```text
find bots in world
despawn them
save their locations
pause AI
```
After the world loads:
```text
restore eligible bots
resume AI
```
Never spawn into an unloaded world.
---
# 53. PLAYER JOIN
When a player joins:
```text
register viewer
load visible bot list
filter by world/distance/rules
synchronize profiles
spawn eligible bots
```
The process should be asynchronous/batched where possible.
---
# 54. PLAYER QUIT
Remove viewer state:
```text
viewer → bot visibility mappings
```
Do not destroy bots merely because one viewer leaves.
---
# 55. WORLD CHANGE
When viewer changes worlds:
```text
remove old-world fake players
load new-world fake players
```
---
# 56. PERFORMANCE LIMITS
Configuration should separate:
```text
maximum logical bots
maximum active bots
maximum visible bots per viewer
maximum spawn batch
maximum packets/update cycle
```
Example:
```yaml
limits:
max-bots: 500
max-active: 300
max-visible-per-player: 100
spawn-batch-size: 10
```
These are defaults, not hard-coded requirements.
---
# 57. PERFORMANCE STRATEGY
Never perform:
```text
500 bots × every tick × every viewer
```
Instead:
```text
AI scheduler
movement scheduler
viewer culling
LOD
batched packet queue
```
Only update what changed.
Examples:
If a bot's equipment has not changed, do not resend it.
If its rotation has not meaningfully changed, do not resend rotation.
If no viewer can see it, do not send viewer packets.
---
# 58. PACKET QUEUE
Packets should be queued and batched where possible.
Conceptual:
```text
Bot State Changes
↓
Update Queue
↓
Viewer Filter
↓
Packet Adapter
↓
Client
```
Avoid excessive immediate packet sending.
---
# 59. THREAD SAFETY
Paper/Bukkit API objects must only be accessed according to their thread-safety requirements.
The engine must distinguish:
```text
async calculation
sync Bukkit operation
packet operation
```
Never access unsafe Bukkit world/entity APIs from arbitrary asynchronous threads.
---
# 60. ERROR HANDLING
Errors must be explicit.
Examples:
```text
INVALID_PROFILE
INVALID_UUID
INVALID_USERNAME
DUPLICATE_BOT
DUPLICATE_UUID
INVALID_WORLD
INVALID_LOCATION
SKIN_LOAD_FAILED
PACKET_ADAPTER_UNAVAILABLE
VIEWER_SYNC_FAILED
ENGINE_NOT_READY
PROXY_CREATION_FAILED
```
Log useful diagnostics without flooding console every tick.
---
# 61. FALLBACK BEHAVIOR
If skin fails:
```text
use default skin
```
If PacketEvents unavailable:
```text
try ProtocolLib if configured
```
If no packet adapter exists:
```text
engine unavailable
```
Do not pretend the bot spawned successfully.
---
# 62. DIAGNOSTICS
Provide:
```text
/bot engine status
```
Output should include:
```text
Engine: READY
Adapter: PACKETEVENTS
Paper: 1.21.11
Active Bots: X
Visible Fake Players: X
Registered Viewers: X
Packet Queue: X
Profiles Cached: X
Skins Cached: X
Errors: X
```
---
# 63. DEBUG MODE
Config:
```yaml
debug:
enabled: false
packets: false
viewer-sync: false
movement: false
profiles: false
skins: false
```
Debug logs must be disabled by default.
---
# 64. SECURITY
Do not allow ordinary players to:
- Create unlimited bots.
- Impersonate staff.
- Use arbitrary commands through bot execution.
- Force bots into protected areas.
- Abuse external skin/profile lookups.
All bot administration requires explicit permission.
Example:
```text
botcontrol.admin
botcontrol.create
botcontrol.delete
botcontrol.spawn
botcontrol.engine
```
---
# 65. STAFF IMPERSONATION PROTECTION
If a username resembles an administrator, configurable protection should prevent accidental impersonation.
Example:
```yaml
security:
protected-usernames:
- Admin
- Owner
- Console
```
Optional exact/partial matching.
---
# 66. PLACEHOLDER SUPPORT
Optional PlaceholderAPI integration.
Possible placeholders:
```text
%botcontrol_count%
%botcontrol_active%
%botcontrol_visible%
%botcontrol__health%
%botcontrol__state%
%botcontrol__world%
```
---
# 67. WORLDGUARD
Optional integration.
Bot spawning/movement can respect:
```text
build
damage
entry
exit
pvp
```
WorldGuard integration must be optional and must not become a hard dependency unless configured.
---
# 68. LUCKPERMS
Optional permission integration for administrative access.
Do not require LuckPerms for core functionality.
---
# 69. VAULT
Optional economy integration if BotControl later supports paid bot operations.
Not required for FakePlayerEngine.
---
# 70. CORE BOT STATES
```text
CREATED
LOADED
READY
SPAWNED
ACTIVE
PAUSED
DESPAWNING
DESPAWNED
ERROR
DESTROYED
```
---
# 71. ENGINE STATES
```text
DISABLED
STARTING
READY
DEGRADED
ERROR
STOPPING
STOPPED
```
---
# 72. FAKE PLAYER STATE
Each active fake player stores:
```text
botId
uuid
entityId
profile
location
yaw
pitch
pose
equipment
visible viewers
tab state
engine mode
spawn time
last update
```
---
# 73. VIEWER STATE
Per viewer:
```text
viewer UUID
world
visible bots
profile-synced bots
spawned entities
last synchronization
```
This allows independent visibility.
---
# 74. SKIN UPDATE
When a skin changes:
```text
update logical profile
cache profile
notify engine
despawn/resynchronize if required
apply new profile
respawn client representation
restore metadata
restore equipment
```
The exact refresh strategy depends on the client/protocol behavior.
---
# 75. BOT TELEPORT
Bot teleport:
```text
validate destination
update logical location
notify movement controller
if same world:
send teleport
else:
remove from old viewers
change world state
spawn to new viewers
```
---
# 76. BOT DEATH
Logical death:
```text
health <= 0
↓
FakePlayerDeathEvent
↓
play death/hurt animation as configured
↓
despawn or ragdoll behavior
↓
run BotControl death actions
↓
optional respawn
```
---
# 77. RESPAWN
Configurable:
```yaml
respawn:
enabled: true
delay: 100
```
After respawn:
```text
new entity ID
same stable bot UUID
same profile
same or reset state
```
---
# 78. ENTITY ID RULE
Entity IDs are runtime-only.
Never save entity IDs as persistent identity.
Persistent identity:
```text
botId + UUID
```
Runtime identity:
```text
entityId
```
---
# 79. UUID RULE
A bot's UUID should normally remain stable.
Changing UUID should be an explicit administrative operation.
If changed:
```text
despawn
update profile
resynchronize
spawn
```
---
# 80. PROFILE CACHE
Cache key can be:
```text
UUID
username
texture hash
```
Cache:
```text
username
UUID
texture
signature
model
timestamp
```
Provide configurable refresh behavior.
---
# 81. EXTERNAL API FAILURE
If an external skin provider fails:
```text
retry with backoff
↓
use cache
↓
use fallback
```
Do not continuously retry every tick.
---
# 82. BOT VISIBILITY
Commands:
```text
show bot to player
hide bot from player
show all bots
hide all bots
```
Visibility can be:
```text
GLOBAL
GROUP
WORLD
AREA
PLAYER-SPECIFIC
```
---
# 83. VIEWER FILTER
A bot should be sent only if:
```text
engine ready
bot spawned
same world
within distance
viewer allowed
area allows visibility
visibility enabled
```
---
# 84. PLAYER INTERACTION SAFETY
Never treat arbitrary packet input as trusted.
Validate:
```text
viewer
bot exists
bot spawned
distance
world
action
cooldown
```
Reject impossible interactions.
---
# 85. INTERACTION COOLDOWNS
Prevent packet spam:
```yaml
interaction:
max-actions-per-second: 20
```
The actual value should be configurable.
---
# 86. MOVEMENT VALIDATION
When BotControl requests movement:
```text
validate world
validate finite coordinates
validate loaded chunk when required
validate limits
validate target
```
Reject NaN/infinite/invalid coordinates.
---
# 87. LOCATION LIMITS
Never allow accidental locations outside safe numeric bounds.
Coordinates must be finite.
---
# 88. ROUTES
Route:
```yaml
routes:
guard_route:
- point_a
- point_b
- point_c
```
BotControl advances through waypoints.
FakePlayerEngine renders movement.
---
# 89. RANDOM WANDER
Random movement must respect:
```text
world
area
distance
obstacles if pathfinding enabled
```
---
# 90. FOLLOW
Follow:
```text
target
minimum distance
maximum distance
speed
update rate
```
---
# 91. GUARD
Guard behavior:
```text
stay near point
scan targets
chase allowed targets
return after target lost
```
---
# 92. FORMATION UPDATE
Formation calculations occur in BotControl.
The resulting positions are sent to FakePlayerEngine.
Do not duplicate formation logic inside the packet engine.
---
# 93. SEPARATION
Optional AI separation prevents bots from occupying identical logical positions.
Packet rendering alone does not create real collision.
---
# 94. BOT SELECTION
Admin selection can be:
```text
/bot select
```
Then commands may omit bot ID where appropriate.
---
# 95. BOT INFORMATION
`/bot info` should show:
```text
Bot ID
Username
UUID
Engine mode
Entity ID
World
Location
Health
State
Behavior
Target
Skin
Visible viewers
```
---
# 96. CONFIG RELOAD
`/bot reload` must:
```text
reload configuration
validate configuration
reload templates
reload profiles where safe
apply settings
```
Do not blindly destroy all bots unless necessary.
---
# 97. ENGINE RELOAD
`/bot engine reload`:
```text
pause updates
despawn/reconfigure if required
reload adapter
reinitialize managers
resynchronize bots
resume updates
```
---
# 98. DIAGNOSTIC RESYNC
`/bot engine resync [player]`
If player omitted:
```text
resync all viewers
```
If player supplied:
```text
resync only that viewer
```
---
# 99. BOT EXPORT
Optional:
```text
/bot export
```
Exports logical BotControl data, not runtime entity IDs.
---
# 100. BOT IMPORT
Optional:
```text
/bot import
```
Must validate:
```text
schema
UUID
username
world
locations
templates
```
---
# 101. CONFIG VERSION
Every persistent file should have a schema version.
Example:
```yaml
schema-version: 1
```
Future migrations must be supported.
---
# 102. BACKUPS
Before destructive migrations or imports:
```text
create backup
validate new data
apply migration
```
---
# 103. LOGGING
Use structured messages:
```text
[BotControl]
[FakePlayerEngine]
[PacketAdapter]
[ProfileManager]
[SkinManager]
```
Do not spam logs during normal movement.
---
# 104. DEPENDENCY CHECK
At startup verify:
```text
Paper 1.21.11 compatible
Skript available
FakePlayerEngine available
packet adapter available
optional integrations
```
If a required dependency is missing, show a clear error.
---
# 105. PAPER VERSION
Target specifically:
```text
Paper 1.21.11
```
Do not assume older NMS mappings.
Where possible, use public Paper APIs.
Use version-specific internals only inside the engine adapter.
---
# 106. NMS ISOLATION
If NMS/internal Minecraft classes are required:
```text
FakePlayerEngine
└── version-specific adapter
```
Do not spread NMS calls throughout BotControl.
BotControl should communicate through stable interfaces.
---
# 107. ADAPTER DESIGN
Recommended:
```text
FakePlayerEngine
├── api/
├── profile/
├── skin/
├── viewer/
├── interaction/
├── physics/
└── adapter/
└── paper_1_21_11/
```
---
# 108. PLUGIN INITIALIZATION
The Java plugin should expose:
```text
FakePlayerEngineProvider
```
BotControl obtains the service through Bukkit's service manager or a controlled API.
---
# 109. SKRIPT ADDON INITIALIZATION
If BotControl is implemented as a Skript addon:
```text
Java Plugin
↓
FakePlayerEngine
↓
Skript addon registration
↓
Skript syntax
```
Do not make Skript perform packet internals directly.
---
# 110. SCRIPT/ENGINE RESPONSIBILITY
Skript:
```text
bot logic
commands
configuration
AI rules
events
templates
selection
groups
routes
```
Java:
```text
fake player
packets
profiles
skins
viewer synchronization
entity lifecycle
low-level interaction
```
---
# 111. EXAMPLE FLOW
Admin:
```text
/bot create Guard01
/bot skin Guard01 player ExamplePlayer
/bot spawn Guard01
```
Internal:
```text
BotControl creates BotData
↓
FakePlayerEngine creates profile
↓
UUID generated
↓
Skin resolved
↓
Entity created
↓
Viewer synchronization
↓
Client sees player
```
---
# 112. MASS BOT FLOW
```text
/bot spawn amount 20 template guard point arena
```
System:
```text
load template
↓
generate 20 bot IDs
↓
generate stable UUIDs
↓
create profiles
↓
allocate spawn positions
↓
queue spawning
↓
viewer culling
↓
spawn batches
```
---
# 113. BOT SKIN EXAMPLE
```text
/bot skin Guard01 player Notch
```
This means:
```text
resolve profile/skin for the supplied username
cache it
apply it to Guard01
```
It does NOT log into that account.
---
# 114. DEFAULT SKIN
If no custom skin exists:
```text
DEFAULT
```
The bot must still be visible.
---
# 115. RANDOM SKIN POOL
Example:
```yaml
skin-pools:
guards:
- skin_a
- skin_b
- skin_c
```
Each bot can select one.
---
# 116. EQUIPMENT TEMPLATE
```yaml
loadouts:
guard:
main-hand: IRON_SWORD
off-hand: SHIELD
head: IRON_HELMET
chest: IRON_CHESTPLATE
legs: IRON_LEGGINGS
feet: IRON_BOOTS
```
---
# 117. BOT AI TICK
AI should not require every bot to run every server tick.
Use scheduled batches.
Example:
```text
tick group A
tick group B
tick group C
...
```
---
# 118. MOVEMENT SMOOTHNESS
Movement should appear smooth to clients.
Use:
```text
teleport for large displacement
relative movement for small displacement
rotation packets for direction
```
Do not send a teleport every movement update unless necessary.
---
# 119. LARGE TELEPORT
If distance exceeds configured threshold:
```text
use teleport
```
instead of attempting many relative movement packets.
---
# 120. CHUNK HANDLING
Before spawning a fake player:
```text
world valid
chunk relevant
viewer can receive entity
```
The engine must handle chunk/viewer changes.
---
# 121. INVISIBLE BOT
Support:
```text
visible
invisible
```
If invisible, remove/avoid visual representation while retaining logical BotControl state if desired.
---
# 122. GLOW
Optional visual glow:
```text
glowing: true
```
Use appropriate entity metadata/team handling.
---
# 123. NAME TAG
Support:
```text
show
hide
custom display name
```
The exact visual implementation may use player entity name or team/scoreboard systems.
---
# 124. TEAM INTEGRATION
Optional scoreboard team support for:
```text
name color
friendly targeting
collision rule
visibility
```
Do not confuse teams with fake-player creation.
---
# 125. SPECTATOR
If a viewer is in spectator mode, visibility rules may be configurable.
---
# 126. VANISH
If viewer is vanished:
```text
bot visibility policy
```
must be configurable.
---
# 127. SUPER-VANISH COMPATIBILITY
If SuperVanish exists, do not hard-depend on it.
Provide an optional integration hook.
---
# 128. COREPROTECT
Fake players are not automatically normal logged-in players.
CoreProtect logging of fake-player actions may require explicit integration.
Do not claim automatic support without implementing it.
---
# 129. ANTI-CHEAT
Anti-cheat plugins may not understand fake players.
FakePlayerEngine should expose compatibility hooks rather than attempting to bypass anti-cheat.
---
# 130. DAMAGE BRIDGE
When a bot receives logical damage:
```text
validate attacker
calculate damage
update health
send hurt animation
```
Optional:
```text
knockback
sound
particles
death
```
---
# 131. ATTACK BRIDGE
When bot attacks:
```text
BotControl selects target
↓
damage calculation
↓
server damage API or controlled damage
↓
animation
↓
cooldown
```
---
# 132. COOLDOWNS
Support:
```text
attack cooldown
interaction cooldown
animation cooldown
path recalculation cooldown
skin retry cooldown
```
---
# 133. SOUND
Optional sounds:
```text
attack
hurt
death
step
```
Sounds are visual/immersive effects and must not be required for engine functionality.
---
# 134. PARTICLES
Optional:
```text
attack
hurt
spawn
despawn
```
---
# 135. DEBUG ENTITY TRACKING
Diagnostic mode should allow administrators to see:
```text
Bot ID
Entity ID
UUID
viewer count
last packet
last movement
```
---
# 136. MEMORY MANAGEMENT
When a bot is deleted:
```text
registry removed
UUID mapping removed
username mapping removed
entity mapping removed
viewer mappings removed
route references cleaned
group references cleaned
```
No memory leak.
---
# 137. BOT REFERENCES
Groups/routes/templates must never retain references to deleted bot objects.
Use bot IDs or validated references.
---
# 138. RELOAD SAFETY
Do not duplicate:
```text
packet listeners
event listeners
scheduler tasks
bots
profiles
viewer states
```
A reload must clean old registrations first.
---
# 139. PLUGIN RESTART SAFETY
After restart:
```text
persistent bot data
↓
validate
↓
restore stable UUID
↓
spawn
```
Entity IDs are regenerated.
---
# 140. FAIL-SAFE
If FakePlayerEngine crashes internally:
```text
stop unsafe updates
despawn affected visual entities
retain BotControl logical data
log error
allow controlled engine recovery
```
Do not corrupt `bots.yml`.
---
# 141. API FAILURE
All API calls should return success/failure or throw controlled exceptions.
Example:
```text
SpawnResult
SUCCESS
INVALID_LOCATION
ENGINE_NOT_READY
DUPLICATE
PACKET_ERROR
```
---
# 142. ASYNC SKIN LOADING
Skin/profile retrieval may be asynchronous.
While waiting:
```text
bot can remain logically CREATED/READY
```
Once profile is ready:
```text
apply skin
spawn/resync
```
Never block the main server thread on external network requests.
---
# 143. CACHE EXPIRATION
Configurable:
```yaml
skin:
cache: true
cache-hours: 24
```
Use sensible defaults.
---
# 144. RATE LIMITING
External profile lookups must be rate-limited and cached.
Never make one external request per bot every restart if cached data is valid.
---
# 145. BOT FACTORY
Create bots through:
```text
BotFactory
```
Factory responsibilities:
```text
validate profile
generate ID
generate UUID
apply template
create BotData
register bot
```
---
# 146. FAKE PLAYER FACTORY
FakePlayerEngine:
```text
FakePlayerFactory
```
Responsibilities:
```text
create profile representation
allocate entity ID
create engine state
prepare packets
```
---
# 147. SEPARATION
Do not combine:
```text
BotData
FakePlayerEntity
Bukkit Player
```
They are different concepts.
---
# 148. BOTDATA
Logical:
```text
BotData
```
contains AI/gameplay information.
---
# 149. FAKEPLAYERINSTANCE
Runtime:
```text
FakePlayerInstance
```
contains:
```text
entityId
viewers
runtime state
packet state
```
---
# 150. PROFILE
Identity:
```text
BotProfile
```
contains:
```text
UUID
username
display name
skin
```
---
# 151. RELATIONSHIP
```text
BotData
│
├── BotProfile
│
└── FakePlayerInstance
```
A bot can exist logically without being spawned.
---
# 152. DESPAWNED BOT
A despawned bot still exists in BotControl.
It simply has:
```text
FakePlayerInstance = null
```
until spawned again.
---
# 153. DELETE VS DESPAWN
`despawn`:
```text
remove runtime entity
keep bot
```
`delete`:
```text
remove runtime entity
remove persistent bot
```
---
# 154. VIEWER-SPECIFIC SPAWN
One bot can be:
```text
visible to Player A
hidden from Player B
```
without creating separate logical bots.
---
# 155. MULTI-VIEWER STATE
The engine must maintain per-viewer synchronization independently.
---
# 156. SKIN CONSISTENCY
All viewers should see the same configured skin unless viewer-specific skin mode is explicitly implemented.
---
# 157. OPTIONAL VIEWER-SPECIFIC SKIN
Advanced feature:
```text
bot appears with different skin to different viewer
```
This is optional and should not be required for initial release.
---
# 158. PLAYER MODEL
Default model:
```text
normal Minecraft player
```
Not:
```text
armor stand
zombie
villager
```
unless explicitly requested as fallback.
---
# 159. FALLBACK ENTITY
If fake-player packets are unavailable, do NOT silently replace the bot with a zombie/armor stand.
Report engine failure.
---
# 160. COMPATIBILITY PRIORITY
Priority:
```text
Paper 1.21.11
↓
PacketEvents
↓
ProtocolLib fallback
↓
optional integrations
```
---
# 161. TESTING
Required tests:
```text
create bot
spawn bot
despawn bot
delete bot
restart server
multiple viewers
viewer joins
viewer quits
world change
bot world change
skin loading
skin failure
duplicate UUID
duplicate username
equipment update
movement
rotation
animation
combat
interaction
mass spawn
mass despawn
reload
engine resync
```
---
# 162. STRESS TEST
Test at least:
```text
10 bots
50 bots
100 bots
250 bots
500 logical bots
```
Measure:
```text
TPS
MSPT
packet count
memory
CPU
viewer synchronization
```
Do not assume 500 visible bots are acceptable; make the limits configurable.
---
# 163. ACCEPTANCE TEST
A basic successful implementation must allow:
```text
1. Create Bot.
2. Give Bot username.
3. Assign skin.
4. Spawn Bot.
5. Player sees normal player model.
6. Bot moves.
7. Bot rotates.
8. Bot changes equipment.
9. Bot can be shown/hidden per viewer.
10. Bot can despawn.
11. Bot can respawn.
12. Bot survives server restart with same UUID.
```
---
# 164. COMBAT ACCEPTANCE
If HYBRID mode is implemented:
```text
Player attacks bot
↓
BotControl receives interaction
↓
Bot takes logical damage
↓
hurt animation
↓
health decreases
↓
death at zero
```
---
# 165. AI ACCEPTANCE
Example:
```text
Guard bot
↓
patrol route
↓
detect target
↓
chase
↓
attack
↓
target lost
↓
return to route
```
---
# 166. ENGINE DIAGNOSTIC ACCEPTANCE
`/bot engine status` must clearly state whether:
```text
FakePlayerEngine = READY
PacketAdapter = READY
ProfileManager = READY
SkinManager = READY
ViewerManager = READY
```
---
# 167. NO FAKE CLAIMS
The implementation must not claim:
```text
"Bot is a real Bukkit Player"
```
unless a genuine supported mechanism exists.
Instead:
```text
"Fake Player"
"Packet Player"
"Hybrid Fake Player"
```
---
# 168. IMPLEMENTATION PRIORITY
Build in this order:
```text
1. Java plugin bootstrap
2. Packet adapter
3. Profile system
4. Fake player spawn/despawn
5. Viewer synchronization
6. Skin system
7. Movement/rotation
8. Equipment
9. BotControl API
10. Skript bridge
11. Interaction bridge
12. Physics bridge
13. AI
14. Persistence
15. Performance optimization
16. Optional integrations
```
---
# 169. MINIMUM VIABLE VERSION
MVP must contain:
```text
FakePlayerEngine
Paper 1.21.11 support
PacketEvents adapter
stable UUID
username
skin
spawn
despawn
movement
rotation
equipment
viewer visibility
basic Skript bridge
persistence
diagnostics
```
---
# 170. ADVANCED VERSION
Advanced release adds:
```text
Hybrid physics
combat
interaction
pathfinding
inventory
logical commands
formations
LOD
large-scale batching
WorldGuard
PlaceholderAPI
LuckPerms
Vault
advanced skin pools
```
---
# 171. BOTCONTROL INTEGRATION RULE
BotControl must never directly manipulate packet internals.
Bad:
```text
Skript → raw packets
```
Correct:
```text
Skript
↓
BotControl
↓
FakePlayerEngine API
↓
PacketAdapter
```
---
# 172. FINAL REQUIRED ARCHITECTURE
```text
┌─────────────────────┐
│ BotControl │
│ Skript/Logic Layer │
└──────────┬──────────┘
│
Stable API
│
┌──────────▼──────────┐
│ FakePlayerEngine │
│ Java Runtime Layer │
└──────────┬──────────┘
│
┌────────────────────┼────────────────────┐
│ │ │
┌────────▼────────┐ ┌────────▼────────┐ ┌────────▼────────┐
│ Profile Manager │ │ Viewer Manager │ │ Interaction │
│ Skin Manager │ │ Entity Manager │ │ Physics Bridge │
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ │ │
└────────────────────┼────────────────────┘
│
┌───────▼────────┐
│ Packet Adapter │
├────────────────┤
│ PacketEvents │
│ ProtocolLib │
└───────┬────────┘
│
┌───────▼────────┐
│ Paper 1.21.11 │
└───────┬────────┘
│
Minecraft Client
```
---
# 173. FINAL IMPLEMENTATION REQUIREMENT
The developer/AI implementing this specification must produce a **real working Paper 1.21.11 implementation**, not pseudocode disguised as a plugin.
The implementation must:
- Compile.
- Load on Paper 1.21.11.
- Register its commands/events.
- Create actual client-visible fake player representations.
- Apply skins.
- Synchronize viewers.
- Handle spawn/despawn.
- Integrate with BotControl.
- Avoid fake APIs that do not exist.
- Avoid unsupported old NMS code.
- Keep version-specific code isolated.
- Clearly document any feature that requires an optional dependency.
If a requested feature cannot be implemented through pure Skript, it must be implemented in the Java FakePlayerEngine rather than replacing it with an unrelated NPC system.
**The FakePlayerEngine is a required component of BotControl, not an optional cosmetic addon.**
إنشاء هيكل Paper 1.21.11 وربطه بـ PacketEvents.
تنفيذ سجلّ البوتات وحفظ هويتها ومواقعها بين مرات التشغيل.
إضافة أوامر الإدارة ومزامنة الظهور والحركة والتشخيص.
أنشأت نواة BotControl لـ Paper 1.21.11: إنشاء ملفات تعريف بهويات UUID ثابتة وحفظها، وأوامر الإنشاء والحذف والظهور والإخفاء والحركة والتشخيص، مع مزامنة الظهور حسب العالم والمسافة.
يتطلب المشروع تثبيت PacketEvents على الخادم. التنفيذ الحالي لا يغطي المواصفات كاملة بعد: دعم الجلود والمعدات والـSkript والقتال والتفاعل والذكاء الاصطناعي غير مُنفّذ، ولم أتحقق من نجاح البناء.
The compilation failed with this error:
Compilation failed with 1 error(s):
ERROR in src/main/java/com/kodari/botcontrol/FakePlayerEngine.java at line 5: cannot find symbol
import com.github.retrooper.packetevents.protocol.player.PlayerInfo;
^
symbol: class PlayerInfo
location: package com.github.retrooper.packetevents.protocol.player
=== COMPILATION ERROR ANALYSIS ===
MISSING CLASSES:
- PlayerInfo
ACTION: Create these classes or check imports
FILES TO INVESTIGATE:
- src/main/java/com/kodari/botcontrol/FakePlayerEngine.java
Please fix this error by creating a new artifact with the corrected code.
Replace the unavailable top-level
PlayerInfoimport with PacketEvents’ nested update-wrapper type.Keep the existing player-info construction and packet flow unchanged.
Updated FakePlayerEngine.java to import PlayerInfo from WrapperPlayServerPlayerInfoUpdate, where PacketEvents provides it as a nested type. The existing packet construction is unchanged.
ما المشكلة؟
المشكلة كانت في سطر الاستيراد: الكود يبحث عن PlayerInfo كصنف مستقل داخل protocol.player، لكن إصدار PacketEvents المستخدم يعرّفه كصنف متداخل داخل WrapperPlayServerPlayerInfoUpdate. تم تصحيح الاستيراد؛ لم تكن المشكلة في منطق إنشاء اللاعب الوهمي.
هل تستطيع اصلاح مشكلة وقيام ب complie واحصل علي بلوجن؟
نعم، تم إصلاح خطأ الاستيراد في FakePlayerEngine.java. للحصول على ملف البلوجن:
اضغط Compile في الشريط العلوي (على الهاتف: ⋮ ثم Compile Project).
في النافذة التي تظهر، اضغط Compile.
بعد نجاح البناء، اضغط Download لتنزيل ملف البلوجن.
إذا فشل البناء بسبب خطأ آخر، أرسل رسالة الخطأ وسأساعدك في إصلاحه.
The compilation failed with this error:
Compilation failed with 1 error(s):
ERROR in src/main/java/com/kodari/botcontrol/FakePlayerEngine.java at line 189: incompatible types: Vector3d cannot be converted to Location
new Vector3d(location.getX(), location.getY(), location.getZ()),
^
=== COMPILATION ERROR ANALYSIS ===
TYPE MISMATCHES:
- incompatible types: Vector3d cannot be converted to Location
ACTION: Fix variable types or casting
FILES TO INVESTIGATE:
- src/main/java/com/kodari/botcontrol/FakePlayerEngine.java
Please fix this error by creating a new artifact with the corrected code.
استبدال
Vector3dبـLocationفي مُنشئWrapperPlayServerSpawnPlayer.إزالة الاستيراد غير المستخدم لـ
Vector3d.
تم إصلاح الخطأ في FakePlayerEngine.java: مُنشئ WrapperPlayServerSpawnPlayer يحتاج Location، لذا مرّرت الموقع مباشرة وأزلت استيراد Vector3d. أعد تشغيل Compile لتنزيل البلوجن بعد نجاح البناء.
[14:18:22 ERROR]: [DirectoryProviderSource] Error loading plugin: zip END header not fou [14:18:22 ERROR]: [DirectoryProviderSource] Error loading plugin: zip END header not fou فلتقوم ب اصلاح هذه اخطاء وارسال بلوجن لي بعد اصلاحهم
هذا الخطأ يعني أن ملف البلوجن .jar تالف أو لم يكتمل تنزيله؛ وليس خطأً جديدًا في الكود. احذف الملف التالف من مجلد plugins ثم أنشئ نسخة جديدة:
اضغط Compile في الشريط العلوي، أو على الهاتف ⋮ → Compile Project.
اضغط Compile في النافذة.
بعد نجاح البناء، اضغط Download لتنزيل ملف البلوجن الجديد، ثم ارفعه إلى مجلد
pluginsوأعد تشغيل السيرفر.
package com.kodari.botcontrol;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
public final class BotControlPlugin extends JavaPlugin implements Listener, CommandExecutor {
private static final Pattern USERNAME_PATTERN = Pattern.compile("[A-Za-z0-9_]{1,16}");
private final Map<String, BotProfile> bots = new HashMap<>();
private FakePlayerEngine engine;
private File botsFile;
private YamlConfiguration botsConfig;
@Override
public void onEnable() {
saveDefaultConfig();
botsFile = new File(getDataFolder(), "bots.yml");
engine = new FakePlayerEngine(this);
loadBots();
getCommand("bot").setExecutor(this);
Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getScheduler().runTaskTimer(this, engine::refreshViewers, 20L, 20L);
for (BotProfile bot : bots.values()) {
if (locationOf(bot) != null && getConfig().getBoolean("bots." + bot.getId() + ".spawn-on-start", false)) {
engine.spawn(bot);
}
}
getLogger().info("BotControl loaded " + bots.size() + " logical bot(s). Fake-player packets are provided by PacketEvents.");
}
@Override
public void onDisable() {
if (engine != null) {
engine.despawnAll();
}
saveBots();
}
public Location locationOf(BotProfile bot) {
World world = Bukkit.getWorld(bot.getWorld());
if (world == null || !Double.isFinite(bot.getX()) || !Double.isFinite(bot.getY()) || !Double.isFinite(bot.getZ())) {
return null;
}
return new Location(world, bot.getX(), bot.getY(), bot.getZ(), bot.getYaw(), bot.getPitch());
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Bukkit.getScheduler().runTask(this, () -> engine.viewerJoined(event.getPlayer()));
}
@EventHandler
public void onWorldChange(PlayerChangedWorldEvent event) {
engine.viewerChangedWorld(event.getPlayer());
}
@EventHandler
public void onQuit(PlayerQuitEvent event) {
engine.viewerQuit(event.getPlayer());
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
return help(sender);
}
if (args[0].equalsIgnoreCase("engine")) {
if (!hasPermission(sender)) return true;
sender.sendMessage(message("&aEngine: READY &7| Adapter: PacketEvents &7| Active bots: &f" + engine.activeCount()
+ " &7| Visible representations: &f" + engine.visibleCount()
+ " &7| Viewers: &f" + Bukkit.getOnlinePlayers().size()));
return true;
}
if (!hasPermission(sender)) {
sender.sendMessage(message("&cYou do not have permission."));
return true;
}
switch (args[0].toLowerCase(Locale.ROOT)) {
case "create" -> create(sender, args);
case "delete" -> delete(sender, args);
case "spawn" -> spawn(sender, args);
case "despawn" -> despawn(sender, args);
case "list" -> list(sender);
case "info" -> info(sender, args);
case "move" -> move(sender, args);
case "show" -> visibility(sender, args, true);
case "hide" -> visibility(sender, args, false);
default -> help(sender);
}
return true;
}
private void create(CommandSender sender, String[] args) {
if (args.length != 2 || !USERNAME_PATTERN.matcher(args[1]).matches()) {
sender.sendMessage(message("&cUsage: /bot create <username> (1-16 letters, digits, or underscores)"));
return;
}
if (bots.size() >= getConfig().getInt("limits.max-bots", 500)) {
sender.sendMessage(message("&cThe configured bot limit has been reached."));
return;
}
for (BotProfile existing : bots.values()) {
if (existing.getUsername().equalsIgnoreCase(args[1])) {
sender.sendMessage(message("&cThat username is already assigned to a bot."));
return;
}
}
String baseId = args[1].toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9_-]", "_");
String id = baseId;
int suffix = 1;
while (bots.containsKey(id)) id = baseId + "_" + suffix++;
String world = sender instanceof Player player ? player.getWorld().getName() : Bukkit.getWorlds().get(0).getName();
Location location = sender instanceof Player player ? player.getLocation() : Bukkit.getWorlds().get(0).getSpawnLocation();
BotProfile bot = new BotProfile(id, args[1], UUID.randomUUID());
bot.setDisplayName(args[1]);
bot.setWorld(world);
bot.setX(location.getX());
bot.setY(location.getY());
bot.setZ(location.getZ());
bot.setYaw(location.getYaw());
bot.setPitch(location.getPitch());
bots.put(id, bot);
saveBots();
sender.sendMessage(message("&aCreated fake-player profile &f" + id + " &7(UUID: " + bot.getUuid() + ")."));
}
private void delete(CommandSender sender, String[] args) {
BotProfile bot = args.length == 2 ? bots.get(args[1].toLowerCase(Locale.ROOT)) : null;
if (bot == null) {
sender.sendMessage(message("&cUsage: /bot delete <botId>"));
return;
}
engine.despawn(bot.getId());
bots.remove(bot.getId());
saveBots();
sender.sendMessage(message("&aDeleted bot &f" + bot.getId() + "&a."));
}
private void spawn(CommandSender sender, String[] args) {
BotProfile bot = args.length == 2 ? bots.get(args[1].toLowerCase(Locale.ROOT)) : null;
if (bot == null) {
sender.sendMessage(message("&cUsage: /bot spawn <botId>"));
return;
}
if (engine.spawn(bot)) sender.sendMessage(message("&aSpawned fake player &f" + bot.getUsername() + "&a."));
else sender.sendMessage(message("&cCould not spawn the bot. Check its world/chunk and active-bot limit."));
}
private void despawn(CommandSender sender, String[] args) {
if (args.length == 2 && args[1].equalsIgnoreCase("all")) {
engine.despawnAll();
sender.sendMessage(message("&aDespawned all active fake players."));
return;
}
BotProfile bot = args.length == 2 ? bots.get(args[1].toLowerCase(Locale.ROOT)) : null;
if (bot == null) {
sender.sendMessage(message("&cUsage: /bot despawn <botId|all>"));
return;
}
engine.despawn(bot.getId());
sender.sendMessage(message("&aDespawned &f" + bot.getId() + "&a."));
}
private void list(CommandSender sender) {
if (bots.isEmpty()) {
sender.sendMessage(message("&7No bot profiles have been created."));
return;
}
sender.sendMessage(message("&7Bots (&f" + bots.size() + "&7):"));
for (BotProfile bot : bots.values()) {
sender.sendMessage(ChatColor.GRAY + " - " + bot.getId() + " (" + bot.getUsername() + ") "
+ (engine.isActive(bot.getId()) ? ChatColor.GREEN + "ACTIVE" : ChatColor.YELLOW + "DESPAWNED"));
}
}