Class CommandDispatcher
java.lang.Object
net.minestom.server.command.builder.CommandDispatcher
Class responsible for parsing
Command
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull CommandResult
execute
(@NotNull CommandSender source, @NotNull String commandString) Checks if the command exists, and execute it.@Nullable Command
findCommand
(@NotNull String commandName) Gets the command class associated with the name.@NotNull CommandResult
parse
(@NotNull CommandSender sender, @NotNull String commandString) Parses the given command.void
Registers a command, be aware that registering a command name or alias will override the previous entry.void
unregister
(@NotNull Command command)
-
Constructor Details
-
CommandDispatcher
-
CommandDispatcher
public CommandDispatcher()
-
-
Method Details
-
register
Registers a command, be aware that registering a command name or alias will override the previous entry.- Parameters:
command
- the command to register
-
unregister
-
getCommands
-
findCommand
Gets the command class associated with the name.- Parameters:
commandName
- the command name- Returns:
- the
Command
associated with the name, null if not any
-
execute
@NotNull public @NotNull CommandResult execute(@NotNull @NotNull CommandSender source, @NotNull @NotNull String commandString) Checks if the command exists, and execute it.- Parameters:
source
- the command sourcecommandString
- the command with the argument(s)- Returns:
- the command result
-
parse
@NotNull public @NotNull CommandResult parse(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String commandString) Parses the given command.- Parameters:
commandString
- the command (containing the command name and the args if any)- Returns:
- the parsing result
-