Annotation Interface Command


@Retention(RUNTIME) @Target(METHOD) public @interface Command
Marks a method as a command handler.

Methods annotated with @Command will automatically be registered as server commands when the plugin is enabled. The method must accept a CommandContext parameter.

Usage Example:


@Command(name = "hello", description = "Greets the player")
public void onHello(CommandContext ctx) {
    ctx.sender().sendMessage(Message.raw("Hello!"));
}

@Command(name = "teleport", aliases = { "tp",
        "warp" }, permission = "myplugin.teleport", description = "Teleports a player")
public void onTeleport(CommandContext ctx) {
    // Teleport logic
}

Since:
1.0.0
Version:
1.0.4
Author:
HytaleLoader
  • 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
    Alternative names for this command.
    A human-readable description of what the command does.
    The permission required to execute this command.
    boolean
    Whether this command requires user confirmation before execution.
  • Element Details

    • name

      String name
      The name of the command.

      This is the primary way players will invoke the command. Example: name = "hello" creates the /hello command.

      Returns:
      the command name
    • description

      String description
      A human-readable description of what the command does.

      This description may be shown in help menus or command listings.

      Returns:
      the command description
      Default:
      ""
    • aliases

      String[] aliases
      Alternative names for this command.

      Players can use any of these aliases to invoke the same command. Example: aliases = {"tp", "warp"} allows /tp and /warp.

      Returns:
      array of command aliases
      Default:
      {}
    • permission

      String permission
      The permission required to execute this command.

      If specified, only players with this permission can use the command. If empty, the command is available to all players.

      Returns:
      the required permission node
      Default:
      ""
    • requiresConfirmation

      boolean requiresConfirmation
      Whether this command requires user confirmation before execution.

      Useful for dangerous or irreversible operations.

      Returns:
      true if confirmation is required, false otherwise
      Default:
      false