Brigadier
| Author(s) | |
|---|---|
| Platform(s) |
? |
| Written in | |
| Latest version | |
| Release date |
? |
| Size |
? |
| License |
MIT License |
| Source available |
{
"title": "Brigadier",
"rows": [
{
"field": "(link to File:Mojang Studios logo.svg article, displayed as x20px|link=Mojang Studios) (link to Mojang Studios article, displayed as Mojang Studios)",
"label": "Author(s)"
},
{
"field": "?",
"label": "Platform(s)"
},
{
"field": "(link to wikipedia:Java (programming language) article, displayed as Java)",
"label": "Written in"
},
{
"field": "[https://github.com/Mojang/brigadier/releases/latest 1.0.18]",
"label": "Latest version"
},
{
"field": "?",
"label": "Release date"
},
{
"field": "?",
"label": "Size"
},
{
"field": "MIT License",
"label": "License"
},
{
"field": "[https://github.com/Mojang/brigadier/ Yes]",
"label": "<span style=\"white-space:normal\">Source available</span>"
}
],
"invimages": [],
"images": []
}
|
“ |
|
„ |
| — Dinnerbone on Brigadier[1] |
Brigadier is a command parser and dispatcher, designed and developed for Java Edition,[2] mainly maintained by Dinnerbone.[3] It is the first library used by Java Edition that Mojang has released under an open-source license.[4]
Usage
Brigadier is used for parsing and executing string commands.
Features
- Define command nodes with argument or literal branches
- All the commands available in Java Edition are actually the literal branches available for the root command nodes instead of the actual executed commands.[5]
- Modify/fork command source in command contexts
/execute as <target selector>may modify the command source to be multiple when multiple entities are selected
- Active inspection on command parsing[6]
- Listing all possible commands from current command node[7]
- Handle command result real-time on execution success/failure
/execute storecan store the command result to block/entity NBT data or scoreboard
- Recursive command node redirection
/execute runredirects to the root node of the vanilla command dispatcher
Limitations and issues
Brigadier has various numbers of limitations while executing the command, such as the numeric limitations on integer data types such as /effect, /weather, and floating-point data types such as /time, making many integer values parsed in the commands inaccessible.
Minecraft argument types
More general documentation on brigadier and its use can be found at the github repository, however this is information specifically on the argument types added and used in Minecraft. While basic implementation of commands may vary by mod loader, these argument types are mostly consistent. Your chosen mod loader probably has its own documentation for how to actually register commands using Brigadier.
| Class name | Description | Example | |
|---|---|---|---|
Commands.literal
|
A fixed keyword that must be typed exactly. | /datapack list
|
|
StringArgumentType.greedyString
|
Will match the longest possible string of letters (only works at the very end of a command). | /say all of this will be in the greedy string
|
|
StringArgumentType.word
|
Will match the longest string of letters without spaces. | /tag @s add oneword
|
|
StringArgumentType.string
|
Will match the longest string of letters without spaces, unless surrounded by quotation marks. Similar to greedyString, but can have more arguments afterwards.
|
/datapack enable "multiple words" last
|
|
BoolArgumentType.bool
|
Can only be true or false.
|
/gamerule keepInventory true
|
|
IntegerArgumentType.integer
|
A Java int. Must be a whole number. This argument can optionally have a minimum value, or a minimum and maximum value.
|
/scoreboard players set @s objective 100
|
|
LongArgumentType.longArg
|
A Java long. Must be a whole number. Similar to int, but can store much larger numbers. This argument can optionally have a minimum value, or a minimum and maximum value.
|
Not used in any commands | |
FloatArgumentType.floatArg
|
A Java float (6 digits of precision). Can have decimals. This argument can optionally have a minimum value, or a minimum and maximum value.
|
/playsound minecraft:ambient.cave master @s ~ ~ ~ 1.23456
|
|
DoubleArgumentType.doubleArg
|
A Java double (15 digits of precision). Can have decimals. This argument can optionally have a minimum value, or a minimum and maximum value.
|
/attribute @s minecraft:generic.movement_speed base set 12.345678912345
|
(See more about Java ints, longs, floats and doubles here)
History
| October 25, 2014 | Dinnerbone mentions Brigadier in the comments on MC-10880. | ||||||
|---|---|---|---|---|---|---|---|
| July 27, 2017 | Dinnerbone discloses a non-obfuscated command parser library called "brigadier". | ||||||
| Java Edition | |||||||
| 1.13 | 17w45a | Commands are now handled with Brigadier. | |||||
| Minecraft introduces Brigadier as a dependency. | |||||||
| September 26, 2018 | Brigadier is open sourced under the MIT License.[8] | ||||||
| 1.14 | 19w08a | Now allows single quotes for strings in commands.[9] | |||||
Version history
| Version | Date | Changes |
|---|---|---|
| 1.0.15 | September 26, 2018[10] |
|
| 1.0.17 | February 19, 2019[11] |
|
| 1.0.18 | July 16, 2021[12] |
|
Gallery
-
The
/executecommand tree, which utilizes an overwhelming amount of the brigadier features. -
The
/tagcommand tree, showing the difference between actual executed commands (red nodes) versus the first literal after the root (the "tag" box) -
The
/msgcommand tree, showing that aliases have been implemented by brigadier's command node redirection functionality (dashed lines)
References
- ↑ "Programmers: Play with Minecraft's Inner Workings!" – Minecraft.net.
- ↑ "Mojang/brigadier: Brigadier is a command parser & dispatcher, designed and developed for Minecraft: Java Edition." – GitHub.
- ↑ "Contributors to Mojang/brigadier" – GitHub.
- ↑ "We just pulled in our very first community contributed code into a Minecraft Java Edition official library. Woo! 🎉 Want to help out? The first library we've opened is our command engine - it's MIT licensed so you can freely use it in your own projects!" – @Dinnerbone (Nathan Adams) on X (formerly Twitter), September 26, 2018
- ↑ "Added copyright header, LICENSE, and README.md by Dinnerbone · Pull Request #8 · Mojang/brigadier" by boq – Mojang/brigadier – GitHub. "I'd argue that most people identify command by first literal after root, so that would make "command" a sub-tree and not just path leading to leaf node. /bikeshedding"
- ↑ "Inspecting a command" – Mojang/brigadier – GitHub.
- ↑ "Displaying usage info" – Mojang/brigadier – GitHub.
- ↑ "Preparation for OSS :)" - Preparing for the open source software – Mojang/brigadier – GitHub
- ↑ "Allow single quote in strings by boq · Pull Request #52" – Mojang/brigadier – GitHub.
- ↑ "Release 1.0.15 · Mojang/brigadier" – GitHub.
- ↑ "Release 1.0.17 · Mojang/brigadier" – GitHub.
- ↑ "Release 1.0.18 · Mojang/brigadier" – GitHub.
| |||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
