Package com.velocitypowered.api.command
Interface CommandManager
-
public interface CommandManagerHandles the registration and execution of commands.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description booleanexecute(CommandSource source, String cmdLine)Deprecated.this method blocks the current thread during the event call and the command execution.CompletableFuture<Boolean>executeAsync(CommandSource source, String cmdLine)Attempts to asynchronously execute a command from the givencmdLine.booleanexecuteImmediately(CommandSource source, String cmdLine)Deprecated.this methods blocks the current thread during the command execution.CompletableFuture<Boolean>executeImmediatelyAsync(CommandSource source, String cmdLine)Attempts to asynchronously execute a command from the givencmdLinewithout firing aCommandExecuteEvent.booleanhasCommand(String alias)Returns whether the given alias is registered on this manager.CommandMeta.BuildermetaBuilder(BrigadierCommand command)Returns a builder to create aCommandMetafor the given Brigadier command.CommandMeta.BuildermetaBuilder(String alias)Returns a builder to create aCommandMetawith the given alias.voidregister(BrigadierCommand command)Registers the specified Brigadier command.voidregister(CommandMeta meta, Command command)Registers the specified command with the given metadata.voidregister(Command command, String... aliases)Deprecated.This method requires at least one alias, but this is only enforced at runtime.voidregister(String alias, Command command, String... otherAliases)Registers the specified command with the specified aliases.voidunregister(String alias)Unregisters the specified command alias from the manager, if registered.
-
-
-
Method Detail
-
metaBuilder
CommandMeta.Builder metaBuilder(String alias)
Returns a builder to create aCommandMetawith the given alias.- Parameters:
alias- the first command alias- Returns:
- a
CommandMetabuilder
-
metaBuilder
CommandMeta.Builder metaBuilder(BrigadierCommand command)
Returns a builder to create aCommandMetafor the given Brigadier command.- Parameters:
command- the command- Returns:
- a
CommandMetabuilder
-
register
@Deprecated void register(Command command, String... aliases)
Deprecated.This method requires at least one alias, but this is only enforced at runtime. Preferregister(String, Command, String...)Registers the specified command with the specified aliases.- Parameters:
command- the command to registeraliases- the command aliases- Throws:
IllegalArgumentException- if one of the given aliases is already registered
-
register
void register(String alias, Command command, String... otherAliases)
Registers the specified command with the specified aliases.- Parameters:
alias- the first command aliascommand- the command to registerotherAliases- additional aliases- Throws:
IllegalArgumentException- if one of the given aliases is already registered
-
register
void register(BrigadierCommand command)
Registers the specified Brigadier command.- Parameters:
command- the command to register- Throws:
IllegalArgumentException- if the node alias is already registered
-
register
void register(CommandMeta meta, Command command)
Registers the specified command with the given metadata.- Parameters:
meta- the command metadatacommand- the command to register- Throws:
IllegalArgumentException- if one of the given aliases is already registered
-
unregister
void unregister(String alias)
Unregisters the specified command alias from the manager, if registered.- Parameters:
alias- the command alias to unregister
-
execute
@Deprecated boolean execute(CommandSource source, String cmdLine)
Deprecated.this method blocks the current thread during the event call and the command execution. PreferexecuteAsync(CommandSource, String)instead.Attempts to execute a command from the givencmdLinein a blocking fashion.- Parameters:
source- the source to execute the command forcmdLine- the command to run- Returns:
trueif the command was found and executed
-
executeImmediately
@Deprecated boolean executeImmediately(CommandSource source, String cmdLine)
Deprecated.this methods blocks the current thread during the command execution. PreferexecuteImmediatelyAsync(CommandSource, String)instead.Attempts to execute a command from the givencmdLinewithout firing aCommandExecuteEventin a blocking fashion.- Parameters:
source- the source to execute the command forcmdLine- the command to run- Returns:
trueif the command was found and executed
-
executeAsync
CompletableFuture<Boolean> executeAsync(CommandSource source, String cmdLine)
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.
-
executeImmediatelyAsync
CompletableFuture<Boolean> executeImmediatelyAsync(CommandSource source, String cmdLine)
Attempts to asynchronously execute a command from the givencmdLinewithout firing aCommandExecuteEvent.- 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.
-
hasCommand
boolean hasCommand(String alias)
Returns whether the given alias is registered on this manager.- Parameters:
alias- the command alias to check- Returns:
trueif the alias is registered
-
-