-
Notifications
You must be signed in to change notification settings - Fork 0
Subcommand Groups
mario edited this page Mar 29, 2026
·
2 revisions
@Subcommand on a class declares root aliases once. Every @Command method inside
inherits them automatically — changing the root name requires editing a single line.
This works identically on Bukkit, BungeeCord, and Velocity.
| Property | Type | Description |
|---|---|---|
names |
String[] |
One or more root aliases to prepend to every method's command names. |
For @Subcommand(names = {"party", "p"}) with @Command(names = {"invite", "inv"}):
| Root | Method | Registered as |
|---|---|---|
| party | invite | /party invite |
| party | inv | /party inv |
| p | invite | /p invite |
| p | inv | /p inv |
@Subcommand(names = {"party", "p"})
public class PartyCommands {
@Command(names = {"invite"}, playerOnly = true)
public void invite(Player sender, @Param(name = "player") Player target) {
sender.sendMessage("Invited " + target.getName() + " to your party.");
}
@Command(names = {"leave"}, playerOnly = true)
public void leave(Player sender) {
sender.sendMessage("You left the party.");
}
@Command(names = {"disband"}, playerOnly = true, permission = "plugin.party.disband")
public void disband(Player sender) {
sender.sendMessage("Party disbanded.");
}
@Help(names = {"party", "p"})
public void help(CommandSender sender) {
sender.sendMessage("/party invite <player> — Invite a player.");
sender.sendMessage("/party leave — Leave your party.");
sender.sendMessage("/party disband — Disband your party.");
}
}Classes without @Subcommand continue to work exactly as before — fully backward-compatible.
public class FactionCommands {
@Command(names = {"f create", "faction create"}, permission = "plugin.faction.create", playerOnly = true)
public void create(Player sender, @Param(name = "name") String name) { ... }
}