Class Command<C>

  • Type Parameters:
    C - Command sender type

    public class Command<C>
    extends java.lang.Object
    A command consists out of a chain of command arguments.
    • Constructor Detail

      • Command

        public Command​(@NonNull java.util.List<@NonNull CommandComponent<C>> commandComponents,
                       @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
                       @Nullable java.lang.Class<? extends C> senderType,
                       @NonNull CommandPermission commandPermission,
                       @NonNull CommandMeta commandMeta)
        Construct a new command
        Parameters:
        commandComponents - Command component argument and description
        commandExecutionHandler - Execution handler
        senderType - Required sender type. May be null
        commandPermission - Command permission
        commandMeta - Command meta instance
        Since:
        1.3.0
      • Command

        public Command​(@NonNull java.util.List<@NonNull CommandComponent<C>> commandComponents,
                       @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
                       @Nullable java.lang.Class<? extends C> senderType,
                       @NonNull CommandMeta commandMeta)
        Construct a new command
        Parameters:
        commandComponents - Command components
        commandExecutionHandler - Execution handler
        senderType - Required sender type. May be null
        commandMeta - Command meta instance
        Since:
        1.3.0
      • Command

        public Command​(@NonNull java.util.List<@NonNull CommandComponent<C>> commandComponents,
                       @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
                       @NonNull CommandPermission commandPermission,
                       @NonNull CommandMeta commandMeta)
        Construct a new command
        Parameters:
        commandComponents - Command components
        commandExecutionHandler - Execution handler
        commandPermission - Command permission
        commandMeta - Command meta instance
        Since:
        1.3.0
      • Command

        @Deprecated
        public Command​(@NonNull java.util.Map<@NonNull CommandArgument<C,​?>,​@NonNull Description> commandArguments,
                       @NonNull CommandExecutionHandler<@NonNull C> commandExecutionHandler,
                       @Nullable java.lang.Class<? extends C> senderType,
                       @NonNull CommandMeta commandMeta)
        Deprecated.
        Map does not allow for the same literal or variable argument name to repeat
        Construct a new command
        Parameters:
        commandArguments - Command arguments
        commandExecutionHandler - Execution handler
        senderType - Required sender type. May be null
        commandMeta - Command meta instance
        See Also:
        Command(List, CommandExecutionHandler, Class, CommandMeta)
    • Method Detail

      • newBuilder

        @Deprecated
        public static <C> @NonNull Command.Builder<C> newBuilder​(@NonNull java.lang.String commandName,
                                                                 @NonNull CommandMeta commandMeta,
                                                                 @NonNull Description description,
                                                                 @NonNull java.lang.String... aliases)
        Deprecated.
        Create a new command builder. Is recommended to use the builder methods in CommandManager rather than invoking this method directly.
        Type Parameters:
        C - Command sender type
        Parameters:
        commandName - Base command argument
        commandMeta - Command meta instance
        description - Command description
        aliases - Command aliases
        Returns:
        Command builder
      • newBuilder

        public static <C> @NonNull Command.Builder<C> newBuilder​(@NonNull java.lang.String commandName,
                                                                 @NonNull CommandMeta commandMeta,
                                                                 @NonNull ArgumentDescription description,
                                                                 @NonNull java.lang.String... aliases)
        Create a new command builder. Is recommended to use the builder methods in CommandManager rather than invoking this method directly.
        Type Parameters:
        C - Command sender type
        Parameters:
        commandName - Base command argument
        commandMeta - Command meta instance
        description - Command description
        aliases - Command aliases
        Returns:
        Command builder
        Since:
        1.4.0
      • newBuilder

        public static <C> @NonNull Command.Builder<C> newBuilder​(@NonNull java.lang.String commandName,
                                                                 @NonNull CommandMeta commandMeta,
                                                                 @NonNull java.lang.String... aliases)
        Create a new command builder. Is recommended to use the builder methods in CommandManager rather than invoking this method directly.
        Type Parameters:
        C - Command sender type
        Parameters:
        commandName - Base command argument
        commandMeta - Command meta instance
        aliases - Command aliases
        Returns:
        Command builder
      • getArguments

        public @NonNull java.util.List<CommandArgument<@NonNull C,​?>> getArguments()
        Return a copy of the command argument array
        Returns:
        Copy of the command argument array. This List is mutable.
      • getComponents

        public @NonNull java.util.List<CommandComponent<@NonNull C>> getComponents()
        Returns a copy of the command component array
        Returns:
        Copy of the command component array. This List is mutable
        Since:
        1.3.0
      • getCommandExecutionHandler

        public CommandExecutionHandler<@NonNull C> getCommandExecutionHandler()
        Get the command execution handler
        Returns:
        Command execution handler
      • getSenderType

        public @NonNull java.util.Optional<java.lang.Class<? extends C>> getSenderType()
        Get the required sender type, if one has been specified
        Returns:
        Required sender type
      • getCommandPermission

        public @NonNull CommandPermission getCommandPermission()
        Get the command permission
        Returns:
        Command permission
      • getCommandMeta

        public @NonNull CommandMeta getCommandMeta()
        Get the command meta instance
        Returns:
        Command meta
      • getArgumentDescription

        @Deprecated
        public @NonNull java.lang.String getArgumentDescription​(@NonNull CommandArgument<C,​?> argument)
        Deprecated.
        More than one matching command argument may exist per command. Use getArguments() and search in that, instead.
        Get the description for an argument
        Parameters:
        argument - Argument
        Returns:
        Argument description
        Throws:
        java.lang.IllegalArgumentException - If the command argument does not exist
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isHidden

        public boolean isHidden()
        Check whether or not the command is hidden
        Returns:
        true if the command is hidden, false if not