đź“„
pasted-code-1791101606835.txt
txt
376 lines
â–¶
Create a Minecraft Java plugin called **MalabarFakePlayers** for my server.
### Server
* Minecraft Java Edition: **1.21.11**
* Server software: **Paper**
* Plugin must be optimized for a production SMP server.
* Use Java and Maven.
* Provide the complete source code, `plugin.yml`, `config.yml`, and Maven `pom.xml`.
* The plugin must not require a client-side mod.
### Main Goal
Create fake players that appear and behave like real Minecraft players.
Fake players should:
* Join the server at configurable/random times.
* Leave the server at configurable/random times.
* Have realistic names and skins if possible.
* Move around naturally.
* Look around randomly.
* Walk between locations.
* Stop, start, and change direction naturally.
* Perform realistic Minecraft activities.
* Avoid looking like simple stationary NPCs.
### Realistic Activities
Fake players should randomly perform activities such as:
1. **Mining**
* Walk toward blocks.
* Look at the block.
* Break blocks.
* Collect dropped items when possible.
* Continue mining for a configurable amount of time.
2. **Building**
* Select blocks from their inventory.
* Place blocks.
* Build simple configurable structures.
* Avoid placing blocks inside themselves.
* Stop building occasionally.
3. **Walking / Exploring**
* Randomly explore the configured world.
* Walk around paths/areas.
* Randomly stop.
* Look around.
* Change direction.
* Avoid walking into dangerous locations.
4. **Farming**
* Find configured farmland.
* Break mature crops.
* Replant crops.
* Collect dropped items.
5. **Chopping**
* Find nearby trees.
* Break logs.
* Collect drops.
* Move to another tree.
6. **Fishing**
* Go to configured fishing locations.
* Equip a fishing rod.
* Fish for a configurable period.
* Stop and continue another activity.
7. **Idle**
* Sometimes simply stand around.
* Look around.
* Move slightly.
* Occasionally jump/sneak.
* Idle duration must be configurable.
### Activity System
Create an activity/task system.
Each fake player should have a current state such as:
* IDLE
* WALKING
* MINING
* BUILDING
* FARMING
* CHOPPING
* FISHING
* EXPLORING
The fake player should randomly switch between activities.
Example:
JOIN
→ WALKING
→ MINING
→ IDLE
→ EXPLORING
→ FARMING
→ WALKING
→ LEAVE
Activity selection must be configurable with weights/chances.
### Join / Leave System
Add configurable fake-player scheduling.
Example configuration:
min-online-players: 2
max-online-players: 8
join:
min-delay: 60
max-delay: 300
leave:
min-online-time: 300
max-online-time: 1800
Fake players should not all join at once.
Each fake player should have a randomized:
* Join delay
* Online duration
* Leave time
* Activity duration
When a fake player leaves, another fake player can join after a randomized delay.
### Commands
Add these commands:
/fakeplayer
/fakeplayer list
/fakeplayer spawn
/fakeplayer remove
/fakeplayer removeall
/fakeplayer activity
/fakeplayer follow
/fakeplayer stop
/fakeplayer reload
/fakeplayer info
Add permission nodes:
malabarfakeplayers.admin
malabarfakeplayers.spawn
malabarfakeplayers.remove
malabarfakeplayers.reload
### Configuration
Create a detailed `config.yml`.
It should contain:
* Maximum fake players
* Minimum fake players
* Join delays
* Leave delays
* Online duration
* Activity chances
* Activity durations
* Worlds where fake players are allowed
* Spawn locations
* Allowed blocks for mining
* Allowed blocks for building
* Farming settings
* Tree/chopping settings
* Fishing locations
* Dangerous blocks to avoid
* Whether fake players can take damage
* Whether fake players can die
* Whether fake players drop items
* Whether fake players count toward server player count
* Debug mode
Example:
fake-players:
min-online: 2
max-online: 8
schedule:
join-delay:
min: 60
max: 300
online-time:
min: 300
max: 1800
activities:
idle:
enabled: true
chance: 15
min-duration: 20
max-duration: 60
walking:
enabled: true
chance: 25
min-duration: 30
max-duration: 120
mining:
enabled: true
chance: 20
min-duration: 60
max-duration: 300
building:
enabled: true
chance: 10
min-duration: 60
max-duration: 300
farming:
enabled: true
chance: 15
min-duration: 60
max-duration: 240
chopping:
enabled: true
chance: 10
min-duration: 60
max-duration: 240
fishing:
enabled: true
chance: 5
min-duration: 60
max-duration: 300
### Important Technical Requirement
Do NOT implement fake players as simple ArmorStands or basic Citizens NPCs.
The goal is for them to appear as actual player-like entities to normal players.
Use an appropriate Paper-compatible player/NPC implementation for Minecraft 1.21.11.
If creating a true server-side fake `Player` entity is not possible with the Paper API alone, clearly explain the limitation and implement the closest stable solution using supported APIs/NMS while keeping the plugin maintainable.
Do not use unstable hacks unless absolutely necessary.
### Behavior
Make the fake players look human.
Add:
* Random reaction delays
* Random movement speed
* Random activity duration
* Random pauses
* Random head rotation
* Random camera movement
* Random path selection
* Occasional jumps
* Occasional sneaking
* Occasional inventory interaction
* Configurable interaction range
They should NOT:
* Move perfectly straight all the time.
* Perform actions every exact number of ticks.
* Teleport constantly.
* Spam block breaking.
* Instantly change direction.
* Behave identically.
### Safety
Fake players must:
* Avoid lava when possible.
* Avoid falling from high places.
* Avoid suffocation.
* Avoid repeatedly entering the same blocked location.
* Avoid breaking protected/claimed blocks if a protection plugin is detected.
Add hooks for common protection plugins where practical, such as WorldGuard.
### Persistence
Store fake-player configuration/state safely.
When the server restarts:
* Do not duplicate fake players.
* Restore the configured fake-player system.
* Start the join/leave scheduler again.
* Respect the configured minimum/maximum online count.
### Performance
The plugin must be optimized.
Do NOT run expensive world scans every tick.
Use:
* Scheduled tasks
* Cached nearby blocks
* Async calculations where safe
* Main thread only for Bukkit/Paper API operations that require it
* Efficient pathfinding
* Configurable AI update interval
The plugin should support at least **20 fake players** without causing significant TPS loss.
### Logging
Add useful debug messages such as:
[MalabarFakePlayers] Fake player Steve started MINING.
[MalabarFakePlayers] Fake player Alex started EXPLORING.
[MalabarFakePlayers] Fake player Steve will leave in 12 minutes.
Debug logging must be configurable.
### Code Quality
Use a clean package structure, for example:
com.malabar.fakeplayers
* MalabarFakePlayers.java
* command/
* player/
* ai/
* activities/
* scheduler/
* pathfinding/
* listener/
* configuration/
* storage/
* utility/
Use interfaces/classes where appropriate so new activities can easily be added later.
### Final Output
Provide:
1. Complete project structure.
2. Complete `pom.xml`.
3. Complete `plugin.yml`.
4. Complete `config.yml`.
5. Every Java source file.
6. Installation instructions.
7. Build instructions.
8. All commands and permissions.
9. Explanation of how the fake-player system works.
10. Explain exactly which parts use Paper API and which parts require NMS.
11. Make sure the code compiles for **Paper 1.21.11**.
Do not give pseudocode or incomplete sections. Generate the complete working plugin source code.
Build the Maven/Paper plugin scaffold and configuration.
Use Citizens for real player-model NPCs, then add scheduling, commands, and lightweight activity AI.
Document runtime requirements and the Paper API/NMS boundary.
Created the MalabarFakePlayers Maven project with plugin.yml, config.yml, persistence, commands, scheduling, and activity logic.
Implementation boundary: Citizens is required and supplies the player-model NPCs, skins, and navigation; this plugin adds its own scheduling and behavior on top. The plugin itself uses Paper/Bukkit APIs and does not call NMS directly. These NPCs are not logged-in players: they do not appear in the server’s actual online-player count, and the count-toward-player-count setting cannot change that.
Behavior notes: Mining, chopping, farming, and building use block events so compatible protection plugins can cancel edits. Farming and building are deliberately simple; fishing equips a rod and simulates fishing activity, but does not perform a real cast or catch. Skin availability depends on Citizens’ skin fetching. These are limitations of the implementation, not full player-client simulation.
Files created: pom.xml, src/main/resources/plugin.yml, src/main/resources/config.yml, and Java classes for the plugin, activities, player manager/agent, command, and safety listener.
Commands: /fakeplayer list, spawn <name>, remove <name>, removeall, activity <name> <activity>, follow <name> <player>, stop <name>, reload, and info <name>.
Permissions: malabarfakeplayers.admin, .spawn, .remove, and .reload (all default to operators).
Build and install: Use Compile in Kodari, then download the resulting jar. Install it alongside a Citizens version compatible with your Paper server, then restart. The POM targets Java 21 and Paper 1.21.11-R0.1-SNAPSHOT; I have not run a build here, so successful compilation depends on that Paper snapshot and the configured Citizens/XSeries artifacts being available.
package com.malabar.fakeplayers;
import com.malabar.fakeplayers.command.FakePlayerCommand;
import com.malabar.fakeplayers.listener.FakePlayerListener;
import com.malabar.fakeplayers.player.FakePlayerManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class MalabarFakePlayers extends JavaPlugin {
private FakePlayerManager fakePlayerManager;
@Override
public void onEnable() {
saveDefaultConfig();
if (Bukkit.getPluginManager().getPlugin("Citizens") == null) {
getLogger().severe("Citizens is required. Disabling MalabarFakePlayers.");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
fakePlayerManager = new FakePlayerManager(this);
fakePlayerManager.restore();
fakePlayerManager.start();
getServer().getPluginManager().registerEvents(new FakePlayerListener(fakePlayerManager, this), this);
FakePlayerCommand command = new FakePlayerCommand(this, fakePlayerManager);
getCommand("fakeplayer").setExecutor(command);
getCommand("fakeplayer").setTabCompleter(command);
}
@Override
public void onDisable() {
if (fakePlayerManager != null) {
fakePlayerManager.shutdown();
}
}
public FakePlayerManager getFakePlayerManager() {
return fakePlayerManager;
}
}