Package wbs.utils.util.commands
Class WbsSubcommand
java.lang.Object
wbs.utils.util.plugin.WbsMessenger
wbs.utils.util.commands.WbsSubcommand
- Direct Known Subclasses:
WbsCommandNode,WbsErrorsSubcommand,WbsReloadSubcommand
A "leaf" of a WbsCommand. WbsSubcommands are called from WbsCommands or
WbsCommandNodes to run their command.
-
Field Summary
Fields inherited from class wbs.utils.util.plugin.WbsMessenger
plugin -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd an alternative label to use instead of label.addAliases(String... aliases) Add multiple aliases for this subcommandReturns a copy of the collection of aliases for this subcommand@NotNull StringgetLabel()@NotNull StringgetTabCompletions(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String[] args) getTabCompletions(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String[] args, int start) booleanCheck if the given String is an alias of this subcommandprotected booleanonCommand(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String[] args) Run this subcommand for the given sender, starting at arg[start].protected booleanonCommand(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String[] args, int start) Run this subcommand for the given sender, starting at arg[start].protected final booleanonCommandCheckPermission(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String[] args, int start) Check this command's permission, and if successful, run the implementing class's onCommand methodprotected final voidprotected final voidsendUsage(String usage, org.bukkit.command.CommandSender sender, String label, String[] args, int count) setAliases(Set<String> aliases) Sets the list of aliases for this subcommand to the provided value, removing all existing ones.@NotNull WbsSubcommandsetPermission(@NotNull String permission) Sets the permission needed to use this subcommandMethods inherited from class wbs.utils.util.plugin.WbsMessenger
broadcast, broadcastActionBar, checkPermission, sendActionBar, sendList, sendList, sendMessage, sendMessageNoPrefix
-
Constructor Details
-
WbsSubcommand
- Parameters:
plugin- The plugin to use for messaginglabel- The label for this subcommand
-
-
Method Details
-
onCommand
protected boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args) Run this subcommand for the given sender, starting at arg[start]. When this is called, the permission has already been checked.- Parameters:
sender- The sender that ran the commandlabel- The alias used to run this commandargs- The arguments provided- Returns:
- false if the command failed unexpectedly, true otherwise
-
onCommand
protected boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args, int start) Run this subcommand for the given sender, starting at arg[start]. When this is called, the permission has already been checked.- Parameters:
sender- The sender that ran the commandlabel- The alias used to run this commandargs- The arguments provided- Returns:
- false if the command failed unexpectedly, true otherwise
-
onCommandCheckPermission
protected final boolean onCommandCheckPermission(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args, int start) Check this command's permission, and if successful, run the implementing class's onCommand method- Parameters:
sender- The sender that ran the commandlabel- The alias used to run this commandargs- The arguments providedstart- The index that was reached before running this command- Returns:
- false if the command failed unexpectedly, true otherwise
-
sendUsage
-
sendUsage
-
setPermission
Sets the permission needed to use this subcommand- Parameters:
permission- The permission that will be needed to use this subcommand- Returns:
- The same WbsSubcommand (for chaining)
-
getPermission
- Returns:
- The permission required to use this subcommand
-
addAlias
Add an alternative label to use instead of label. The added alias does not appear in tabbing.- Parameters:
alias- A new alias for this subcommand- Returns:
- The same WbsSubcommand (for chaining)
-
addAliases
Add multiple aliases for this subcommand- Parameters:
aliases- Any number of Strings that this subcommand can be referenced by- Returns:
- The same WbsSubcommand (for chaining)
-
setAliases
Sets the list of aliases for this subcommand to the provided value, removing all existing ones.- Parameters:
aliases- The new aliases to be used for this subcommand.- Returns:
- The same WbsSubcommand (for chaining)
-
getAliases
Returns a copy of the collection of aliases for this subcommand- Returns:
- A copy of the collection of aliases
-
isAliased
Check if the given String is an alias of this subcommand- Parameters:
check- The String to check- Returns:
- True if the given String can be used to reference this subcommand, via an alias or the label
-
getLabel
- Returns:
- The label of this subcommand
-
getTabCompletions
-
getTabCompletions
-