Package com.velocitypowered.api.command
Interface CommandManager
public interface CommandManager
Handles the registration and execution of commands.
-
Method Summary
Modifier and TypeMethodDescriptionexecuteAsync
(CommandSource source, String cmdLine) Attempts to asynchronously execute a command from the givencmdLine
.executeImmediatelyAsync
(CommandSource source, String cmdLine) Attempts to asynchronously execute a command from the givencmdLine
without firing aCommandExecuteEvent
.Returns an immutable collection of the case-insensitive aliases registered on this manager.@Nullable CommandMeta
getCommandMeta
(String alias) Retrieves theCommandMeta
from the specified command alias, if registered.boolean
hasCommand
(String alias) Returns whether the given alias is registered on this manager.boolean
hasCommand
(String alias, CommandSource source) Returns whether the given alias is registered on this manager and can be used by the givenCommandSource
.metaBuilder
(BrigadierCommand command) Returns a builder to create aCommandMeta
for the given Brigadier command.metaBuilder
(String alias) Returns a builder to create aCommandMeta
with the given alias.void
register
(BrigadierCommand command) Deprecated.void
register
(CommandMeta meta, Command command) Registers the specified command with the given metadata.default void
Deprecated.useregister(CommandMeta, Command)
instead with a plugin specifiedvoid
unregister
(CommandMeta meta) Unregisters the specified command from the manager, if registered.void
unregister
(String alias) Unregisters the specified command alias from the manager, if registered.
-
Method Details
-
metaBuilder
Returns a builder to create aCommandMeta
with the given alias.- Parameters:
alias
- the first command alias- Returns:
- a
CommandMeta
builder
-
metaBuilder
Returns a builder to create aCommandMeta
for the given Brigadier command.- Parameters:
command
- the command- Returns:
- a
CommandMeta
builder
-
register
Deprecated.useregister(CommandMeta, Command)
instead with a plugin specifiedRegisters 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, or the given command does not implement a registrableCommand
subinterface- See Also:
-
register
Deprecated.useregister(CommandMeta, Command)
instead with a plugin specifiedRegisters the specified Brigadier command.- Parameters:
command
- the command to register- Throws:
IllegalArgumentException
- if the node alias is already registered
-
register
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, or the given command does not implement a registrableCommand
subinterface- See Also:
-
unregister
Unregisters the specified command alias from the manager, if registered.- Parameters:
alias
- the command alias to unregister
-
unregister
Unregisters the specified command from the manager, if registered.- Parameters:
meta
- the command to unregister
-
getCommandMeta
Retrieves theCommandMeta
from the specified command alias, if registered.- Parameters:
alias
- the command alias to lookup- Returns:
- an
CommandMeta
of the alias
-
executeAsync
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
Attempts to asynchronously execute a command from the givencmdLine
without 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.
-
getAliases
Collection<String> getAliases()Returns an immutable collection of the case-insensitive aliases registered on this manager.- Returns:
- the registered aliases
-
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
-
register(CommandMeta, Command)
instead with a plugin specified