Repository navigation
Scripting API
Because the script interpreter is completely sandboxed, it cannot access the operating system natively. Scripts interact with the outside world strictly through the jhmc global table, which is injected by the engine.
Most of these API calls require explicit Permissions. Calling a function without the appropriate permission raises an ErrPermissionDenied and immediately aborts the script.
(Requires Permission: network)
-
jhmc.http_get(url) -> stringPerforms an HTTP GET request and returns the body as a string. (Limited to 64 MiB). -
jhmc.http_json(url) -> tablePerforms an HTTP GET request and automatically parses the JSON response into a Lua table. -
jhmc.download(url, opts) -> pathDownloads a file from a URL, streaming progress to the UI. Returns the absolute destination path.-
opts.dest: (Required) The destination path relative to the server directory. -
opts.sha256oropts.sha1: (Optional) If provided, the engine will verify the downloaded file against this checksum and fail if it doesn't match.
-
-
jhmc.http(opts) -> {status, body, headers}Full HTTP client.opts:url(required),method(default"GET"),body,headers(table),timeout(seconds, default 30),max_body(bytes, default 64 MiB). Non-2xx responses are returned, not raised, so scripts can branch onstatus. Responseheaderskeys are lower-cased.
(Requires Permission: fs_server)
All filesystem paths are relative to the server directory. Accessing files outside the server directory is strictly prohibited (Zip-slip and path traversal protections apply).
-
jhmc.fs.read(rel) -> stringReads a file and returns its contents. -
jhmc.fs.write(rel, data)Writes string data to a file, creating parent directories if they don't exist. -
jhmc.fs.exists(rel) -> boolTests if a file or directory exists. -
jhmc.fs.glob(rel) -> { string, ... }Lists all paths matching a relative glob pattern. -
jhmc.fs.mkdir(rel)Creates a directory and any necessary parents. -
jhmc.fs.remove(rel)Recursively removes a path. -
jhmc.unzip(zipRel, destRel)Safely extracts a ZIP archive into a destination directory within the server folder. -
jhmc.copy_bundled(name, destRel) -> destRelCopies a file that was bundled alongside the script (e.g., a.jaruploaded with a custom provider) into the server directory. -
jhmc.zip_read(zipRel, name) -> string|nilReads one entry from a zip/jar under the server directory (≤ 16 MiB);nilwhen the entry is absent. -
jhmc.zip_entries(zipRel) -> { string, ... }Lists all entry names within a zip/jar file.
(Requires Permission: install)
-
jhmc.resolve_java(major[, useJDK]) -> pathResolves ajava.exebinary for the requested Javamajorversion, downloading it automatically if necessary. SetuseJDKto true to require the full JDK (needed for compile tools like Spigot BuildTools). -
jhmc.run_jar(opts)Runs an installer.jar(like Forge, NeoForge, or BuildTools) with streaming progress logs.-
opts.java_major: The required Java version. -
opts.jdk: Set to true to use the full JDK. -
opts.args: A list of arguments to pass to the Java process. -
opts.dir: (Optional) Run the process in a specific subdirectory relative to the server dir.
-
(No Permissions Required)
-
jhmc.sha256(rel) -> hexCalculates and returns the SHA-256 hash of a file within the server directory. -
jhmc.java_major_for(mcVersion) -> numberMaps a Minecraft version string (e.g.,"1.20.4") to the standard Java major version required by Mojang (e.g.,21). -
jhmc.json_decode(string) -> valueParses a JSON string into a Lua table/value. -
jhmc.json_encode(value) -> stringSerializes a Lua value into a JSON string. -
jhmc.toml_decode(string) -> tableParses TOML into a Lua table (e.g.,mods.toml). -
jhmc.yaml_decode(string) -> valueParses YAML into a Lua value (e.g.,plugin.yml). -
jhmc.time() -> numberReturns the current UTC Unix time in seconds (fractional). -
jhmc.log(line)Appends a raw string directly to the installation/automation log.
(No Permissions Required. Available for automation and shop scripts)
Each automation script gets an isolated key-value store persisted at <data>/script-data/<scriptID>.json. Keys and values are strings. The store is unavailable during import/meta-parse and in provider scripts.
-
jhmc.store.get(key) -> string|nilReads a key (nilwhen absent). -
jhmc.store.set(key, value)Writes a key. -
jhmc.store.delete(key)Deletes a key (absent key is a no-op). -
jhmc.store.keys() -> { string, ... }Returns all keys, sorted alphabetically.
- Back to the Scripting Hub