Commands¶
All mode commands switch gamemodes with vanilla selectors. An omitted
target means yourself; console must always name one. Every switch needs
jgamemode.use, plus the scope (jgamemode.self or jgamemode.other)
and the mode (jgamemode.use.<mode>) permissions.
| Command | Description | Permission |
|---|---|---|
/gm [<mode>\|toggle] [targets] |
Set gamemode, or toggle without a mode. | jgamemode.use |
/gms [targets] |
Switch to survival. | jgamemode.use |
/gmc [targets] |
Switch to creative. | jgamemode.use |
/gma [targets] |
Switch to adventure. | jgamemode.use |
/gmsp [targets] |
Switch to spectator. | jgamemode.use |
/gmt [targets] |
Toggle spectator and back. | jgamemode.use |
/t [targets] |
Toggle spectator and back (native root). | jgamemode.use |
/gm0\|/gm1\|/gm2\|/gm3 [targets] |
Switch directly by numeric id. | jgamemode.use |
/gamemode [<mode>\|toggle] [targets] |
Vanilla gamemode through this plugin. | jgamemode.use |
/jgamemode <help\|version\|reload> |
Help, version, and config reload (aliases /jgm, /jg). |
— |
The single-letter roots /s, /c, /a and /sp switch directly when
their label is free (see configuration.md).
- Modes are matched dynamically: full names (
survival), shorthands (s,c,a,sp), numbers (0-3) and any substring (creatworks out to creative, first match wins). Gibberish errors out. - Toggle (
/gm,/gmt,/t,/gm toggle) swaps between spectator and the last non-spectator mode, mirroring vanilla F3+N: leaving for spectator caches where you came from, coming back never overwrites the ticket. Spectators without history fall back to creative, then survival, then adventure, by permission. - History is stored per player in the database (only this plugin's switches count) and survives restarts. Switching directly to spectator never overrides a stored ticket, but seeds an empty cache so the next toggle has somewhere to go.
Direct examples: /gmc, /gm sp Steve, /gm tog @a, /gamemode 1.
Adding a Command¶
- Create a command class in a new subpackage of
core.commands(e.g.core.commands.user.fun) that builds a Brigadier node withCommands.literal(...), gates it withrequires(), and runs its logic inexecutes(...). - Attach the node to the root in the matching registrar
(
UserCommandsRegistrarorAdminCommandsRegistrar) withroot.then(new MyCommand(...).node()), injecting only the services it needs (commonlyCommandContext). - Declare the permission in
paper-plugin.yml(with a constant inGameModePermissions), document it in permissions.md and add aHelpEntryso the command shows up in/jgamemode help.
See api.md for the full walkthrough.