Overview
SimpleCommandGroup allows you to organize multiple related subcommands under a single main command. For example, /arena join, /arena leave, /arena list would all be subcommands of the /arena command group.
The command group automatically handles help menus, tab completion, and subcommand routing.
Class hierarchy
Creating a command group
Constructors
Creates a new command group using
SimpleSettings.MAIN_COMMAND_ALIASES.Requires a settings class extending SimpleSettings with Command_Aliases defined.Creates a new command group with label and aliases separated by
| or /.Example: "arena|a|ar" creates /arena with /a and /ar as aliases.Creates a new command group with explicit label and aliases.
Creates a new command group from a list where the first item is the label and the rest are aliases.
Basic example
Registration
register()
Registers this command group into Bukkit and starts using it.Automatically registers all subcommands added in
registerSubcommands().unregister()
Removes this command group from Bukkit.Takes immediate effect in the game.
isRegistered()
Checks if the command group has been registered.
Core methods
registerSubcommands()
Required implementation. Override this method to register your subcommands.Call
registerSubcommand() for each subcommand you want to add.Registering subcommands
registerSubcommand(SimpleSubCommand command)
Registers a new subcommand for this group.
registerSubcommand(Class<? extends SimpleSubCommand> parentClass)
Automatically registers all extending classes for the given parent class.Ignores abstract classes. Child classes must be final.
When using auto-registration, ensure all child classes are
final to avoid accidental registration of intermediate classes.registerHelpLine(String… menuHelp)
Registers simple help messages for this group.Displayed in the help menu along with subcommands.
Customization methods
getNoParamsHeader()
Returns the message displayed when no parameters are given.By default, displays plugin credits and author information.
sendHelpIfNoArgs()
Should we send command help instead of the no-params header when no arguments are provided?Default:
falsegetHelpLabel()
Returns which subcommands should trigger the automatic help menu.Default:
["help", "?"]getHelpHeader()
Returns the header messages for the help menu.Displayed at the top of
/arena help or /arena ?.getSubcommandDescription()
Returns the format for subcommand descriptions in the help menu.Available placeholders:
{label}, {sublabel}, {usage}, {description}, {dash}getCredits()
Returns credits text shown in the no-params header.Typically shows your website or support information.
getHeaderPrefix()
Returns the default color/style prefix used in headers.Default: GOLD + BOLD
getTheme()
Returns the theme color used in various places of the help menu.Default:
ChatColor.GOLDgetCommandsPerPage()
Returns how many commands to display per page in the help menu.Default:
12Setters
setLabel(String label)
Updates the command label.Only works if the command is not registered yet.
setAliases(List<String> aliases)
Updates the command aliases.Only works if the command is not registered yet.
Getters
getLabel()
Gets the main command label.
getAliases()
Gets the command aliases.
getSender()
Gets the temporary sender currently viewing the command group.Mainly used in customization methods like
getNoParamsHeader().Complete example
Automatic features
The command group automatically provides:Registration patterns
In your main plugin class
Using auto-register annotation
The
@AutoRegister annotation automatically registers your command group when the plugin starts, as long as it has a no-args constructor.See also
- SimpleCommand - Base command class
- SimpleSubCommand - For creating subcommands