Annotation 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 -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionString[]Alternative names for this command.A human-readable description of what the command does.The permission required to execute this command.booleanWhether this command requires user confirmation before execution.
-
Element Details
-
name
String nameThe name of the command.This is the primary way players will invoke the command. Example:
name = "hello"creates the/hellocommand.- Returns:
- the command name
-
description
String descriptionA 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[] aliasesAlternative names for this command.Players can use any of these aliases to invoke the same command. Example:
aliases = {"tp", "warp"}allows/tpand/warp.- Returns:
- array of command aliases
- Default:
{}
-
permission
String permissionThe 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 requiresConfirmationWhether this command requires user confirmation before execution.Useful for dangerous or irreversible operations.
- Returns:
trueif confirmation is required,falseotherwise
- Default:
false
-