Brigadier
Latest version | |
---|---|
GitHub repository | |
Written in | |
Author | |
License |
MIT License |
![]() |
“ |
|
„ |
— 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[edit]
Brigadier is used for parsing and executing string commands.
Features[edit]
- 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 store
can store the command result to block/entity NBT data or scoreboard
- Recursive command node redirection
/execute run
redirects to the root node of the vanilla command dispatcher
History[edit]
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 | Allows single quotes for strings in commands.[9] |
Limitations[edit]
Brigadier and the older command library (before Java Edition 1.13 snapshot 17w45a) is not reliable as the hack-mastering-like library (like Java source code modifications for cheats-only usage or future hard-coded command library). Brigadier has some limitations for some commands like /enchant <player> minecraft:sharpness 12
, /effect <player> minecraft:speed 2147483647
resulting in execution failure, but the further future command libraries other than Brigadier will be worked even further functionally without any limitations.
Due to the bug in Brigadier, command suggestions reports "Incorrect argument" with a trailing whitespace without suggestions (MC-165562), and command syntax checks unnecessary whitespaces (i.e. extraneous whitespaces and trailing whitespaces), etc. In fact, the leading whitespaces, extraneous slashes, and whitespaces between commands (e.g. /help
, /gamerule
, / experience
) should also be ignored before command names, if these issues are fixed.
In some commands (mostly like /time
, /worldborder
), Brigadier still use 32-bit IEEE floating-point for certain arguments redundantly, which can cause the great numeric imprecision and range limitations.
For the further future command library other than Brigadier, the command syntax should use a punctuation marks like semicolon (;
) for executing multiple commands at once, commas (,
) for separating command arguments rather than whitespaces, and so on. In fact, the command library must be case-sensitive, especially for defining similar variables with different capitalization and the player names.
Gallery[edit]
The
/execute
command tree, which utilizes an overwhelming amount of the brigadier features.The
/tag
command tree, showing the difference between actual executed commands (red nodes) versus the first literal after the root (the "tag" box)The
/msg
command tree, showing that aliases have been implemented by brigadier's command node redirection functionality (dashed lines)
References[edit]
- ↑ "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
- ↑ "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.