Class SubCommand

java.lang.Object
com.github.pinont.singularitylib.api.command.SubCommand

public abstract class SubCommand extends Object
A subcommand within a CommandGroup. Implementations provide a name, optional permission, and the execution + tab-completion for their own args.

Usage (from a CommandGroup):

group.registerSubcommand(new MySubCommand());
  • Constructor Details

    • SubCommand

      public SubCommand()
  • Method Details

    • getName

      public abstract String getName()
      Returns:
      the subcommand name (first arg after the root label)
    • getPermission

      public String getPermission()
      Returns:
      optional permission node (e.g. "mineplugin.admin"), or null/"" for none
    • getDescription

      public String getDescription()
      Returns:
      short description shown in the auto-generated help menu
    • execute

      public abstract void execute(org.bukkit.command.CommandSender sender, String[] args)
      Executes the subcommand.
      Parameters:
      sender - the command sender
      args - the arguments AFTER the subcommand name
    • execute

      public void execute(io.papermc.paper.command.brigadier.CommandSourceStack source, String[] args)
      Convenience overload used by CommandGroup (extracts the sender).
    • isPlayerOnly

      public boolean isPlayerOnly()
      Optionally restrict to players only.
      Returns:
      true if this subcommand requires a Player sender
    • checkPermission

      protected boolean checkPermission(org.bukkit.command.CommandSender sender)
      Checks the sender's permission for this subcommand.
    • checkConsole

      protected boolean checkConsole(org.bukkit.command.CommandSender sender)
      Checks that the sender is allowed for this subcommand (console vs player).