Interface CommandManager


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

      • register

        default void register​(String alias,
                              Command command,
                              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:
        IllegalArgumentException - if one of the given aliases is already registered, or the given command does not implement a registrable Command subinterface
        See Also:
        for a list of registrable subinterfaces
      • 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
      • unregister

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

        CompletableFuture<Boolean> executeAsync​(CommandSource source,
                                                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.
      • executeImmediatelyAsync

        CompletableFuture<Boolean> executeImmediatelyAsync​(CommandSource source,
                                                           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.
      • getAliases

        Collection<String> getAliases()
        Returns an immutable collection of the case-insensitive aliases registered on this manager.
        Returns:
        the registered aliases
      • hasCommand

        boolean hasCommand​(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; false otherwise