Overview
TheCommandManager handles all command-related functionality in LiquidBounce, including command registration, parsing, execution, and auto-completion. It provides a flexible system for creating commands with parameters and subcommands.
Package: net.ccbluex.liquidbounce.features.command
Object Declaration
Global Settings
Command prefix character(s)Example:
.friend add PlayerNumber of command suggestions to show for unknown commands
Core Methods
Command Registration
Registers all built-in LiquidBounce commands.Registers commands including:
- Client Management: Client, Config, LocalConfig, Debug
- Module Control: Toggle, Bind, Hide, Panic, Value
- Friends: Friend
- Utility: Help, Clear, Targets
- Script: Script
- Creative: ItemRename, ItemGive, ItemSkull, ItemStack, ItemEnchant
- Teleport: VClip, Teleport, PlayerTeleport
- Info: Ping, Tps, ServerInfo, Username, Coordinates
- Other: Say, FakePlayer, RemoteView, XRay, AutoDisable, Models, Translate, AutoTranslate, Marketplace
Adds a custom command to the manager.Throws an error if command name already exists.
Removes a command from the manager.
Command Execution
Executes a command string.Example:Throws:
CommandException if command is invalid or parameters are incorrectCommand Parsing
Tokenizes a command string into arguments.Returns: Pair of tokenized arguments and their starting indicesExample:Features:
- Quoted strings with spaces:
"My Name" - Escape characters:
\",\\ - Multi-word arguments
Auto-Completion
Provides auto-completion suggestions for partial commands.Parameters:
origCmd- Full command text including prefixstart- Cursor position
Usage Examples
Executing Commands
Tokenizing Commands
Creating Custom Command
Command with Subcommands
Error Handling
CommandException
Thrown when command execution fails:Common Errors
- Unknown Command - Command not found, suggestions provided
- Invalid Usage - Wrong number of arguments
- Command Takes No Parameters - Arguments provided to parameterless command
- Parameter Required - Missing required parameter
- Unknown Parameter - Too many arguments
- Invalid Parameter Value - Parameter validation failed
Command Suggestions
When an unknown command is entered, CommandManager uses Levenshtein distance to suggest similar commands:GlobalSettings.hintCount.
Best Practices
- Use descriptive command names - Clear and concise
- Provide aliases - Common abbreviations for frequently used commands
- Add parameter validation - Prevent invalid input
- Support auto-completion - Improve user experience
- Handle errors gracefully - Provide helpful error messages
- Use subcommands - Organize complex command hierarchies
See Also
- Command Builder - Creating commands with DSL
- Parameters - Command parameter system
- Parameter Types - Built-in parameter types