Most Minecraft plugin "testing" is: install the jar, join with your client, punch things, eyeball it. That doesn't scale when your plugin's whole job is managing death states — you need two clients, deterministic damage, and assertions on things that happen in the world after a player dies.
Here's the setup I use to e2e-test Paper plugins on a headless VM: mineflayer bots + RCON.
The pieces
# Paper server (test instance, separate dir) java -jar paper-1.21.4.jar --nogui - mineflayer (Node.js) — headless Minecraft clients. Two bots:
victimandhelper. - RCON — server console over TCP. The only reliable way to apply real damage (
/damage), teleport, and set gamemode. - Assertions: check player state via mineflayer (
entity.health,bot.game.gameMode), and world state via RCON (/execute if block,/data get).
Gotchas that will waste your day
/killreports damage sourceKILL, notGENERIC_KILL. Paper 1.21's last-damage-cause for the vanilla kill command isKILL— if your death listener filters onGENERIC_KILLit will never fire. I burned an hour on this.RCON responses don't include
executesub-command output.execute if block 0 65 0 chest run say FOUNDprintsFOUNDto the server log, not the RCON response. Either read the log file, or use/data get block//execute ... run returnvariants that do echo back.A dead bot respawns at spawn — and the death chunk unloads. If you assert "is there a chest at the death point" after respawning, the chunk may already be unloaded. Keep a "spy" bot parked at the death location holding the chunk open.
Physics is async. Waiting fixed milliseconds is flaky on a loaded VM. Poll
bot.entity.position/bot.entity.velocityuntil quiescent, with a timeout.The bots count as players.
online-mode=falsetest server, obviously — but also rememberplayer-idle-timeoutand per-player plugins (death chests keyed to UUID!) see the bot's UUID, so give each bot a distinct name.
Example: asserting a grave spawned
// victim dies at a known spot; spy bot watches the chunk await rcon(`execute positioned ${x} ${y} ${z} run kill @p[name=victim]`); await sleep(1500); // from spy bot held at the location: const block = spy.blockAt(new Vec3(x, y, z)); assert(block.name === 'chest', `expected chest, got ${block.name}`); That's it. Headless, repeatable, runs in CI. The full harness I use is ~300 lines of Node.
Built while developing SecondWind (DBNO revives — https://github.com/SecondWindMC/SecondWindRevive) and GraveGuard (death chests — https://github.com/SecondWindMC/GraveGuard). Both MIT-licensed Paper 1.21.x plugins.