Package com.zetaplugins.zetacore.command
Class PluginCommand<T extends JavaPlugin>
java.lang.Object
com.zetaplugins.zetacore.command.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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanexecute(CommandContext ctx) Execute the commandgetDisplayOptions(List<String> options, String input) Get a list of options that start with the inputgetPlayerOptions(String input) Get a list of player optionsprotected TbooleanonCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String label, @NotNull String[] args) onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) final <E extends CommandException>
voidregisterExceptionHandler(Class<E> exceptionClass, CommandExceptionHandler<E> handler) Register an exception handler for a specific CommandException subclassThe Tabcompletion method for the command
-
Constructor Details
-
PluginCommand
Constructor for the PluginCommand class- Parameters:
plugin- The instance of the plugin
-
-
Method Details
-
getPlugin
-
execute
Execute the command- Parameters:
ctx- The context of the command execution, containing the sender, command, label, and arguments- Returns:
- Whether the command was executed successfully
- Throws:
CommandException- If an error occurs during command execution
-
tabComplete
The Tabcompletion method for the command- Parameters:
ctx- The context of the tab completion, containing the sender, command, label, and arguments- 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:
onCommandin interfaceCommandExecutor
-
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:
onTabCompletein interfaceTabCompleter
-
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 handlehandler- The handler to execute when the exception is thrown
-
getDisplayOptions
Get a list of options that start with the input- Parameters:
options- The list of optionsinput- The input to check against- Returns:
- A list of options that start with the input
-
getPlayerOptions
Get a list of player options- Parameters:
input- The input to check against- Returns:
- A list of player options
-