BukkitCommand
, FormattedCommandAlias
, MultipleCommandAlias
, PluginCommand
public abstract class Command
extends java.lang.Object
Modifier and Type | Field | Description |
---|---|---|
protected java.lang.String |
description |
|
CustomTimingsHandler |
timings |
|
protected java.lang.String |
usageMessage |
Modifier | Constructor | Description |
---|---|---|
protected |
Command(java.lang.String name) |
|
protected |
Command(java.lang.String name,
java.lang.String description,
java.lang.String usageMessage,
java.util.List<java.lang.String> aliases) |
Modifier and Type | Method | Description |
---|---|---|
static void |
broadcastCommandMessage(CommandSender source,
java.lang.String message) |
|
static void |
broadcastCommandMessage(CommandSender source,
java.lang.String message,
boolean sendToSource) |
|
abstract boolean |
execute(CommandSender sender,
java.lang.String commandLabel,
java.lang.String[] args) |
Executes the command, returning its success
|
java.util.List<java.lang.String> |
getAliases() |
Returns a list of active aliases of this command
|
java.lang.String |
getDescription() |
Gets a brief description of this command
|
java.lang.String |
getLabel() |
Returns the label for this command
|
java.lang.String |
getName() |
Returns the name of this command
|
java.lang.String |
getPermission() |
Gets the permission required by users to be able to perform this
command
|
java.lang.String |
getPermissionMessage() |
Returns a message to be displayed on a failed permission check for this
command
|
java.lang.String |
getUsage() |
Gets an example usage of this command
|
boolean |
isRegistered() |
Returns the current registered state of this command
|
boolean |
register(CommandMap commandMap) |
Registers this command to a CommandMap.
|
Command |
setAliases(java.util.List<java.lang.String> aliases) |
Sets the list of aliases to request on registration for this command.
|
Command |
setDescription(java.lang.String description) |
Sets a brief description of this command.
|
boolean |
setLabel(java.lang.String name) |
Sets the label of this command.
|
boolean |
setName(java.lang.String name) |
Sets the name of this command.
|
void |
setPermission(java.lang.String permission) |
Sets the permission required by users to be able to perform this
command
|
Command |
setPermissionMessage(java.lang.String permissionMessage) |
Sets the message sent when a permission check fails
|
Command |
setUsage(java.lang.String usage) |
Sets the example usage of this command
|
java.util.List<java.lang.String> |
tabComplete(CommandSender sender,
java.lang.String alias,
java.lang.String[] args) |
Executed on tab completion for this command, returning a list of
options the player can tab through.
|
java.util.List<java.lang.String> |
tabComplete(CommandSender sender,
java.lang.String alias,
java.lang.String[] args,
Location location) |
Executed on tab completion for this command, returning a list of
options the player can tab through.
|
boolean |
testPermission(CommandSender target) |
Tests the given
CommandSender to see if they can perform this
command. |
boolean |
testPermissionSilent(CommandSender target) |
Tests the given
CommandSender to see if they can perform this
command. |
java.lang.String |
toString() |
|
boolean |
unregister(CommandMap commandMap) |
Unregisters this command from the passed CommandMap applying any
outstanding changes
|
protected java.lang.String description
protected java.lang.String usageMessage
public CustomTimingsHandler timings
protected Command(java.lang.String name)
protected Command(java.lang.String name, java.lang.String description, java.lang.String usageMessage, java.util.List<java.lang.String> aliases)
public abstract boolean execute(CommandSender sender, java.lang.String commandLabel, java.lang.String[] args)
sender
- Source object which is executing this commandcommandLabel
- The alias of the command usedargs
- All arguments passed to the command, split via ' 'public java.util.List<java.lang.String> tabComplete(CommandSender sender, java.lang.String alias, java.lang.String[] args) throws java.lang.IllegalArgumentException
sender
- Source object which is executing this commandalias
- the alias being usedargs
- All arguments passed to the command, split via ' 'java.lang.IllegalArgumentException
- if sender, alias, or args is nullpublic java.util.List<java.lang.String> tabComplete(CommandSender sender, java.lang.String alias, java.lang.String[] args, Location location) throws java.lang.IllegalArgumentException
sender
- Source object which is executing this commandalias
- the alias being usedargs
- All arguments passed to the command, split via ' 'location
- The position looked at by the sender, or null if nonejava.lang.IllegalArgumentException
- if sender, alias, or args is nullpublic java.lang.String getName()
public boolean setName(java.lang.String name)
May only be used before registering the command. Will return true if the new name is set, and false if the command has already been registered.
name
- New command namepublic java.lang.String getPermission()
public void setPermission(java.lang.String permission)
permission
- Permission name or nullpublic boolean testPermission(CommandSender target)
CommandSender
to see if they can perform this
command.
If they do not have permission, they will be informed that they cannot do this.
target
- User to testpublic boolean testPermissionSilent(CommandSender target)
CommandSender
to see if they can perform this
command.
No error is sent to the sender.
target
- User to testpublic java.lang.String getLabel()
public boolean setLabel(java.lang.String name)
May only be used before registering the command. Will return true if the new name is set, and false if the command has already been registered.
name
- The command's namepublic boolean register(CommandMap commandMap)
commandMap
- the CommandMap to register this command topublic boolean unregister(CommandMap commandMap)
commandMap
- the CommandMap to unregisterpublic boolean isRegistered()
public java.util.List<java.lang.String> getAliases()
public java.lang.String getPermissionMessage()
public java.lang.String getDescription()
public java.lang.String getUsage()
public Command setAliases(java.util.List<java.lang.String> aliases)
PluginDescriptionFile.getCommands()
(under the
`aliases
' node) is equivalent to this method.aliases
- aliases to register to this commandpublic Command setDescription(java.lang.String description)
PluginDescriptionFile.getCommands()
(under the
`description
' node) is equivalent to this method.description
- new command descriptionpublic Command setPermissionMessage(java.lang.String permissionMessage)
permissionMessage
- new permission message, null to indicate
default message, or an empty string to indicate no messagepublic Command setUsage(java.lang.String usage)
usage
- new example usagepublic static void broadcastCommandMessage(CommandSender source, java.lang.String message)
public static void broadcastCommandMessage(CommandSender source, java.lang.String message, boolean sendToSource)
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2018. All rights reserved.