Class CommandGroup

java.lang.Object
com.github.pinont.singularitylib.api.command.CommandGroup
All Implemented Interfaces:
SimpleCommand, io.papermc.paper.command.brigadier.BasicCommand

public abstract class CommandGroup extends Object implements SimpleCommand
A command that groups SubCommands under one root label, with an auto-generated help menu when invoked with no arguments.

Consumers create a subclass, register subcommands in the constructor, and register the group via CommandManager (or registerComponents()).

CommandGroup arena = new CommandGroup() {
    {
        registerSubcommand(new ArenaCreateSub());
        registerSubcommand(new ArenaDeleteSub());
    }
};
  • Constructor Details

    • CommandGroup

      public CommandGroup()
  • Method Details

    • registerSubcommand

      public final void registerSubcommand(SubCommand sub)
      Registers a subcommand (also registers its aliases via name:alias).
    • getSubcommandNames

      public List<String> getSubcommandNames()
      Returns:
      immutable list of registered subcommand names
    • execute

      public void execute(io.papermc.paper.command.brigadier.CommandSourceStack source, String[] args)
      Specified by:
      execute in interface io.papermc.paper.command.brigadier.BasicCommand
    • execute

      public void execute(org.bukkit.command.CommandSender sender, String[] args)
      Dispatches to subcommands using a plain CommandSender (console-friendly and unit-testable without a CommandSourceStack).
    • getUsageHint

      protected String getUsageHint(String unknown)
      Returns:
      a red "unknown subcommand" hint
    • sendHelp

      public void sendHelp(org.bukkit.command.CommandSender sender)
      Sends the paginated help listing to the sender.
    • usage

      public String usage(Boolean bool)
      Description copied from interface: SimpleCommand
      Gets the usage string for this command.
      Specified by:
      usage in interface SimpleCommand
      Parameters:
      bool - unused parameter for compatibility
      Returns:
      the usage string for this command