Skip to main content
Paper provides multiple ways to create commands. The modern approach uses the BasicCommand interface and programmatic registration, while legacy plugins can still use the Command class.
Paper plugins using paper-plugin.yml cannot declare commands in YAML. You must register commands programmatically using JavaPlugin.registerCommand().
The BasicCommand interface provides a simple, Bukkit-style approach to creating commands.

Creating a BasicCommand

From io.papermc.paper.command.brigadier.BasicCommand:
1

Implement BasicCommand

Create a class implementing BasicCommand:
2

Register the Command

Register your command in the plugin’s onEnable() method:
From JavaPlugin.java:374-436, the registerCommand() methods:

CommandSourceStack

The CommandSourceStack (package: io.papermc.paper.command.brigadier.CommandSourceStack) provides context for command execution:
Usage example:

Command Class (Legacy)

For advanced use cases, you can extend the Command class directly.

Creating a Command

From org.bukkit.command.Command:
Example:

Tab Completion

Provide suggestions for command arguments:

BasicCommand Tab Completion

Dynamic Tab Completion

Permission Checking

BasicCommand Permissions

Command Class Permissions

From org.bukkit.command.Command:175-225:

Command Aliases

Register multiple aliases for a command:
Aliases will not override already existing commands (except namespaced ones). The main command label will override existing commands.

Subcommands

Implement subcommands by parsing the first argument:

Lifecycle Event Registration

Alternatively, register commands via lifecycle events:

Best Practices

  1. Validate input:
  2. Check sender type:
  3. Use permissions:
  4. Provide tab completion:
  5. Handle errors gracefully:
Do not call getCommand() in onEnable() for Paper plugins. Use registerCommand() instead.