Server Agent

3files
1figure
6min read
Sheet 25 of 47 · Server

Filesplugins/IgniteTestAgent/config.yml · config.json · config.yml

Fileplugins/IgniteTestAgent/config.ymlFileconfig.jsonIgniteTestAgent is a small Paper and Folia plugin that answers what bots cannot see: health, velocity, PDC, effects, AI, blocks. It ships inside the tool jar, and every read runs on the thread that owns the entity, chunk or region, so it is safe on Folia.

Install

Any of these puts the agent in place:

WhereHow
WindowThe Install button on the Agent page
APIGET /server/install-agent?dir=<server>/plugins
CI--install-agent

Fileplugins/IgniteTestAgent/config.ymlThe agent listens on bind and port from plugins/IgniteTestAgent/config.yml. The default is 127.0.0.1:8768, so only the same machine reaches it until you change bind. It never runs without a token:

  • Fileplugins/IgniteTestAgent/config.ymlFileconfig.jsonAn install through the tool writes the tool's agentToken into plugins/IgniteTestAgent/config.yml. When the tool has no token yet it takes the one already in that config, or makes a new one, and saves it to config.json.
  • Fileconfig.ymlAn agent copied in by hand starts with an empty token. On its first start it writes a random one into its config.yml, so the token only shows up after that start. With agentToken empty the tool reads it from <serverDir>/plugins/IgniteTestAgent/config.yml on every call, so a local test server needs no setup. For a server on another machine, open that file after the first start and paste the token into Settings > Agent token.
  • Requests with an Origin header are refused, the token is compared in constant time, and exec waits at most 30 s.

Remote server

For a test server on another machine, where the tool cannot write into plugins/ itself.

1. Get the jar. In the next update the tool can hand you the jar directly: Save agent jar... on the Agent page, GET /server/agent-jar, or --export-agent <dir> on the command line. Until then, set Settings > Server folder to a local folder (a mounted SFTP drive, a synced copy, or any empty folder), press Install on the Agent page and take plugins/IgniteTestAgent.jar from there.

Fileplugins/IgniteTestAgent/config.yml2. Upload and start once. Put the jar into plugins/ on the server and start it. The agent writes its token into plugins/IgniteTestAgent/config.yml.

3. Copy the token. Paste it into Settings > Agent token, or pass --agent-token in CI.

4. Connect. Pick one:

WayOn the serverIn the tool
SSH tunnel (recommended)Keep bind: 127.0.0.1. On your machine run ssh -N -L 8768:127.0.0.1:8768 user@host and leave it openAgent address stays http://127.0.0.1:8768
Open portSet bind: 0.0.0.0, restart, and firewall port 8768 so only your IP gets inAgent address (--agent-url in CI) is http://host:8768

No agent? RCON still runs console commands. Reads like player, entities or events need the agent.

Endpoints

Everything goes through the tool as /server/<endpoint> with the same parameters, from the command line as call server/<endpoint>, and in scenarios as a server or assertServer step.

EndpointParametersReturns
pingAgent, server and Minecraft version, Folia or not, players, plugins
entityplayer=, uuid= or id= (the id bots see), near=<player>, r=64Position, velocity, onGround, health, max health, attributes, effects, AI, target, tags, PDC
entitiesnear=<player>, r=16, type=The same for everything around a player
playerplayer=The entity view plus game mode, allowFlight, flying, sneaking, sprinting, food, level, held slot and the inventory with names, lore, PDC and components
entity/setThe lookup, then health, maxHealth, vx, vy, vz, ai=0/1, clearEffects=1, remove=1The entity after the change
dummytype=zombie, near=<player> with dx, dy, dz or world, x, y, z, health=20, ai=0, nameSpawns a target with known health that stands still, tagged itt_dummy
dummy/clearRemoves every dummy this agent spawned
blockworld, x, y, zThe block the server holds, with its full data. A block entity adds state: its PDC, a container's items and custom name, a sign's front and back lines, a spawner's mob and delay, a skull's owner
snapshot, restorename, world, x1 to z2 / nameSaves a box of blocks and puts it back later, chunk by chunk on the region that owns it
execcmd, wait=100Runs a console command and returns what it printed
tickaction=freeze,unfreeze,step,rate,status, ticks, rateThe server tick manager
healthTPS and MSPT, per region on Folia
commandsplugin=Every registered command once, with its plugin, aliases and permission. ACF aliases are folded into one entry
player/resetplayer=, keep=inventory,effects,xp,gamemodeThe player as if it never played: health, hunger, air and fire reset, inventory, effects and levels gone, default game mode. What fresh: true on a join calls
events/watchtype=PlayerInteractEvent,BlockBreakEventStarts recording those Bukkit events. A short name is looked up in the Bukkit and Paper event packages, a plugin's own event takes its full class name. Answers mark, the number of the last event so far
eventssince=<mark>, type=, player=, n=200The recorded events after a mark, each with type, cancelled, async and what its getters say: player, action, block, item, hand and so on. Also mark for the next call
events/clearStops recording and forgets everything
placeholdertext=%plugin_value%, player=The text with PlaceholderAPI placeholders filled in
permissionplayer=, node= or prefix=has and set for one node, or every effective permission under a prefix as nodes
inspectplugin=, path=What a plugin holds in memory, read by path from its main class

The agent also answers sql and invoke. See Databases & Plugin Calls.

Reading plugin memory with inspect

inspect walks getters and fields by name. path=arenaService.arenas[IttArena].state calls getArenaService() or reads the field arenaService, takes the entry IttArena of the map (a player name finds a UUID key), then state. [3] picks from a list, .size counts.

ResultComes back as
A plain valueAs it is
A list or mapIts size and first entries
Any other objectIts class and fields one level deep
A name that does not existA list of what the object has
No pathThe plugin itself, which is where to start

It reads only, and replaces the helper plugin a suite would otherwise carry for looking at internal state. type= starts at the static side of a class.

Checking events

Events answer the question a bot cannot: did the plugin's own event fire, was it cancelled, how often.

- {do: server, path: events/watch, type: "BlockPlaceEvent,com.example.shop.ShopBuyEvent", as: mark, field: mark}
- {do: action, action: place, x: "~1", y: "~-1", z: "~"}
- {do: assertServer, path: events, since: "${mark}", type: BlockPlaceEvent, field: "events[0].cancelled", value: true, timeout: 2000}
- {do: assertServer, path: events, since: "${mark}", type: ShopBuyEvent, field: events.size, value: 0}

RCON

Fileconfig.json/rcon?c=<command> runs a command over RCON, for servers the tool did not start. Set rconHost, rconPort and rconPassword in Settings or config.json. A command waits rconTimeoutSeconds (5) for the connect and the answer. An answer longer than one 4096 character packet is read to its end.

The Agent page

The Agent page shows the same without writing URLs: the player and entities around, TPS, clearing dummies, an RCON console and one-click install.

Keep one reply as A, do something in game, fetch again as B and diff them. You get every changed, added or removed path, for example inventory[1].pdc.lightfall:item. POST /state/diff with {"before": ..., "after": ..., "ignore": ["yaw"]} does the same over HTTP.

The Agent page: state, A/B diff and RCON in one place.
The Agent page with player and entity state, the A/B diff, the RCON console and the install key

On Folia

exec runs on the global region, so commands that read a region (execute if block) fail there; block and entity cover those checks. Tick control freezes every region, so unfreeze before the next scenario.

Loading the index

Enter openUp Down moveEsc close