Skip to content

Commands

This section covers the command API for mod developers creating custom 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, --named args, 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
GreetCommand.java
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)));
}
}
src/main/resources/Server/Languages/en-US/myplugin/commands.lang
greet.desc = Greet someone by name
greet.name.desc = Name to greet
greet.success = Hello, {name}!

Register in your mod’s setup() method:

@Override
protected void setup() {
this.getCommandRegistry().registerCommand(new GreetCommand());
}
com.hypixel.hytale
├── server.core.command
│ ├── system/ # Command system
│ │ ├── basecommands/ # Base classes
│ │ └── arguments/ # Arguments
│ └── commands/ # Built-in commands
└── builtin/ # Builtin plugins