Package wbs.utils.util.commands
Class WbsCommandNode
java.lang.Object
wbs.utils.util.plugin.WbsMessenger
wbs.utils.util.commands.WbsSubcommand
wbs.utils.util.commands.WbsCommandNode
An implementation of WbsSubcommand that simply passes the command to
a given subcommand, including tabbing, or provides default usage messages
when no args or incorrect args are given.
-
Field Summary
Fields inherited from class wbs.utils.util.plugin.WbsMessenger
plugin -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(WbsSubcommand subcommand) Adds a child subcommandvoidaddChild(WbsSubcommand subcommand, String permission) Adds a child permission and automatically sets the permission for that subcommandprotected intgetSubcommandLabels(org.bukkit.command.CommandSender sender) Gets a list of all labels for subcommands usable by the given sendergetTabCompletions(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String[] args, int start) protected final booleanonCommand(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String[] args) Theoretically should never be called, only being implemented here since the start version is implemented, and implementing subclasses shouldn't be able to implement this (as they might expect it to be called).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 booleanonCommandNoArgs(@NotNull org.bukkit.command.CommandSender sender, @NotNull String label, @NotNull String[] args, int start) Methods inherited from class wbs.utils.util.commands.WbsSubcommand
addAlias, addAliases, getAliases, getLabel, getPermission, getTabCompletions, isAliased, onCommandCheckPermission, sendUsage, sendUsage, setAliases, setPermissionMethods inherited from class wbs.utils.util.plugin.WbsMessenger
broadcast, broadcastActionBar, checkPermission, sendActionBar, sendList, sendList, sendMessage, sendMessageNoPrefix
-
Constructor Details
-
WbsCommandNode
- Parameters:
plugin- The WbsPluginlabel- The label for this node
-
-
Method Details
-
addChild
Adds a child subcommand- Parameters:
subcommand- The child subcommand to pass to if the label is given
-
addChild
Adds a child permission and automatically sets the permission for that subcommand- Parameters:
subcommand- The child subcommand to pass to if the label is givenpermission- The permission to apply to the child subcommand
-
onCommand
protected boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args, int start) Description copied from class:WbsSubcommandRun this subcommand for the given sender, starting at arg[start]. When this is called, the permission has already been checked.- Overrides:
onCommandin classWbsSubcommand- 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 final boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args) Theoretically should never be called, only being implemented here since the start version is implemented, and implementing subclasses shouldn't be able to implement this (as they might expect it to be called).- Overrides:
onCommandin classWbsSubcommand- 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
-
onCommandNoArgs
-
getTabCompletions
public List<String> getTabCompletions(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args, int start) - Overrides:
getTabCompletionsin classWbsSubcommand
-
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
-
getArgLength
protected int getArgLength()- Returns:
- The number of arguments this node will process before handing off to the child
-