Interface CommandRegistry
public interface CommandRegistry
Handles the registration and execution of commands.
-
Method Summary
Modifier and TypeMethodDescriptiondispatchAsync(CommandSource source, String cmdLine) Attempts to asynchronously execute a command from the givencmdLine.booleanhasCommand(String alias) Returns whether the given alias is registered on this manager.booleanhasCommand(String alias, CommandSource source) Returns whether the given alias is registered on this manager and can be used by the givenCommandSource.CompletableFuture<com.mojang.brigadier.suggestion.Suggestions> offerBrigadierSuggestions(CommandSource source, String cmdLine) Asynchronously collects suggestions to fill in the given commandcmdLine.offerSuggestions(CommandSource source, String cmdLine) Asynchronously collects suggestions to fill in the given commandcmdLine.default voidregister(com.mojang.brigadier.builder.LiteralArgumentBuilder<CommandSource> command) Registers a command from the given builder.default voidregister(com.mojang.brigadier.builder.LiteralArgumentBuilder<CommandSource> command, Set<String> aliases) Registers a command from the given builder with the specified aliases.default voidregister(com.mojang.brigadier.tree.LiteralCommandNode<CommandSource> command) Registers a command node without aliases.voidregister(com.mojang.brigadier.tree.LiteralCommandNode<CommandSource> command, Set<String> aliases) Registers a command node with the specified aliases.voidunregister(String alias) Unregisters the specified command alias from the manager, if registered.
-
Method Details
-
register
Registers a command from the given builder.- Parameters:
command- the command builder to register
-
register
Registers a command node without aliases.- Parameters:
command- the command node to register
-
register
default void register(com.mojang.brigadier.builder.LiteralArgumentBuilder<CommandSource> command, Set<String> aliases) Registers a command from the given builder with the specified aliases.- Parameters:
command- the command builder to registeraliases- additional aliases that should point to this command
-
register
void register(com.mojang.brigadier.tree.LiteralCommandNode<CommandSource> command, Set<String> aliases) Registers a command node with the specified aliases.Aliases are additional names that can be used to execute the command besides its primary literal name.
- Parameters:
command- the command node to registeraliases- additional aliases that should point to this command
-
unregister
Unregisters the specified command alias from the manager, if registered. Root literal names are also treated as aliases in this context.- Parameters:
alias- the command alias to unregister; if not currently registered, this method does nothing
-
dispatchAsync
Attempts to asynchronously execute a command from the givencmdLine.- Parameters:
source- the source to execute the command forcmdLine- the command to run- Returns:
- a future that may be completed with the result of the command execution. Can be completed exceptionally if an exception is thrown during execution.
-
offerSuggestions
Asynchronously collects suggestions to fill in the given commandcmdLine. Returns only the raw completion suggestions without tooltips.- Parameters:
source- the source to execute the command forcmdLine- the partially completed command- Returns:
- a
CompletableFutureeventually completed with aList, possibly empty
-
offerBrigadierSuggestions
CompletableFuture<com.mojang.brigadier.suggestion.Suggestions> offerBrigadierSuggestions(CommandSource source, String cmdLine) Asynchronously collects suggestions to fill in the given commandcmdLine. Returns the brigadierSuggestionswith tooltips for each result.- Parameters:
source- the source to execute the command forcmdLine- the partially completed command- Returns:
- a
CompletableFutureeventually completed withSuggestions, possibly empty
-
hasCommand
Returns whether the given alias is registered on this manager.- Parameters:
alias- the command alias to check- Returns:
- true if the alias is registered; false otherwise
-
hasCommand
Returns whether the given alias is registered on this manager and can be used by the givenCommandSource. SeeArgumentBuilder.requires(Predicate)- Parameters:
alias- the command alias to checksource- the command source- Returns:
- true if the alias is registered and usable; false otherwise
-