Skip to main content

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:

Building Command Trees

Sequential Arguments

Chain arguments with Then():

Branching Commands

Create multiple paths from a single node:

Optional Arguments

Make arguments optional by adding multiple execution points:
This creates:
  • /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:
Errors are automatically sent to the command source.

Advanced Patterns

Parsing Custom Types

Create custom argument parsers:

Best Practices

  • 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
  • Always filter suggestions based on partial input
  • Limit suggestions to 20-30 items for performance
  • Sort suggestions alphabetically for better UX
  • Use descriptive argument names: player not p
  • 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