Tree-based commands

To get started with OneConfig's tree-based (Brigadier-style) command system, you'll need to get started by creating a CommandBuilder:

CommandBuilder builder = CommandBuilder.command("examplemod", "example", "example_mod");

From here, if you want to do something when the command is run on it's own (f.ex /examplemod), you can use the runs method to define what is executed, like so:

builder.then(CommandBuilder.runs().does(() -> {
    System.out.println("Hello, OneConfig!");
}));

Both the object which command and runs returns have a description method which allow you to describe what happens when you execute that command or subcommand, it is recommended to use this where possible.

Finally, to register your command, you can simply use CommandManager#registerCommand like so:

CommandManager.registerCommand(builder.build());

Last updated