Hytale-documentation.github.io

Command System

The Command System allows plugins to register custom commands that players or the console can execute.

Key Classes

Creating a Command

To create a command, extend com.hypixel.hytale.server.core.command.system.AbstractCommand.

public class MyCommand extends AbstractCommand {
    public MyCommand() {
        super("mycommand", "Description of what it does");
        addAliases("mc", "myc");
        // Permissions are automatically generated: pluginName.command.mycommand
    }

    @Override
    public CompletableFuture<Void> execute(CommandContext context) {
        CommandSender sender = context.getSender();
        sender.sendMessage("Hello from MyCommand!");
        return CompletableFuture.completedFuture(null);
    }
}

Registering a Command

Register your command in your plugin’s setup() method.

@Override
public void setup() {
    getCommandRegistry().registerCommand(new MyCommand());
}

Subcommands

You can add subcommands using addSubCommand() in your command’s constructor.

public MyCommand() {
    super("parent", "Parent command");
    addSubCommand(new ChildCommand());
}

Permissions

Permissions are automatically checked before execute is called. You can check permissions manually using sender.hasPermission("my.perm").