ScriptManager

The ScriptManager allows to extend the client by loading supported scripts at runtime. Scripts can be written in various languages when installed through GraalVM and can interact with the client through the Script API.

Scripts are stored in the scripts directory and can be organized in subdirectories when using a main script file.

Properties

Link copied to clipboard
val root: File

The root directory where all scripts are stored. This directory is created if it does not exist.

Link copied to clipboard

A list that holds all the loaded scripts.

Functions

Link copied to clipboard

Disables all loaded scripts. This method iterates over the list of loaded scripts and disables each one.

Link copied to clipboard
fun enableAll()

Enables all loaded scripts. This method iterates over the list of loaded scripts and enables each one.

Link copied to clipboard
Link copied to clipboard
fun loadAll()

Loads all scripts found in the scripts directory. This method scans the directory for script files and directories containing a main script file. It then loads and enables all found scripts.

Link copied to clipboard
fun loadScript(file: File, language: String = Source.findLanguage(file), debugOptions: ScriptDebugOptions = ScriptDebugOptions()): PolyglotScript

Loads a script from a file. This method creates a new Script object, initializes it, and adds it to the list of loaded scripts.

Link copied to clipboard
fun reload()

Reloads all scripts. This method unloads all currently loaded scripts, loads them again from the scripts directory, and then enables them. It logs a message upon successful completion.

Link copied to clipboard
fun unloadAll()

Unloads all currently loaded scripts. This method disables each script and clears the list of loaded scripts.

Link copied to clipboard

Unloads a specific script. This method disables the script and removes it from the list of loaded scripts.