Add a command
Wire up a working command with tab completion and permissions, matching the project's stack and
conventions. Follow the collaborative rule: propose the design, show the code, then write after
the user approves.
Phase 1: Load context
- Read
.mcplugin/config.yml for platform, mc_version, version_scheme, package,
main_class, plugin_name. If it's missing, tell the user to run /setup-platform (and
/scaffold) first.
- Read the command reference and pitfalls (relative to this skill;
Glob as fallback):
../../references/api/commands.md — command systems, tab completion, argument patterns
../../references/pitfalls.md — the "Commands" section
- Look at existing source to match style:
Glob src/main/java/**/*.java, read the main class
and any existing command classes.
Phase 2: Clarify the command
Ask (AskUserQuestion or plain text) only what you can't infer from the argument/description:
- Name + aliases (e.g.
warp, aliases w).
- What it does and its arguments (e.g.
/warp <name>, /warp set <name>). Note which
args need tab completion.
- Who can run it — a permission node (default
<pluginname>.<command>) and default
(op/true/false), and whether it's player-only or also console/command-block.
Phase 3: Choose the command system
Decide from the stack (explain the pick briefly):
- Classic
plugin.yml + CommandExecutor/TabCompleter — universal, works everywhere,
simplest. Default choice.
- Paper Brigadier (
Commands / lifecycle API) — only on Paper 1.20.6+ and when the user
wants typed arguments, suggestions, or nested subcommands with real parsing. Use the details
in commands.md; don't guess the API surface.
Phase 4: Implement
Generate, in the project's package:
- A command class implementing the executor (and tab completer) with:
args.length checks before indexing; helpful usage message on bad input.
sender instanceof Player check before casting when player-only; a clear message otherwise.
- Permission checks via the declared node.
- Tab completion returning context-appropriate, filtered suggestions (match the current token).
- Register it: add the command block to
plugin.yml (name, description, usage, permission,
aliases) and the permission node; in the main class onEnable, set the executor —
guarding the getCommand("x") result against null (it's null if the name isn't in
plugin.yml).
Show the new/edited files (the command class, the plugin.yml diff, the onEnable diff) and
get approval before writing.
Phase 5: Verify + hand off
- Re-check the pitfalls: command declared in
plugin.yml, executor set, null-guarded, args
validated, sender type handled, permission consistent between code and plugin.yml.
- Suggest next steps: "
/build to compile, then /run-server to try /{command} in game."
Do not fabricate APIs for a Minecraft version newer than ../../references/api/VERSION.md
documents — if unsure the method exists in the target version, say so and verify.
1---2name: add-command3description: Add a command to a Minecraft plugin — the executor class, tab completion, plugin.yml registration, permissions, and wiring in onEnable. Use this whenever the user wants a new /command, slash command, subcommands, argument parsing, or tab completion in their Bukkit/Paper/Spigot plugin. Reads the target stack from .mcplugin/config.yml.4---56# Add a command78Wire up a working command with tab completion and permissions, matching the project's stack and9conventions. Follow the collaborative rule: propose the design, show the code, then write after10the user approves.1112## Phase 1: Load context1314- Read `.mcplugin/config.yml` for `platform`, `mc_version`, `version_scheme`, `package`,15 `main_class`, `plugin_name`. If it's missing, tell the user to run `/setup-platform` (and16 `/scaffold`) first.17- Read the command reference and pitfalls (relative to this skill; `Glob` as fallback):18 - `../../references/api/commands.md` — command systems, tab completion, argument patterns19 - `../../references/pitfalls.md` — the "Commands" section20- Look at existing source to match style: `Glob` `src/main/java/**/*.java`, read the main class21 and any existing command classes.2223## Phase 2: Clarify the command2425Ask (AskUserQuestion or plain text) only what you can't infer from the argument/description:26- **Name + aliases** (e.g. `warp`, aliases `w`).27- **What it does** and its **arguments** (e.g. `/warp <name>`, `/warp set <name>`). Note which28 args need tab completion.29- **Who can run it** — a permission node (default `<pluginname>.<command>`) and default30 (`op`/`true`/`false`), and whether it's player-only or also console/command-block.3132## Phase 3: Choose the command system3334Decide from the stack (explain the pick briefly):35- **Classic `plugin.yml` + `CommandExecutor`/`TabCompleter`** — universal, works everywhere,36 simplest. Default choice.37- **Paper Brigadier (`Commands` / lifecycle API)** — only on Paper 1.20.6+ and when the user38 wants typed arguments, suggestions, or nested subcommands with real parsing. Use the details39 in `commands.md`; don't guess the API surface.4041## Phase 4: Implement4243Generate, in the project's package:441. A command class implementing the executor (and tab completer) with:45 - `args.length` checks before indexing; helpful usage message on bad input.46 - `sender instanceof Player` check before casting when player-only; a clear message otherwise.47 - Permission checks via the declared node.48 - Tab completion returning context-appropriate, filtered suggestions (match the current token).492. **Register it**: add the command block to `plugin.yml` (name, description, usage, permission,50 aliases) and the permission node; in the main class `onEnable`, set the executor —51 guarding the `getCommand("x")` result against null (it's null if the name isn't in52 `plugin.yml`).5354Show the new/edited files (the command class, the `plugin.yml` diff, the `onEnable` diff) and55get approval before writing.5657## Phase 5: Verify + hand off5859- Re-check the pitfalls: command declared in `plugin.yml`, executor set, null-guarded, args60 validated, sender type handled, permission consistent between code and `plugin.yml`.61- Suggest next steps: "`/build` to compile, then `/run-server` to try `/{command}` in game."6263Do not fabricate APIs for a Minecraft version newer than `../../references/api/VERSION.md`64documents — if unsure the method exists in the target version, say so and verify.