Interface CommandManager


  • public interface CommandManager
    Handles the registration and execution of commands.
    • Method Detail

      • metaBuilder

        CommandMeta.Builder metaBuilder​(java.lang.String alias)
        Returns a builder to create a CommandMeta with the given alias.
        Parameters:
        alias - the first command alias
        Returns:
        a CommandMeta builder
      • register

        default void register​(java.lang.String alias,
                              Command command,
                              java.lang.String... otherAliases)
        Registers the specified command with the specified aliases.
        Parameters:
        alias - the first command alias
        command - the command to register
        otherAliases - additional aliases
        Throws:
        java.lang.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:
        java.lang.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 metadata
        command - the command to register
        Throws:
        java.lang.IllegalArgumentException - if one of the given aliases is already registered
      • unregister

        void unregister​(java.lang.String alias)
        Unregisters the specified command alias from the manager, if registered.
        Parameters:
        alias - the command alias to unregister
      • execute

        java.util.concurrent.CompletableFuture<java.lang.Boolean> execute​(CommandSource source,
                                                                          java.lang.String cmdLine)
        Attempts to asynchronously execute a command from the given cmdLine.
        Parameters:
        source - the source to execute the command for
        cmdLine - 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.
      • executeImmediately

        java.util.concurrent.CompletableFuture<java.lang.Boolean> executeImmediately​(CommandSource source,
                                                                                     java.lang.String cmdLine)
        Attempts to asynchronously execute a command from the given cmdLine without firing a CommandExecuteEvent.
        Parameters:
        source - the source to execute the command for
        cmdLine - 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​(java.lang.String alias)
        Returns whether the given alias is registered on this manager.
        Parameters:
        alias - the command alias to check
        Returns:
        true if the alias is registered