CommandAPI 9.7.0
An API for the command UI introduced in Minecraft 1.13
|
The Brigadier class is used to access some of the internals of the CommandAPI so you can use the CommandAPI alongside Mojang's com.mojang.brigadier package. More...
Static Public Member Functions | |
static CommandDispatcher | getCommandDispatcher () |
Returns the Brigadier CommandDispatcher tree that is used internally by the CommandAPI. More... | |
static RootCommandNode | getRootNode () |
Returns the root node of the current CommandDispatcher. More... | |
static< CommandSender, Argument extends AbstractArgument< String, ?, ?, CommandSender > LiteralArgumentBuilder | fromLiteralArgument (Literal< Argument > literalArgument) |
Creates a new literal argument builder from a CommandAPI LiteralArgument. More... | |
static< CommandSender, Argument extends AbstractArgument<?, ?, Argument, CommandSender > RedirectModifier | fromPredicate (BiPredicate< CommandSender, Object[]> predicate, List< Argument > args) |
Constructs a RedirectModifier from a predicate that uses a command sender and some arguments. More... | |
static< Argument extends AbstractArgument<?, ?, Argument, CommandSender > CommandSender Command | fromCommand (AbstractCommandAPICommand<?, Argument, CommandSender > command) |
static< Argument extends AbstractArgument<?, ?, Argument, ?> RequiredArgumentBuilder | fromArgument (List< Argument > args, Argument argument) |
Constructs a RequiredArgumentBuilder from a given argument within a command declaration. More... | |
static< Argument extends AbstractArgument<?, ?, Argument, ?> RequiredArgumentBuilder | fromArgument (Argument argument) |
Constructs a RequiredArgumentBuilder from a given argument. More... | |
static< Argument extends AbstractArgument<?, ?, Argument, ?> SuggestionProvider | toSuggestions (Argument argument, List< Argument > args) |
Converts an argument and a list of arguments to a Brigadier SuggestionProvider. More... | |
static< Argument extends AbstractArgument<?, ?, Argument, ?> Object[] | parseArguments (CommandContext cmdCtx, List< Argument > args) throws CommandSyntaxException |
Parses arguments into their respective objects with a given command context. More... | |
static< CommandSender > Object | getBrigadierSourceFromCommandSender (CommandSender sender) |
Gets a Brigadier source object (e.g. More... | |
static< CommandSender > CommandSender | getCommandSenderFromContext (CommandContext cmdCtx) |
Returns a Bukkit CommandSender from a Brigadier CommandContext. More... | |
The Brigadier class is used to access some of the internals of the CommandAPI so you can use the CommandAPI alongside Mojang's com.mojang.brigadier package.
|
static |
Constructs a RequiredArgumentBuilder from a given argument.
argument | the argument to create a RequiredArgumentBuilder from |
|
static |
Constructs a RequiredArgumentBuilder from a given argument within a command declaration.
For example:
List<Argument> arguments = new ArrayList<>(); arguments.add(new IntegerArgument("hello")); RequiredArgumentBuilder argBuilder = Brigadier.fromArguments(arguments, "hello");
args | the List of arguments which you typically declare for commands |
argument | the argument you want to specify |
|
static |
Creates a new literal argument builder from a CommandAPI LiteralArgument.
literalArgument | the LiteralArgument to convert from |
|
static |
Constructs a RedirectModifier from a predicate that uses a command sender and some arguments.
RedirectModifiers can be used with Brigadier's fork()
method to invoke other nodes in the CommandDispatcher tree. You would use this method as shown:
Brigadier.fromPredicate((sender, args) -> { ... }, arguments);
predicate | the predicate to test |
args | the arguments that the sender has filled in |
|
static |
Gets a Brigadier source object (e.g.
CommandListenerWrapper or CommandSourceStack) from a Bukkit CommandSender. This source object is the same object you would get from a command context.
sender | the Bukkit CommandSender to convert into a Brigadier source object |
|
static |
Returns the Brigadier CommandDispatcher tree that is used internally by the CommandAPI.
Modifying this CommandDispatcher tree before the server finishes loading will still keep any changes made to it. For example, adding a new node to this tree will keep the node once the server has finished loading.
|
static |
|
static |
Returns the root node of the current CommandDispatcher.
This is the equivalent of running
Brigadier.getCommandDispatcher().getRoot();
|
static |
Parses arguments into their respective objects with a given command context.
This method effectively performs the "parse" step in an argument's class and returns an Object[] which maps directly to the input List with the values generated via parsing.
cmdCtx | the command context used to parse the command arguments |
args | the list of arguments to parse |
CommandSyntaxException | if there was an error during parsing |
|
static |
Converts an argument and a list of arguments to a Brigadier SuggestionProvider.
argument | the argument to convert to suggestions |
args | the list of arguments |