Interface CommandManager


public interface CommandManager
Manages command registration and execution.
  • Method Details

    • register

      void register(@Nonnull Object plugin, @Nonnull Command command, @Nonnull String... aliases)
      Register a command.
      Parameters:
      plugin - the plugin registering the command
      command - the command to register
      aliases - additional aliases for the command
    • 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 command
      name - the command name
      handler - the handler for the command
      aliases - additional aliases for the command
    • unregister

      void unregister(@Nonnull String name)
      Unregister a command by name.
      Parameters:
      name - the command name
    • unregisterAll

      void unregisterAll(@Nonnull Object plugin)
      Unregister all commands registered by a plugin.
      Parameters:
      plugin - the plugin whose commands should be unregistered
    • hasCommand

      boolean hasCommand(@Nonnull String name)
      Check if a command is registered.
      Parameters:
      name - the command name
      Returns:
      true if registered
    • getCommands

      @Nonnull Collection<String> getCommands()
      Get all registered command names.
      Returns:
      a collection of command names
    • execute

      @Nonnull CommandResult execute(@Nonnull CommandSource source, @Nonnull String commandLine)
      Execute a command as a source.
      Parameters:
      source - the command source
      commandLine - 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 source
      commandLine - the command line to execute (without leading slash)
      Returns:
      a future that completes with the command result