Package wbs.utils.util.commands
Class WbsCommand
java.lang.Object
wbs.utils.util.plugin.WbsMessenger
wbs.utils.util.commands.WbsCommand
- All Implemented Interfaces:
org.bukkit.command.CommandExecutor,org.bukkit.command.TabCompleter,org.bukkit.command.TabExecutor
A command executor that is run entirely by the subcommands added to it.
Automatically handles the initial command and passes the executor args
to the first layer of subcommands.
Automatically tabs to the labels (not aliases) of any added subcommands.
-
Field Summary
Fields inherited from class wbs.utils.util.plugin.WbsMessenger
plugin -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddSubcommand(WbsSubcommand subcommand) Add a subcommand without specifying a permissionaddSubcommand(WbsSubcommand subcommand, String permission) Add a subcommand under a given permissiongetLabelsString(org.bukkit.command.CommandSender sender) Gets a human readable list of all labels for subcommands usable by the given sendergetSubcommandLabels(org.bukkit.command.CommandSender sender) Gets a list of all labels for subcommands usable by the given senderfinal booleanonCommand(@NotNull org.bukkit.command.CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, @NotNull String[] args) booleanonCommandNoArgs(@NotNull org.bukkit.command.CommandSender sender, String label) A method that gets run when no arguments are provided.onTabComplete(@NotNull org.bukkit.command.CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, @NotNull String[] args) protected final booleanrunDefaultCommand(org.bukkit.command.CommandSender sender, String label, String[] args) setDefaultCommand(WbsSubcommand defaultCommand) Set the command to run if an invalid argument is passed in as the first argumentMethods inherited from class wbs.utils.util.plugin.WbsMessenger
broadcast, broadcastActionBar, checkPermission, sendActionBar, sendList, sendList, sendMessage, sendMessageNoPrefix
-
Constructor Details
-
WbsCommand
- Parameters:
plugin- The WbsPlugin this command should be registered tocommand- The PluginCommand this command represents, as defined in the plugin.yml of the given WbsPlugin
-
-
Method Details
-
onCommandNoArgs
public boolean onCommandNoArgs(@NotNull @NotNull org.bukkit.command.CommandSender sender, String label) A method that gets run when no arguments are provided. Overrideable, but defaults to a dynamic usage message that lists the subcommands usable by the sender.- Parameters:
sender- The sender performing this commandlabel- The label they used to get this command- Returns:
- Whether or not the command was successful
-
getSubcommandLabels
Gets a list of all labels for subcommands usable by the given sender- Parameters:
sender- The sender to filter by- Returns:
- The list of labels for subcommands usable by the sender
-
getLabelsString
Gets a human readable list of all labels for subcommands usable by the given sender- Parameters:
sender- The command sender to filter by- Returns:
- A human readable list of subcommand labels
-
onCommand
public final boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull org.bukkit.command.Command command, @NotNull @NotNull String label, @NotNull @NotNull String[] args) - Specified by:
onCommandin interfaceorg.bukkit.command.CommandExecutor
-
runDefaultCommand
-
onTabComplete
public final List<String> onTabComplete(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull org.bukkit.command.Command command, @NotNull @NotNull String label, @NotNull @NotNull String[] args) - Specified by:
onTabCompletein interfaceorg.bukkit.command.TabCompleter
-
setDefaultCommand
Set the command to run if an invalid argument is passed in as the first argument- Parameters:
defaultCommand- The default command- Returns:
- The same WbsCommand (for chaining)
-
addSubcommand
Add a subcommand under a given permission- Parameters:
subcommand- The subcommand to addpermission- The permission to automatically set for the subcommand- Returns:
- The same WbsCommand (for chaining)
-
addSubcommand
Add a subcommand without specifying a permission- Parameters:
subcommand- The subcommand to add- Returns:
- The same WbsCommand (for chaining)
-