Skip to main content

Overview

Blade provides a rich set of annotations to control command behavior, permissions, visibility, and execution. These annotations are applied to command methods to customize their functionality.

Core Annotations

Sets the description displayed in help messages.
@Command("heal")
@Description("Restore your health to full")
public void healCommand(@Sender Player player) {
    player.setHealth(20.0);
}
Source: me/vaperion/blade/annotation/command/Description.java:15-23Properties:
  • value() - The description string
Target: ElementType.METHOD

Usage Annotations

Provides a custom usage message instead of the auto-generated one.
@Command("tp")
@Usage("/tp <player> or /tp <x> <y> <z>")
public void teleportCommand(@Sender Player player, @Greedy String args) {
    // Custom parsing logic
}
Source: me/vaperion/blade/annotation/command/Usage.java:17-20
If not specified, Blade automatically generates a usage message based on the command’s parameters.

Input Parsing Annotations

@Quoted

Enables quote parsing for command arguments. Source: me/vaperion/blade/annotation/command/Quoted.java:20-21 Method-Level:
@Command("announce")
@Quoted
public void announceCommand(@Sender Player player, String title, String message) {
    // /announce "Server Event" "Join us for a special event!"
    // title = "Server Event"
    // message = "Join us for a special event!"
}
Parameter-Level:
@Command("setname")
public void setNameCommand(@Sender Player player, Player target, @Quoted String name) {
    // /setname Steve "The Builder"
    // Only the 'name' parameter supports quotes
}
Without @Quoted, arguments are split by spaces. With quotes, text within quotes is treated as a single argument.

Annotation Combinations

Annotations can be combined for sophisticated command behavior:
@Command({"sudo", "runas"})
@Description("Execute a command as another player")
@Permission(value = "server.admin.sudo", message = "Only admins can use sudo!")
@Async
@Quoted
public void sudoCommand(@Sender Player admin, Player target, @Greedy String command) {
    // Executes 'command' as if 'target' typed it
    performAsyncSudoExecution(target, command);
}

Best Practices

  1. Always provide @Description for user-facing commands
  2. Use @Hidden for debug/admin commands that shouldn’t be advertised
  3. Apply @Async for database queries, file I/O, or network requests
  4. Combine @Permission with @Hidden for secret admin commands
  5. Use @Quoted sparingly - most users don’t know about quote syntax

Configuration in Builder

Some annotation behaviors can be configured when building Blade:
Blade blade = Blade.forPlatform(platform)
    .config(cfg -> {
        // Default permission denial message
        cfg.defaultPermissionMessage("You don't have permission!");
    })
    .build();
Reference: me/vaperion/blade/command/BladeCommand.java:91

Build docs developers (and LLMs) love