Class SubCommand

  • All Implemented Interfaces:
    SubCommandExecutor

    public abstract class SubCommand
    extends java.lang.Object
    implements SubCommandExecutor
    Represents a sub command of any command.

    If neither minArgs nor maxArgs is set

    • Constructor Detail

      • SubCommand

        public SubCommand​(int exactArgs,
                          QuestionAnswerType<?>[] requiredArguments)
      • SubCommand

        public SubCommand​(int minArgs,
                          int exactArgs,
                          int maxArgs,
                          QuestionAnswerType<?>[] requiredArguments)
    • Method Detail

      • disableMinArgsIndicator

        public SubCommand disableMinArgsIndicator()
        Disables the "..." in the getArgsAsString() method
        Returns:
        this
      • enableProperties

        public SubCommand enableProperties()
        Allows extra properties for this sub command
        Returns:
        this
      • appendUsage

        public void appendUsage​(java.lang.String usage)
        Appends the given usage to the usage of this command with a space before the new usage.
        Parameters:
        usage - the usage to be appended
      • requiresExactArgs

        public boolean requiresExactArgs()
        Checks whether this command requires the exact length of input arguments or not.
        Returns:
        true if this command requires it or false if not
      • requiresMinArgs

        public boolean requiresMinArgs()
        Checks whether this command requires a minimal length of input argument.
        Returns:
        true if this command requires it or false if not
      • mayLastArgContainSpaces

        public boolean mayLastArgContainSpaces()
      • requiresMaxArgs

        public boolean requiresMaxArgs()
        Checks whether this command requires a maximum length of input arguments.
        Returns:
        true if this command requires it or false if not
      • checkValidArgsLength

        public boolean checkValidArgsLength​(int length)
        Checks whether the input length of arguments is valid according to the exact, min and max length of arguments specified for this command.
        Parameters:
        length - the input arguments length
        Returns:
        true if the length matches or false if not
        See Also:
        requiresExactArgs(), requiresMinArgs(), requiresMaxArgs()
      • getInvalidArgumentMessage

        public de.dytanic.cloudnet.common.collection.Pair<java.lang.String,​java.lang.Integer> getInvalidArgumentMessage​(java.lang.String[] args)
      • parseArgsIgnoreLength

        public SubCommandArgument<?>[] parseArgsIgnoreLength​(java.lang.String[] args)
      • parseProperties

        public de.dytanic.cloudnet.common.Properties parseProperties​(java.lang.String[] args)
      • getNextPossibleArgumentAnswers

        public java.util.Collection<java.lang.String> getNextPossibleArgumentAnswers​(java.lang.String[] args)
        Gets the possible answers for the next argument by the given args array for auto completion. All arguments in the array have to match to get any response.
        Parameters:
        args - the current args to get the next argument from
        Returns:
        a list containing all possible answers or null, if no argument was found or the next argument doesn't have any answers defined
      • isOnlyConsole

        public boolean isOnlyConsole()
      • isAsync

        public boolean isAsync()
      • getPermission

        public java.lang.String getPermission()
      • getDescription

        public java.lang.String getDescription()
      • getExtendedUsage

        public java.lang.String getExtendedUsage()
      • getMinArgs

        public int getMinArgs()
      • setMinArgs

        public SubCommand setMinArgs​(int minArgs)
      • getExactArgs

        public int getExactArgs()
      • setExactArgs

        public SubCommand setExactArgs​(int exactArgs)
      • getMaxArgs

        public int getMaxArgs()
      • setMaxArgs

        public SubCommand setMaxArgs​(int maxArgs)