Class CommandUtils


  • public abstract class CommandUtils
    extends Object
    • Field Detail

      • plugin

        @NotNull
        protected final @NotNull ADPPlugin plugin
    • Constructor Detail

      • CommandUtils

        public CommandUtils()
    • Method Detail

      • register

        @NotNull
        public abstract @NotNull CommandUtils.RegisterResult register​(@NotNull
                                                                      @NotNull ADPMainCommand command)
        Register the command
        Parameters:
        command - the command to register
        Returns:
        the register result
      • executeCommand

        public void executeCommand​(@NotNull
                                   @NotNull User sender,
                                   String mainCommand,
                                   @NotNull
                                   @NotNull ADPSubCommand command,
                                   @NotNull
                                   @NotNull String[] args)
        Trigger the command handler
        Parameters:
        sender - the user that is executing the command
        mainCommand - the command performed
        command - the sub command performed
        args - arguments of the command
      • handleOnOffCommand

        @Nullable
        public @Nullable Boolean handleOnOffCommand​(@NotNull
                                                    @NotNull Boolean value,
                                                    @NotNull
                                                    @NotNull String[] args)
        Handle on/off commands
        Parameters:
        value - the default value
        args - the command arguments
        Returns:
        true if the result is on
      • handleCommandString

        @NotNull
        public @NotNull String handleCommandString​(@NotNull
                                                   @NotNull String[] args,
                                                   int start)
        Handle string into a command, get the entire string since start to end of arguments
        Parameters:
        args - the command arguments
        start - the start of the string
        Returns:
        the string
      • tabCompleteParser

        @NotNull
        public @NotNull List<String> tabCompleteParser​(@NotNull
                                                       @NotNull List<String> commands,
                                                       @NotNull
                                                       @NotNull String word)
        Parse tab complete command list
        Parameters:
        commands - the list of commands
        word - the word to check
        Returns:
        a list of commands that starts with word
      • tabCompleteOnOff

        @NotNull
        public @NotNull List<String> tabCompleteOnOff​(@NotNull
                                                      @NotNull String[] args)
        Handle on/off tab complete
        Parameters:
        args - the command arguments (on/off)
        Returns:
        a list of on/off that match args
      • tabCompletePlayerList

        @NotNull
        public @NotNull List<String> tabCompletePlayerList​(@NotNull
                                                           @NotNull String[] args,
                                                           int index,
                                                           boolean bypassVanish)
        Insert player list inside tab complete
        Parameters:
        args - the command arguments
        index - the argument index
        bypassVanish - show vanished players
        Returns:
        a list of players that match args
      • tabCompletePlayerList

        @NotNull
        public @NotNull List<String> tabCompletePlayerList​(@NotNull
                                                           @NotNull String[] args,
                                                           int index)
        Insert player list inside tab complete
        Parameters:
        args - the command arguments
        index - the argument index
        Returns:
        a list of players that match args