[Brigadier] Document the command dispatcher
Nobody has claimed this yet.
- Dominant language
- MDX
- Stars
- 73
- Forks
- 280
- Avg merge
- 20h 52m
- Merged PRs (30d)
- 4
Description
[!NOTE]
This issue is part of a series of issues regarding the extension of the Paper documentation regarding Paper's Brigadier API.
The command dispatcher is retrievable using Commands#getDispatcher(). With it, one can query/modify/register commands. It can also just be used to work with the root command node in general.
All of its methods should be explained. An example on how to use most of them does not have to be given, since the usage of the dispatcher assumes a user to have general knowledge about the internal functionality of commands.
Though, an example for extending existing commands can be given. For this, one could extend a vanilla command to include their own sub command. Perhaps, this could be done for the /effect vanilla command:
final CommandDispatcher<CommandSourceStack> dispatcher = commands.getDispatcher();
if (dispatcher.getRoot().getChild("effect") instanceof LiteralCommandNode<CommandSourceStack> literalNode) {
dispatcher.register(literalNode.createBuilder().then(Commands.literal("clearall")
.executes(ctx -> {
Bukkit.getOnlinePlayers().forEach(Player::clearActivePotionEffects);
ctx.getSource().getSender().sendRichMessage("<gold>Successfully reset everyone's potion effects!");
return Command.SINGLE_SUCCESS;
})
));
}
[!WARNING]
I myself also haven't yet 100% figured out the dispatcher either. There might be a cleaner way to do what I did here. Iif so, please comment it on this issue 🚀
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Brigadier dispatcher entry point, Commands#getDispatcher(), and review the dispatcher methods and the provided Java example for extending the vanilla /effect command. Document what each dispatcher method does, including how commands can be queried, modified, and registered. Done means the dispatcher API is covered and an extension example is included where useful.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100