Commands
This section covers the command API for mod developers creating custom commands.
Creating Commands
Section titled “Creating Commands”Learn how to build custom commands for your mods:
- Creating Commands - Getting started guide with subcommands, usage variants, and translations
- Command Syntax - Tokenization, quoting,
--namedargs, relative coordinates, and the parsing pipeline - Base Classes - CommandBase, AbstractPlayerCommand, AbstractTargetPlayerCommand, AbstractCommandCollection, etc.
- Arguments - RequiredArg, OptionalArg, FlagArg, ArgTypes (enums, positions, validators)
- Permissions - Permission system, groups, and the self/other pattern
Quick Example
Section titled “Quick Example”public class GreetCommand extends CommandBase { private final RequiredArg<String> nameArg;
public GreetCommand() { super("greet", "myplugin.commands.greet.desc"); this.nameArg = this.withRequiredArg("name", "myplugin.commands.greet.name.desc", ArgTypes.STRING); this.requirePermission("myplugin.command.greet"); }
@Override protected void executeSync(@Nonnull CommandContext context) { context.sendMessage(Message.translation("myplugin.commands.greet.success") .param("name", this.nameArg.get(context))); }}greet.desc = Greet someone by namegreet.name.desc = Name to greetgreet.success = Hello, {name}!Register in your mod’s setup() method:
@Overrideprotected void setup() { this.getCommandRegistry().registerCommand(new GreetCommand());}Code Location
Section titled “Code Location”com.hypixel.hytale├── server.core.command│ ├── system/ # Command system│ │ ├── basecommands/ # Base classes│ │ └── arguments/ # Arguments│ └── commands/ # Built-in commands└── builtin/ # Builtin plugins