Interface Command.Builder

    • Method Detail

      • addFlag

        Command.Builder addFlag​(Flag flag)
        Adds a flag to this command. Flags are always the first arguments of a command. There are no set rules for the order of execution of flags (unlike addParameter(Parameter)), and all flags are considered optional.

        Duplicate keys and/or duplicate aliases may not be provided.

        Parameters:
        flag - The Flag to support
        Returns:
        Ths builder, for chaining
      • addParameter

        Command.Builder addParameter​(Parameter parameter)
        Adds a parameter for use when parsing arguments. When executing a command, they will be executed in the order they are added to this builder.
        Parameters:
        parameter - The parameter to add to the parameter list
        Returns:
        This builder, for chaining
      • addParameters

        default Command.Builder addParameters​(Parameter... parameters)
        Adds parameters to use when parsing arguments. Parameters will be used in the order provided here.
        Parameters:
        parameters - The Parameters to use
        Returns:
        This builder, for chaining
      • addParameters

        default Command.Builder addParameters​(Iterable<Parameter> parameters)
        Adds parameters to use when parsing arguments. Parameters will be used in the order provided here.
        Parameters:
        parameters - The Parameters to use
        Returns:
        This builder, for chaining
      • executor

        Command.Builder executor​(CommandExecutor executor)
        Provides the logic of the command.

        This is only optional if child commands are specified. This will replace any previous executor that has been set.

        Parameters:
        executor - The CommandExecutor that will run the command
        Returns:
        This builder, for chaining
      • extendedDescription

        Command.Builder extendedDescription​(Function<CommandCause,​Optional<Component>> extendedDescriptionFunction)
        Provides the description for this command, which is dependent on the Cause that requests it.

        A one line summary should be provided to shortDescription(Component)

        It is recommended to use the default text color and style. Sections with text actions (e.g. hyperlinks) should be underlined.

        Parameters:
        extendedDescriptionFunction - A function that provides a relevant description based on the supplied Cause
        Returns:
        This builder, for chaining
      • extendedDescription

        default Command.Builder extendedDescription​(@Nullable Component extendedDescription)
        Provides the description for this command.

        A one line summary should be provided to shortDescription(Component)

        Parameters:
        extendedDescription - The description to use, or null for no description.
        Returns:
        This builder, for chaining
      • shortDescription

        Command.Builder shortDescription​(Function<CommandCause,​Optional<Component>> descriptionFunction)
        Provides a simple description for this command, typically no more than one line, which is dependent on the Cause that requests it.

        Fuller descriptions should be provided through extendedDescription(Function)

        Parameters:
        descriptionFunction - A function that provides a relevant description based on the supplied Cause
        Returns:
        This builder, for chaining
      • shortDescription

        default Command.Builder shortDescription​(@Nullable Component description)
        Provides a simple description for this command, typically no more than one line.

        Fuller descriptions should be provided through extendedDescription(Component)

        It is recommended to use the default text color and style. Sections with text actions (e.g. hyperlinks) should be underlined.

        Parameters:
        description - The description to use, or null for no description
        Returns:
        This builder, for chaining
      • permission

        Command.Builder permission​(@Nullable String permission)
        The permission that the responsible Subject in the given Cause requires to run this command, or null if no permission is required. Calling this method will overwrite anything set via executionRequirements(Predicate), or will replace the previous permission set by this method.

        Any permission checks set here will be performed during the Command.canExecute(CommandCause).

        Parameters:
        permission - The permission that is required, or null for no permission
        Returns:
        This builder, for chaining
      • executionRequirements

        Command.Builder executionRequirements​(@Nullable Predicate<CommandCause> executionRequirements)
        Sets a function that determines what is required of the provided Cause before this command executes. Calling this method will overwrite anything set via permission(String) or anything previously set via this method.

        Any requirements set here will be performed as part of Command.canExecute(CommandCause).

        Parameters:
        executionRequirements - A function that sets the
        Returns:
        This builder, for chaining
      • terminal

        Command.Builder terminal​(boolean terminal)
        Sets whether this command is considered "terminal" in its own right, that is, can be executed on its own if no arguments are supplied when invoked, regardless of whether any supplied Parameters are mandatory.
        Parameters:
        terminal - Whether to mark this command as terminal
        Returns:
        This builder, for chaining
        See Also:
        Parameter.isTerminal(), Parameter.Value.Builder.terminal()