Class PluginCommand

All Implemented Interfaces:

public final class PluginCommand extends Command implements PluginIdentifiableCommand
Represents a Command belonging to a plugin
  • Constructor Details

    • PluginCommand

      protected PluginCommand(@NotNull String name, @NotNull Plugin owner)
  • Method Details

    • execute

      public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args)
      Executes the command, returning its success
      Specified by:
      execute in class Command
      sender - Source object which is executing this command
      commandLabel - The alias of the command used
      args - All arguments passed to the command, split via ' '
      true if the command was successful, otherwise false
    • setExecutor

      public void setExecutor(@Nullable CommandExecutor executor)
      Sets the CommandExecutor to run when parsing this command
      executor - New executor to run
    • getExecutor

      @NotNull public CommandExecutor getExecutor()
      Gets the CommandExecutor associated with this command
      CommandExecutor object linked to this command
    • setTabCompleter

      public void setTabCompleter(@Nullable TabCompleter completer)
      Sets the TabCompleter to run when tab-completing this command.

      If no TabCompleter is specified, and the command's executor implements TabCompleter, then the executor will be used for tab completion.

      completer - New tab completer
    • getTabCompleter

      @Nullable public TabCompleter getTabCompleter()
      Gets the TabCompleter associated with this command.
      TabCompleter object linked to this command
    • getPlugin

      @NotNull public Plugin getPlugin()
      Gets the owner of this PluginCommand
      Specified by:
      getPlugin in interface PluginIdentifiableCommand
      Plugin that owns this command
    • tabComplete

      @NotNull public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws CommandException, IllegalArgumentException
      Executed on tab completion for this command, returning a list of options the player can tab through.

      Delegates to the tab completer if present.

      If it is not present or returns null, will delegate to the current command executor if it implements TabCompleter. If a non-null list has not been found, will default to standard player name completion in Command.tabComplete(CommandSender, String, String[]).

      This method does not consider permissions.

      tabComplete in class Command
      sender - Source object which is executing this command
      alias - the alias being used
      args - All arguments passed to the command, split via ' '
      a list of tab-completions for the specified arguments. This will never be null. List may be immutable.
      CommandException - if the completer or executor throw an exception during the process of tab-completing.
      IllegalArgumentException - if sender, alias, or args is null
    • toString

      public String toString()
      toString in class Command