Skip to main content

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

org.mineacademy.fo.command.SimpleCommandGroup
  └── MainCommand (inner class extends SimpleCommand)

Creating a command group

Constructors

SimpleCommandGroup()
constructor
Creates a new command group using SimpleSettings.MAIN_COMMAND_ALIASES.Requires a settings class extending SimpleSettings with Command_Aliases defined.
SimpleCommandGroup(String labelAndAliases)
constructor
Creates a new command group with label and aliases separated by | or /.Example: "arena|a|ar" creates /arena with /a and /ar as aliases.
SimpleCommandGroup(String label, List<String> aliases)
constructor
Creates a new command group with explicit label and aliases.
SimpleCommandGroup(StrictList<String> labelAndAliases)
constructor
Creates a new command group from a list where the first item is the label and the rest are aliases.

Basic example

public class ArenaCommandGroup extends SimpleCommandGroup {
    
    public ArenaCommandGroup() {
        super("arena|a|ar");
    }
    
    @Override
    protected void registerSubcommands() {
        registerSubcommand(new ArenaJoinCommand());
        registerSubcommand(new ArenaLeaveCommand());
        registerSubcommand(new ArenaListCommand());
    }
}

Registration

register()

register()
void
Registers this command group into Bukkit and starts using it.Automatically registers all subcommands added in registerSubcommands().

unregister()

unregister()
void
Removes this command group from Bukkit.Takes immediate effect in the game.

isRegistered()

isRegistered()
boolean
Checks if the command group has been registered.
ArenaCommandGroup arenaCmd = new ArenaCommandGroup();
arenaCmd.register();

// Later...
if (arenaCmd.isRegistered()) {
    arenaCmd.unregister();
}

Core methods

registerSubcommands()

registerSubcommands()
abstract void
Required implementation. Override this method to register your subcommands.Call registerSubcommand() for each subcommand you want to add.
@Override
protected void registerSubcommands() {
    registerSubcommand(new CreateSubCommand());
    registerSubcommand(new DeleteSubCommand());
    registerSubcommand(new ListSubCommand());
    
    // Add help text
    registerHelpLine(
        "&6Arena Commands:",
        "&e  Manage your arena battles"
    );
}

Registering subcommands

registerSubcommand(SimpleSubCommand command)

registerSubcommand(SimpleSubCommand command)
void
Registers a new subcommand for this group.

registerSubcommand(Class<? extends SimpleSubCommand> parentClass)

registerSubcommand(Class<? extends SimpleSubCommand> parentClass)
void
Automatically registers all extending classes for the given parent class.Ignores abstract classes. Child classes must be final.
@Override
protected void registerSubcommands() {
    // Auto-register all subcommands extending ArenaSubCommand
    registerSubcommand(ArenaSubCommand.class);
}
When using auto-registration, ensure all child classes are final to avoid accidental registration of intermediate classes.

registerHelpLine(String… menuHelp)

registerHelpLine(String... menuHelp)
void
Registers simple help messages for this group.Displayed in the help menu along with subcommands.
registerHelpLine(
    "",
    "&6Plugin Information:",
    "&7Version: " + getDescription().getVersion(),
    "&7Author: YourName"
);

Customization methods

getNoParamsHeader()

getNoParamsHeader()
List<SimpleComponent>
Returns the message displayed when no parameters are given.By default, displays plugin credits and author information.
@Override
protected List<SimpleComponent> getNoParamsHeader() {
    return Arrays.asList(
        SimpleComponent.of("&8" + Common.chatLineSmooth()),
        SimpleComponent.of("&6&lArena Plugin &7v1.0"),
        SimpleComponent.of("&7Type &f/arena help &7for commands"),
        SimpleComponent.of("&8" + Common.chatLineSmooth())
    );
}

sendHelpIfNoArgs()

sendHelpIfNoArgs()
boolean
Should we send command help instead of the no-params header when no arguments are provided?Default: false
@Override
protected boolean sendHelpIfNoArgs() {
    return true; // Show help menu when just /arena is typed
}

getHelpLabel()

getHelpLabel()
List<String>
Returns which subcommands should trigger the automatic help menu.Default: ["help", "?"]
@Override
protected List<String> getHelpLabel() {
    return Arrays.asList("help", "?", "commands");
}

getHelpHeader()

getHelpHeader()
String[]
Returns the header messages for the help menu.Displayed at the top of /arena help or /arena ?.
@Override
protected String[] getHelpHeader() {
    return new String[] {
        "&8&m------------------------------",
        "&6&lArena Commands",
        " ",
        "&2  [] &f= Optional",
        "&6  <> &f= Required",
        " "
    };
}

getSubcommandDescription()

getSubcommandDescription()
String
Returns the format for subcommand descriptions in the help menu.Available placeholders: {label}, {sublabel}, {usage}, {description}, {dash}

getCredits()

getCredits()
String
Returns credits text shown in the no-params header.Typically shows your website or support information.
@Override
protected String getCredits() {
    return "&7Visit &fwww.example.com &7for support";
}

getHeaderPrefix()

getHeaderPrefix()
String
Returns the default color/style prefix used in headers.Default: GOLD + BOLD

getTheme()

getTheme()
ChatColor
Returns the theme color used in various places of the help menu.Default: ChatColor.GOLD
@Override
protected ChatColor getTheme() {
    return ChatColor.AQUA;
}

getCommandsPerPage()

getCommandsPerPage()
int
Returns how many commands to display per page in the help menu.Default: 12
@Override
protected int getCommandsPerPage() {
    return 8; // Show fewer commands per page
}

Setters

setLabel(String label)

setLabel(String label)
void
Updates the command label.Only works if the command is not registered yet.

setAliases(List<String> aliases)

setAliases(List<String> aliases)
void
Updates the command aliases.Only works if the command is not registered yet.
Both setLabel() and setAliases() can only be used before registration. Attempting to use them on a registered command group will throw an error.

Getters

getLabel()

getLabel()
String
Gets the main command label.

getAliases()

getAliases()
List<String>
Gets the command aliases.

getSender()

getSender()
CommandSender
Gets the temporary sender currently viewing the command group.Mainly used in customization methods like getNoParamsHeader().

Complete example

public class ArenaCommandGroup extends SimpleCommandGroup {
    
    public ArenaCommandGroup() {
        super("arena|a");
    }
    
    @Override
    protected void registerSubcommands() {
        // Register individual subcommands
        registerSubcommand(new ArenaJoinCommand());
        registerSubcommand(new ArenaLeaveCommand());
        registerSubcommand(new ArenaListCommand());
        registerSubcommand(new ArenaCreateCommand());
        registerSubcommand(new ArenaDeleteCommand());
        
        // Add custom help text
        registerHelpLine(
            "",
            "&6Arena System:",
            "&7  Create and manage PvP arenas",
            "&7  Players can join, leave, and battle"
        );
    }
    
    @Override
    protected boolean sendHelpIfNoArgs() {
        return true; // Show help when /arena is typed
    }
    
    @Override
    protected ChatColor getTheme() {
        return ChatColor.RED; // Use red theme for arena commands
    }
    
    @Override
    protected String getCredits() {
        return "&7Arena plugin by &fYourName";
    }
    
    @Override
    protected String[] getHelpHeader() {
        return new String[] {
            "&8&m------------------------------",
            "&c&lArena Commands &7v1.0",
            " ",
            "&2  [] &f= Optional parameter",
            "&c  <> &f= Required parameter",
            " "
        };
    }
}

Automatic features

The command group automatically provides:
Players can type /arena help or /arena ? to see all subcommands they have permission for.The help menu includes:
  • Command usage syntax
  • Description (on hover in 1.7+)
  • Required permission (on hover)
  • Click to suggest command
  • Automatic pagination

Registration patterns

In your main plugin class

public class MyPlugin extends SimplePlugin {
    
    @Override
    protected void onPluginStart() {
        ArenaCommandGroup arenaCmd = new ArenaCommandGroup();
        arenaCmd.register();
    }
}

Using auto-register annotation

@AutoRegister
public class ArenaCommandGroup extends SimpleCommandGroup {
    // Constructor and methods...
}
The @AutoRegister annotation automatically registers your command group when the plugin starts, as long as it has a no-args constructor.

See also

Build docs developers (and LLMs) love