Brigadier Commands
Brigadier is Mojang’s command parsing library used by Minecraft and Gate. This guide explains how to use Brigadier effectively.Command Nodes
Brigadier commands are built from nodes in a tree structure:Literal Nodes
Literal nodes match exact strings:Argument Nodes
Argument nodes parse typed values:Argument Types
Brigadier provides several built-in argument types:| Type | Description | Example |
|---|---|---|
Int | Integer number | 123, -45 |
Long | Long integer | 123456789 |
Float | Floating point | 3.14, -2.5 |
Double | Double precision | 3.14159 |
Bool | Boolean value | true, false |
StringWord | Single word | player1 |
StringPhrase | Quoted string | "hello world" |
GreedyString | Rest of input | Remaining text |
Building Command Trees
Sequential Arguments
Chain arguments withThen():
Branching Commands
Create multiple paths from a single node:Optional Arguments
Make arguments optional by adding multiple execution points:/teleport <target>- teleport yourself to target/teleport <target> <destination>- teleport target to destination
Suggestions
Provide tab completion suggestions:Contextual Suggestions
Provide different suggestions based on previous arguments:Redirects
Redirect one command to another:Error Handling
Brigadier provides built-in error types:Advanced Patterns
Parsing Custom Types
Create custom argument parsers:Best Practices
Command Structure
Command Structure
- Keep command trees shallow (max 3-4 levels)
- Use branching for subcommands instead of long chains
- Provide execution points at multiple levels for optional args
Suggestions
Suggestions
- Always filter suggestions based on partial input
- Limit suggestions to 20-30 items for performance
- Sort suggestions alphabetically for better UX
Argument Naming
Argument Naming
- Use descriptive argument names:
playernotp - Be consistent across commands
- Use snake_case for multi-word names:
max_players
Next Steps
Permissions
Add permission checks to commands
Examples
See complete command implementations

