Package org.bukkit.command
Class PluginCommand
java.lang.Object
org.bukkit.command.Command
org.bukkit.command.PluginCommand
- All Implemented Interfaces:
PluginIdentifiableCommand
Represents a
Command
belonging to a plugin-
Field Summary
Fields inherited from class org.bukkit.command.Command
description, timings, usageMessage
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
execute(CommandSender sender, String commandLabel, String[] args)
Executes the command, returning its successGets theCommandExecutor
associated with this commandGets the owner of this PluginCommandGets theTabCompleter
associated with this command.void
setExecutor(CommandExecutor executor)
Sets theCommandExecutor
to run when parsing this commandvoid
setTabCompleter(TabCompleter completer)
Sets theTabCompleter
to run when tab-completing this command.tabComplete(CommandSender sender, String alias, String[] args)
Executed on tab completion for this command, returning a list of options the player can tab through.toString()
Methods inherited from class org.bukkit.command.Command
broadcastCommandMessage, broadcastCommandMessage, getAliases, getDescription, getLabel, getName, getPermission, getPermissionMessage, getUsage, isRegistered, register, setAliases, setDescription, setLabel, setName, setPermission, setPermissionMessage, setUsage, tabComplete, testPermission, testPermissionSilent, unregister
-
Constructor Details
-
PluginCommand
-
-
Method Details
-
execute
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args)Executes the command, returning its success -
setExecutor
Sets theCommandExecutor
to run when parsing this command- Parameters:
executor
- New executor to run
-
getExecutor
Gets theCommandExecutor
associated with this command- Returns:
- CommandExecutor object linked to this command
-
setTabCompleter
Sets theTabCompleter
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.
- Parameters:
completer
- New tab completer
-
getTabCompleter
Gets theTabCompleter
associated with this command.- Returns:
- TabCompleter object linked to this command
-
getPlugin
Gets the owner of this PluginCommand- Specified by:
getPlugin
in interfacePluginIdentifiableCommand
- Returns:
- Plugin that owns this command
-
tabComplete
@NotNull public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws CommandException, IllegalArgumentExceptionExecuted 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 inCommand.tabComplete(CommandSender, String, String[])
.This method does not consider permissions.
- Overrides:
tabComplete
in classCommand
- Parameters:
sender
- Source object which is executing this commandalias
- the alias being usedargs
- All arguments passed to the command, split via ' '- Returns:
- a list of tab-completions for the specified arguments. This will never be null. List may be immutable.
- Throws:
CommandException
- if the completer or executor throw an exception during the process of tab-completing.IllegalArgumentException
- if sender, alias, or args is null
-
toString
-