Interface CommandManager
public interface CommandManager
Manages command registration and execution.
-
Method Summary
Modifier and TypeMethodDescriptionexecute(CommandSource source, String commandLine) Execute a command as a source.executeAsync(CommandSource source, String commandLine) Execute a command asynchronously as a source.Get all registered command names.booleanhasCommand(String name) Check if a command is registered.voidregister(Object plugin, String name, CommandHandler handler, String... aliases) Register a simple command with a handler.voidRegister a command.voidunregister(String name) Unregister a command by name.voidunregisterAll(Object plugin) Unregister all commands registered by a plugin.
-
Method Details
-
register
-
register
void register(@Nonnull Object plugin, @Nonnull String name, @Nonnull CommandHandler handler, @Nonnull String... aliases) Register a simple command with a handler.- Parameters:
plugin- the plugin registering the commandname- the command namehandler- the handler for the commandaliases- additional aliases for the command
-
unregister
Unregister a command by name.- Parameters:
name- the command name
-
unregisterAll
Unregister all commands registered by a plugin.- Parameters:
plugin- the plugin whose commands should be unregistered
-
hasCommand
Check if a command is registered.- Parameters:
name- the command name- Returns:
- true if registered
-
getCommands
Get all registered command names.- Returns:
- a collection of command names
-
execute
Execute a command as a source.- Parameters:
source- the command sourcecommandLine- the command line to execute (without leading slash)- Returns:
- the result of the command
-
executeAsync
@Nonnull CompletableFuture<CommandResult> executeAsync(@Nonnull CommandSource source, @Nonnull String commandLine) Execute a command asynchronously as a source.- Parameters:
source- the command sourcecommandLine- the command line to execute (without leading slash)- Returns:
- a future that completes with the command result
-