Class PluginCommand<T extends JavaPlugin>

java.lang.Object
com.zetaplugins.zetacore.commands.PluginCommand<T>
Type Parameters:
T - The type of the plugin
All Implemented Interfaces:
CommandExecutor, TabCompleter

public abstract class PluginCommand<T extends JavaPlugin> extends Object implements CommandExecutor, TabCompleter
Represents a custom command for a plugin
  • Constructor Details

    • PluginCommand

      public PluginCommand(T plugin)
      Constructor for the PluginCommand class
      Parameters:
      plugin - The instance of the plugin
  • Method Details

    • getPlugin

      protected T getPlugin()
    • execute

      public abstract boolean execute(CommandSender sender, Command command, String label, ArgumentList args) throws CommandException
      Execute the command
      Parameters:
      sender - The sender of the command
      command - The command that was executed
      label - The label of the command (The alias used)
      args - The arguments of the command
      Returns:
      Whether the command was executed successfully
      Throws:
      CommandPermissionException - If the sender does not have permission to execute the command
      CommandUsageException - If the command was used incorrectly
      CommandException
    • tabComplete

      public abstract List<String> tabComplete(CommandSender sender, Command command, ArgumentList args)
      The Tabcompletion method for the command
      Parameters:
      sender - The sender of the command
      command - The command that is being tab completed
      args - The current arguments of the command
      Returns:
      A list of possible completions
    • onCommand

      public boolean onCommand(@NotNull @NotNull CommandSender commandSender, @NotNull @NotNull Command command, @NotNull @NotNull String label, @NotNull @NotNull String[] args)
      Specified by:
      onCommand in interface CommandExecutor
    • onTabComplete

      @Nullable public @Nullable List<String> onTabComplete(@NotNull @NotNull CommandSender sender, @NotNull @NotNull Command command, @NotNull @NotNull String label, @NotNull @NotNull String[] args)
      Specified by:
      onTabComplete in interface TabCompleter
    • registerExceptionHandler

      public final <E extends CommandException> void registerExceptionHandler(Class<E> exceptionClass, CommandExceptionHandler<E> handler)
      Register an exception handler for a specific CommandException subclass
      Type Parameters:
      E - The type of CommandException
      Parameters:
      exceptionClass - The class of the exception to handle
      handler - The handler to execute when the exception is thrown
    • getDisplayOptions

      protected final List<String> getDisplayOptions(List<String> options, String input)
      Get a list of options that start with the input
      Parameters:
      options - The list of options
      input - The input to check against
      Returns:
      A list of options that start with the input
    • getPlayerOptions

      protected final List<String> getPlayerOptions(String input)
      Get a list of player options
      Parameters:
      input - The input to check against
      Returns:
      A list of player options