Interface SubCommand
- All Known Subinterfaces:
CommandsCollection
Basically anything you're able to give a name is a command.
This also includes a collection of commands (e.g. /bw or /bw arena).
Those collections are being implemented by CommandsCollection
and are also executable.
-
Method Summary
Modifier and TypeMethodDescriptionString[]
Other possible names for accessing this command.default String
getFullName
(String label) Returns the "full name" as if you'd type it in.The handler handles what should happen when the command is e.g. getting executedgetName()
The main name of the command, which will be displayed in e.g.@Nullable CommandsCollection
A command must be added into a collection otherwise it's not accessible.@Nullable String
The permission needed to use the command.default String
getUsage()
Returns the default parameters the command expects.getUsage
(@Nullable CommandSenderWrapper senderWrapper) Returns the parameters the command expects for a specific sender.boolean
Returns whether or not it'll display the amount of entries in /bw [...] help.boolean
Whether or not only players are able to execute the commandboolean
Returns whether or not this command is visible in help.void
setAliases
(String... aliases) Set the new aliases of the command.void
setHandler
(CommandHandler handler) The handler handles what should happen when the command is e.g. getting executedvoid
setHasContentAmount
(boolean hasContentAmount) Set whether or not it'll display the amount of entries in /bw [...] help.void
setOnlyForPlayers
(boolean onlyForPlayers) Whether or not only players are able to execute the commandvoid
setPermission
(@Nullable String permission) The permission needed to use the command.void
Set the parameters the command expectsvoid
setVisible
(boolean visible) Set whether or not this command is visible in help.
-
Method Details
-
getName
String getName()The main name of the command, which will be displayed in e.g. /bw help.Example: If this returns "banana" then you'd have to type in /bw banana.
- Returns:
- The name of the command
-
getParent
A command must be added into a collection otherwise it's not accessible.As the system is built in a tree-structure-way each command must have a parent node/command. There's only one instance that doesn't have a parent and that's the root node which you obtain with
BedwarsAPI.getRootCommandsCollection()
.- Returns:
- The parent collection to which this command has been added to
-
getFullName
Returns the "full name" as if you'd type it in.E.g. it returns "/bw arena banana" where "bw" is the label which you pass in as a parameter.
- Parameters:
label
- The actual command you'd use to access the command (e.g. "bw")- Returns:
- The full command name
-
getAliases
String[] getAliases()Other possible names for accessing this command.Keep in mind that it's possible that aliases overlap themselves and there's no guarantee that this one will be executed if this occurs. Names of a command have a higher priority than aliases.
These won't be shown in /bw help
- Returns:
- Aliases of the command
-
setAliases
Set the new aliases of the command. You don't have to include the name of the command in the array.Keep in mind that it's possible that aliases overlap themselves and there's no guarantee that this one will be executed if this occurs. Names of a command have a higher priority than aliases.
These won't be shown in /bw help
- Parameters:
aliases
- The new aliases of the command
-
getPermission
The permission needed to use the command. Sender will see an error if he does not have the permission and the execution won't be passed to the handler.null
means that no permission is needed to run the command- Returns:
- The permission needed to execute the command.
null
meaning that none is needed
-
setPermission
The permission needed to use the command. Sender will see an error if he does not have the permission and the execution won't be passed to the handler.null
means that no permission is needed to run the command- Parameters:
permission
- The new permission needed to execute the command.null
meaning that none is needed
-
getUsage
Returns the default parameters the command expects.Use <> for parameters that are strictly needed, [] for optional ones.
Example: /teleport <target> [source]
We must add a target parameter, but we are not forced to add a source parameter.
This example would return with this method ">target< [source]"- Returns:
- The usage of the command
-
getUsage
Returns the parameters the command expects for a specific sender.By default if no sender is being passed, the same usage that has been defined using
setUsage(String)
. However, you may also add conditional usages by overridingCommandHandler.getContentAmount(CommandSender)
.- Parameters:
senderWrapper
- The sender we are getting the usage for. Maybe benull
if we want to use the default usage- Returns:
- The usage of the command
-
setUsage
Set the parameters the command expectsUse <> for parameters that are strictly needed, [] for optional ones.
Example: /teleport <target> [source]
We must add a target parameter, but we are not forced to add a source parameter.
This example would return with this method ">target< [source]"- Parameters:
usage
- The new usage of the command
-
getHandler
CommandHandler getHandler()The handler handles what should happen when the command is e.g. getting executed- Returns:
- The handler of the command
-
setHandler
The handler handles what should happen when the command is e.g. getting executed- Parameters:
handler
- The new handler of this command
-
isOnlyForPlayers
boolean isOnlyForPlayers()Whether or not only players are able to execute the command- Returns:
- If the command is only for normal players and not for the console
-
setOnlyForPlayers
void setOnlyForPlayers(boolean onlyForPlayers) Whether or not only players are able to execute the command- Parameters:
onlyForPlayers
- The new value
-
isVisible
boolean isVisible()Returns whether or not this command is visible in help.Interesting for debug or hidden commands which shouldn't be shown to normal players
- Returns:
- Whether or not the command is visible in /bw [...] help
-
setVisible
void setVisible(boolean visible) Set whether or not this command is visible in help.Interesting for debug or hidden commands which shouldn't be shown to normal players
- Parameters:
visible
- The new value
-
hasContentAmount
boolean hasContentAmount()Returns whether or not it'll display the amount of entries in /bw [...] help.The amount is getting fetched by the current handler using
CommandHandler.getContentAmount(org.bukkit.command.CommandSender)
- Returns:
- If it'll display the amount of content or entries in /bw [...] help
-
setHasContentAmount
void setHasContentAmount(boolean hasContentAmount) Set whether or not it'll display the amount of entries in /bw [...] help.The amount is getting fetched by the current handler using
CommandHandler.getContentAmount(org.bukkit.command.CommandSender)
- Parameters:
hasContentAmount
- New value
-