Skip to main content

Overview

LiquidBounce’s command system provides a powerful way to interact with the client through chat commands. Commands support auto-completion, parameter validation, subcommands, and custom aliases.
By default, the command prefix is . - you can change this in the command settings

Command Manager

The CommandManager is the central registry for all commands. It handles command registration, execution, parsing, and auto-completion.
object CommandManager : Collection<Command> {
    object GlobalSettings : ValueGroup("Commands") {
        var prefix by text("Prefix", ".")
        val hintCount by int("HintCount", 5, 0..10)
    }
}
Source: features/command/CommandManager.kt:97-117

Command Categories

Commands are organized into logical categories based on their functionality:
Control core client features and settings
  • friend - Manage your friends list
  • toggle - Enable/disable modules
  • bind - Assign keybinds to modules
  • config - Load and save configurations
  • script - Manage custom scripts
  • hide - Hide/show modules from the HUD
  • panic - Emergency disable all modules
  • value - Modify module settings
Registered in CommandManager.kt:124-170

Command Architecture

Command Structure

Commands are built using the CommandBuilder DSL:
CommandBuilder
    .begin("commandname")
    .parameter(
        ParameterBuilder
            .begin<String>("paramname")
            .required()
            .build()
    )
    .handler { context ->
        // Command execution logic
    }
    .build()

Subcommands

Commands can have nested subcommands for complex operations:
CommandBuilder
    .begin("friend")
    .hub()  // Mark as command hub
    .subcommand(createAddSubcommand())
    .subcommand(createRemoveSubcommand())
    .subcommand(createListSubcommand())
    .build()
The hub() modifier indicates the command only routes to subcommands

Real Example: Friend Command

The Friend command demonstrates a complete command with multiple subcommands:
object CommandFriend : Command.Factory {
    override fun createCommand(): Command {
        return CommandBuilder
            .begin("friend")
            .hub()
            .subcommand(createAddSubcommand())
            .subcommand(createRemoveSubcommand())
            .subcommand(createAliasSubcommand())
            .subcommand(createListSubcommand())
            .subcommand(createClearSubcommand())
            .build()
    }
}
Source: features/command/commands/client/CommandFriend.kt:52-100

Command Execution

The CommandManager.execute() method handles the complete command lifecycle:
1

Tokenization

The input string is parsed into tokens, respecting quotes and escapes:
.friend add "Senk Ju" -> [.friend, add, Senk Ju]
Reference: CommandManager.kt:398-451
2

Command Resolution

The command tree is traversed to find the matching command and subcommands:
private fun getSubCommand(
    args: List<String>,
    currentCommand: Pair<Command, Int>? = null,
    idx: Int = 0
): Pair<Command, Int>?
Reference: CommandManager.kt:208-228
3

Parameter Validation

Each parameter is validated and parsed according to its type:
when (val validationResult = parameter.verifier.verifyAndParse(argument)) {
    is Result.Ok -> validationResult.mappedResult
    is Result.Error -> throw CommandException(...)
}
Reference: CommandManager.kt:368-389
4

Handler Execution

The command handler is invoked with validated parameters:
val ctx = Command.Handler.Context(command, parsedParameters)
with(command.handler!!) { ctx() }
Reference: CommandManager.kt:360-363

Parameter Types

Commands support various parameter types with built-in validation:
ParameterBuilder
    .begin<String>("message")
    .required()
    .build()
Accepts any text input, supports quotes for spaces

Auto-Completion

The command system provides intelligent auto-completion:
fun autoComplete(origCmd: String, start: Int): CompletableFuture<Suggestions> {
    val tokenized = tokenizeCommand(cmd)
    val builder = SuggestionsBuilder(origCmd, currentArgStart + prefix.length)
    
    // Suggest matching commands
    rootCommandMap.subMap(arg, arg + Char.MAX_VALUE)
        .values.forEach { command ->
            builder.suggest(command.name)
        }
    
    return builder.buildFuture()
}
Source: CommandManager.kt:453-514
Auto-completion supports:
  • Command names and aliases
  • Subcommand suggestions
  • Parameter value hints
  • Player name completion
  • Module name completion

Error Handling

The command system provides helpful error messages with suggestions:
throw CommandException(
    translation("liquidbounce.commandManager.unknownCommand", args[0]),
    usageInfo = commandSet.sortedBy { command ->
        levenshtein(args[0], command.name)  // Suggest similar commands
    }.take(GlobalSettings.hintCount)
)
The hintCount setting controls how many command suggestions are shown for typos

Creating Custom Commands

You can register custom commands at runtime:
val myCommand = CommandBuilder
    .begin("mycommand")
    .alias("mc")
    .handler {
        chat("Hello from my command!")
    }
    .build()

CommandManager.addCommand(myCommand)

Command Reference

Manage your friends listSubcommands:
  • add <name> [alias] - Add a friend
  • remove <name> - Remove a friend
  • alias <name> <alias> - Set friend alias
  • list - Show all friends
  • clear - Remove all friends
Example: .friend add Notch "Best Miner"
Enable or disable a moduleParameters:
  • module - Module name (auto-completes)
  • on|off - Optional state (toggles if omitted)
Example: .toggle KillAura on
Bind a module to a keyboard keyParameters:
  • module - Module name
  • key - Key name or code
Example: .bind Fly R
Manage configuration filesSubcommands:
  • load <name> - Load a config
  • save <name> - Save current config
  • list - Show all configs
  • delete <name> - Delete a config
Example: .config save hypixel
Emergency disable all modulesExample: .panic

Best Practices

Use Descriptive Names

Choose clear, intuitive command names that describe their function

Provide Aliases

Add short aliases for frequently used commands

Validate Input

Always use parameter validators to ensure correct input

Handle Errors

Throw CommandException with helpful messages on failures

Next Steps

Modules

Learn about the module system

Scripts

Create commands via scripting

API Reference

Complete command API documentation

Examples

Build your own commands

Build docs developers (and LLMs) love