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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanexecute(CommandSender sender, Command command, String label, ArgumentList args) 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 subclasstabComplete(CommandSender sender, Command command, ArgumentList args) The Tabcompletion method for the command
-
Constructor Details
-
PluginCommand
Constructor for the PluginCommand class- Parameters:
plugin- The instance of the plugin
-
-
Method Details
-
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 commandcommand- The command that was executedlabel- 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 commandCommandUsageException- If the command was used incorrectlyCommandException
-
tabComplete
The Tabcompletion method for the command- Parameters:
sender- The sender of the commandcommand- The command that is being tab completedargs- 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:
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
-