TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/CCBlueX/LiquidBounce/llms.txt
Use this file to discover all available pages before exploring further.
PolyglotScript class represents a single loaded script instance in LiquidBounce. It manages the script’s lifecycle, context, registered features, and event handling.
Class Declaration
The programming language of the script (e.g., “js”, “python”, “ruby”)
The script file on disk
Debug configuration for the script
Properties
Script Metadata
These properties are set whenregisterScript() is called from within the script.
Display name of the script
Script version string
Array of script authors
Context
The GraalVM polyglot context for executing script code.- Host Access: Full access to Java classes
- IO Access: File system and network operations
- Working Directory: Script’s parent directory
- Thread Creation: Enabled
- Native Access: Disabled for security
- Language Options: Language-specific features
Script State
Whether the script is currently enabled
Registered Features
Scripts can register various features that are tracked by the instance:Modules created by the script
Commands created by the script
Modes created by the script
Methods
initScript()
Initializes the script by evaluating its source code.- Evaluates the script source code
- Calls the global
loadevent - Validates required metadata (name, version, authors)
- Logs loading time
registerModule()
Registers a new module from the script.JavaScript object containing module configuration
Function called with the created module instance
registerCommand()
Registers a new command from the script.GraalVM Value containing command configuration
registerMode()
Registers a new mode for an existing mode value group.The mode group to add the mode to
Mode configuration object
Function called with the created mode instance
on()
Registers a global event handler.Name of the event to listen to
Function to call when the event fires
load- Called when script is loadedenable- Called when script is enableddisable- Called when script is disabled
enable()
Enables the script and all its registered features.- Calls global
enableevent - Registers all modules with ModuleManager
- Registers all commands with CommandManager
- Adds all modes to their respective mode groups
- Sets
scriptEnabledtotrue
disable()
Disables the script and all its registered features.- Calls global
disableevent - Unregisters all modules from ModuleManager
- Unregisters all commands from CommandManager
- Removes all modes from their mode groups
- Triggers RefreshArrayListEvent
- Sets
scriptEnabledtofalse
close()
Closes the script context and releases resources.- Closes the GraalVM context
- Releases all script resources
- Should be called before removing script from memory
AutoCloseable for use with try-with-resources.
Context Configuration
The script context is configured differently based on language:JavaScript Features
- Nashorn compatibility mode
- ECMAScript 2023 support
- CommonJS require() support
- Module resolution from script directory
Debug Options
Enable debugging for the script
Debug protocol to use (INSPECT or DAP)
Port for debug connection
Pause execution at script start
Allow inspecting internal variables
INSPECT Protocol
Chrome DevTools Protocol support:DAP Protocol
Debug Adapter Protocol for VS Code and other editors:Lifecycle Example
Error Handling
Errors during event handling are caught and logged:See Also
- ScriptManager - Script loading and management
- Script Bindings - Available APIs in scripts
- Creating Scripts - Guide to writing scripts
- Debug Support - Debugging scripts