paper-dispatch
Declarative command framework for Paper β Brigadier without hand-building command trees.
A Maven library for PaperMC plugins that wraps Brigadier in a declarative command API: nested sub-commands, typed arguments, GNU-style flags and permission requirements, without hand-building command trees.
| Server software | Supported | Minecraft |
|---|---|---|
| Paper | β | Built against paper-api 26.1.2 |
| Spigot | β | β |
| Bukkit | β | β |
| Folia | β | β |
These docs describe 1.0.3, which is not released yet
The current release is 1.0.2, and the API differs. trackCommand,
flushRegistrations, getSenderAsPlayer and resolvePlayer β used throughout
these pages β do not exist in 1.0.2; there it is registerCommand,
registerCommands and getPlayer().
The dependency snippets still show 1.0.2, because that is what resolves today. See Migrating for the mapping.
What you write
public class HealCommand extends BaseCommand<MyPlugin> {
public HealCommand(MyPlugin plugin) {
super(plugin, "heal", "h");
this.setPermission("myplugin.heal");
this.addOptionalArgument("target", ArgumentTypes.player());
this.addFlag(Flags.boolFlag("silent").alias("s"));
}
@Override
protected CommandResultType perform(CommandDispatch<MyPlugin> dispatch) {
Player target = dispatch.resolvePlayer("target")
.orElse(dispatch.getSenderAsPlayer());
target.setHealth(20.0);
return CommandResultType.SUCCESS;
}
}/heal Notch -s β no Brigadier node assembly anywhere.
Modules
| Module | Contents |
|---|---|
Lib-API | Public API interfaces and abstractions |
paper-dispatch | Full implementation, includes Lib-API |
Depend on paper-dispatch unless you specifically want to compile against the
interfaces alone.
Paper only
This is not a Bukkit library. It compiles against paper-api and uses Paper's
Commands / Brigadier API, PluginBootstrap and paper-plugin.yml β none of
which exist on Spigot or Bukkit. There is no Spigot fallback.
Where to go
| You want to⦠| Go to |
|---|---|
| Add it to your build | Add the dependency |
| Bundle it without breaking others | Shading & relocation |
| Register your first command | Core concepts |
Nest /guild create style trees | Sub-commands |
| Gate a command by permission | Requirements |
| Complete offline player names | Offline player cache |
| Tell arguments from flags apart | Arguments |
| Look up the flag API | Flags |
| Find a class or package | Modules |
| Read generated Javadoc | Javadoc |
| Fix something that is not working | Troubleshooting |
| Ask a question you had first | FAQ |
Known limitation: no bootstrap registration
Paper lets you register commands from a PluginBootstrap, which is its
preferred path for paper-plugin.yml plugins and the only way commands
become available to datapack command functions. paper-dispatch does not support
that today.
The blocker is ordering: PluginBootstrap#bootstrap runs before createPlugin,
so no plugin instance exists yet β while BaseCommand<T extends Plugin>
requires one at construction.
If you need datapack function parsing, register those commands directly against
context.getLifecycleManager() in your bootstrap and use this library for
everything else.
Last updated on