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.
-
(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.
(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.log(line)Appends a raw string directly to the installation/automation log.
- Back to the Scripting Hub