OneConfig V1
  • Welcome
  • Documentation license
  • Introduction
    • Getting started
  • Configuration
    • Creating your config
      • Option dependencies & hiding options
      • Listening for option changes
    • Available options
      • Boolean options
        • Switch option
        • Checkbox option
      • Number options
        • Slider option
        • Number option
      • Selector options
        • Dropdown option
        • Radio button option
      • Text option
      • Color option
      • Keybind option
      • Buttons
      • Accordions
      • Decorations
    • Creating your own options
  • Commands
    • Annotation-based commands
    • Tree-based commands
  • Events
    • Using the events system
      • Callback events
      • Subscriber events
  • Utilities Module
    • Hypixel utilities
    • IO utilities
    • Networking utilities
    • JSON utilities
    • Multithreading
    • Platform-specific utilities
  • Migration
    • Temporary V0 -> V1 migration guide
    • Migrating your configs from Vigilance
Powered by GitBook
On this page
Export as PDF
  1. Commands

Tree-based commands

PreviousAnnotation-based commandsNextUsing the events system

Last updated 5 months ago

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

CommandBuilder builder = CommandBuilder.command("examplemod", "example", "example_mod");
val 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!");
}));
builder.then(CommandBuilder.runs().does {
    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());
CommandManager.registerCommand(builder.build())

Brigadier