Class Command


  • public abstract class Command
    extends Object
    Abstract command.
    • Constructor Detail

      • Command

        protected Command​(@NotNull
                          @NotNull String... names)
        Command constructor.
        Parameters:
        names - Command aliases.
    • Method Detail

      • execute

        public abstract void execute​(@NotNull
                                     @NotNull Context context)
        Execute the command.
        Parameters:
        context - Execution context.
      • tabComplete

        @NotNull
        public @NotNull Collection<String> tabComplete​(@NotNull
                                                       @NotNull Context context)
        Tab complete.
        Parameters:
        context - Execution context.
        Returns:
        Tab complete results.
      • executeCommand

        @Internal
        public final void executeCommand​(@NotNull
                                         @NotNull Context context)
        Execute the command.
        Parameters:
        context - Execution context.
      • executeSubCommand

        @Internal
        public final boolean executeSubCommand​(@NotNull
                                               @NotNull Context context,
                                               @NotNull
                                               @NotNull String command)
        Execute sub command.
        Parameters:
        context - Execution context.
        command - Sub-command name.
        Returns:
        true if a sub-command was found and executed, otherwise false.
      • getName

        @NotNull
        public final @NotNull String getName()
        Get command name.
        Returns:
        Command name.
      • getAliases

        @NotNull
        public final @NotNull Collection<String> getAliases()
        Get command aliases.
        Returns:
        command aliases.
      • addAliases

        protected final void addAliases​(@NotNull
                                        @NotNull Collection<String> aliases)
        Add command aliases.
        Parameters:
        aliases - Command aliases.
      • getSubCommands

        @Internal
        @NotNull
        public final @NotNull Collection<SubCommand> getSubCommands()
        Get sub-commands.
        Returns:
        sub-commands.
      • getPermission

        @NotNull
        protected final @NotNull Optional<Permission> getPermission()
        Get permission.
        Returns:
        an optional containing the command permission, if available, otherwise an empty optional.
      • getPlatform

        @NotNull
        public final @NotNull PlatformTarget getPlatform()
        Get the platform target of this command.
        Returns:
        platform target.
      • setPlatform

        protected final void setPlatform​(@NotNull
                                         @NotNull PlatformTarget platform)
        Set the platform target of this command.
        Parameters:
        platform - platform target.
      • getConditions

        @NotNull
        protected final @NotNull Collection<Condition> getConditions()
        Get command conditions.
        Returns:
        command conditions.
      • setConditions

        protected final void setConditions​(@NotNull
                                           @NotNull Condition... conditions)
        Set command conditions.
        Parameters:
        conditions - Command conditions.
      • getPermissionErrorMessage

        @NotNull
        protected final @NotNull Optional<net.kyori.adventure.text.Component> getPermissionErrorMessage()
        Get command permission error message.
        Returns:
        command permission error message.
      • setPermissionErrorMessage

        protected final void setPermissionErrorMessage​(@NotNull
                                                       @NotNull net.kyori.adventure.text.Component permissionErrorMessage)
        Set command permission error message.
        Parameters:
        permissionErrorMessage - Command permission error message.