Command System
Command annotations
Section titled “Command annotations”SSEC command registration is built around five annotations:
@SSCommanddeclares a root command or subcommand class@SSCExecutemarks the executable method@SSCArgumentmaps method parameters to Brigadier arguments@SSCAliasregisters redirect aliases@SSCPermissionapplies permission rules
Shape of a command
Section titled “Shape of a command”@SSCommand("greeting")@SSCAlias({ "hi", "hello" })@SSCPermission(permission = PermissionLevel.GAME_MASTER)public class GreetingCommand {
@SSCExecute public static void execute( CommandContext<CommandSourceStack> ctx, @SSCArgument("name") String name ) { // ... }
@SSCommand(value = "shout", parent = GreetingCommand.class) public static class ShoutCommand { @SSCExecute public static void execute( CommandContext<CommandSourceStack> ctx, @SSCArgument("msg") String msg ) { // ... } }}This produces a root command plus a nested subcommand without hand-writing literal and argument builders.
What CommandRegistrar does
Section titled “What CommandRegistrar does”The registrar:
- verifies
@SSCommandis present - builds a Brigadier tree from the annotated class graph
- resolves parent-child relationships, including cross-file parents
- registers root aliases and subcommand aliases
- applies permission predicates
- maps Java parameter types to Brigadier argument types through the adapter registry
Built-in argument adapters
Section titled “Built-in argument adapters”CommandRegistrar pre-registers adapters for primitives, strings, vectors, entities, block positions, NBT, scoreboard types, colors, styles, UUIDs, and more.
For the full supported set, see Argument Types.
Custom argument types
Section titled “Custom argument types”If a parameter type is not built in, register an SSCArgumentAdapter during onInitializeSSEC().
public class MyCommandInitializer implements SSECInitializer { @Override public void onInitializeSSEC() { CommandRegistrar.registerAdapter(MyType.class, new MyTypeAdapter()); }
@Override public String[] getPackagesToScan() { return new String[] { "com.example.mymod.command" }; }}Practical rules
Section titled “Practical rules”- Keep
@SSCExecutemethods static unless you have a reason to instantiate a target. - Put reusable permission policy on the command class, then use
propagatewhen children should inherit it. - Register custom adapters before the scan runs.
- Treat aliases as redirects, not independent command implementations.