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: victim and helper.
  • 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

  1. /kill reports damage source KILL, not GENERIC_KILL. Paper 1.21's last-damage-cause for the vanilla kill command is KILL — if your death listener filters on GENERIC_KILL it will never fire. I burned an hour on this.

  2. RCON responses don't include execute sub-command output. execute if block 0 65 0 chest run say FOUND prints FOUND to the server log, not the RCON response. Either read the log file, or use /data get block / /execute ... run return variants that do echo back.

  3. 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.

  4. Physics is async. Waiting fixed milliseconds is flaky on a loaded VM. Poll bot.entity.position/bot.entity.velocity until quiescent, with a timeout.

  5. The bots count as players. online-mode=false test server, obviously — but also remember player-idle-timeout and 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.