Hook points
Commands: command.<root>
Every command the game registers, and the few this server adds (plugins, raid, cookie),
is a hook point named for its root: command.time, command.give, command.ban-ip. Aliases
are separate roots, just as they are in the game's own command tree: tp and teleport,
xp and experience, msg, tell and w.
| Shape | |
|---|---|
| Input | {"player": 7, "name": "time", "rest": "set day"}: who typed it (the player who typed the line, under /execute too; -1 for the console, a command block or a datapack), the root, and the rest of the line, unparsed |
| Output | true if the command succeeded, false if it failed |
The output is what /execute store success, a command block's comparator and a function's
return all read.
What each mode does
- prepend: rewrite the name or the arguments. The rewritten command is checked for permission, so a prepend cannot be used to run something the sender may not.
- override: answer success or failure yourself. The game's command does not run, and nothing is sent to the sender unless you send it with a host call.
- append: change the success the caller sees.
Where it sits
The point runs once the line has been split into a name and the rest, and once the
per-line command budget (max_command_sequence_length) has been charged. It wraps everything
after that: this server's extra-command switch, the permission check, the command_run
event, and the command itself. /stop asks for a shutdown that happens after the point has
returned, so an append on command.stop still runs.
The point name is formatted from whatever root was typed, so a plugin's own commands and even an
unknown root (command.nosuchthing) pass through it as well. The generated index
lists the roots the game and this server register (the command tree's roots and BUILT_IN),
which is what tools/api_check.py counts.
Source: run_within_at in crates/rustmc-server/src/commands.rs; the input is CommandHook
(commands.rs:1547-1555).
From docs/api/reference/hooks/commands.md in the RustMC repository at bbd81209ad.