Skip to main content
The runtime exposes script-owned timers. Timers are cleared when a script unloads.
Timer callbacks receive their timer id as the first argument. Use that id when an interval clears itself. Script.throttle(key, intervalMs) is useful inside frequent events:
Script.cleanup(fn) runs fn when the script runtime is disabled or unloaded. Use it to release external handles that are not already script-owned.
Script.thread(fn) starts a daemon thread when the module is enabled. Use it for sleeps or long waits:
Time.sleep and Time.sleepTicks must not run in client-thread event callbacks or packet callbacks.

Async

Async provides cancellable handles for worker functions, delayed callbacks, repeated callbacks, polling, and HTTP requests.
Async.request accepts either a URL string or a request object: Responses include status, headers, and body for text requests. For binary responses, pass binary = true; the response includes bodyBytes / bytes as a Java byte array plus length.
Handles expose id, kind, cancel(), running(), done(), failed(), error(), and result().