Annotation Interface Command


@Target(METHOD) @Retention(RUNTIME) public @interface Command
Marks a method as a command definition for registration via the CommandBus.

Methods annotated with @Command must accept a single parameter of type LiteralArgumentBuilder and will be invoked during command registration.

The method must be registered using CommandBus.register(String, Object) to be active. The provided name is used as the literal root node of the Brigadier command.

Example usage:

@Command(name = "example")
public void exampleCommand(LiteralArgumentBuilder<CommandSourceStack> builder) {
    builder.executes(ctx -> {
        return 1;
    });
}
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name of the command.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
     
  • Field Details

  • Element Details

    • name

      String name
      The name of the command. This becomes the literal root node in the Brigadier tree.
      Returns:
      the command name
    • aliases

      String[] aliases
      Default:
      {}