Jim

object Jim

The primary scripting entry point. Register triggers with an Event and an arrow-function callback that takes a single argument (the event's primary value):

import { Jim, Event, ChatLib, Player } from 'ratph6.jim.api';

Jim.register(Event.CHAT, (message) => {
ChatLib.chat("pong!");
// Jim.cancelEvent(); // hide the original message
}).setContains().setCriteria("ping");

Jim.register(Event.COMMAND, (args) => {
ChatLib.chat("XYZ: " + Player.getX());
}).setName("coords");

Callbacks receive the event's primary value (e.g. the chat message, the tick count, the command's argument array). To cancel a cancellable event, call cancelEvent from inside the callback.

Functions

Link copied to clipboard

Cancel the cancellable event currently being dispatched (call from inside a callback).

Link copied to clipboard
Link copied to clipboard
fun emit(eventName: String, payload: Any?)

Fire a custom event; every on handler runs with the given payload.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun log(message: String)

Print to the in-game chat, prefixed with [JIM].

Link copied to clipboard

High-resolution timestamp in milliseconds (for benchmarking). Use instead of System.*.

Link copied to clipboard
fun on(eventName: String, callback: Consumer<Any?>): TriggerHandle

Listen for a custom event (see emit) or a built-in jim:* event.

Link copied to clipboard

Register an arrow-function callback for an Event (e.g. Event.CHAT) or custom type id.

Link copied to clipboard
Link copied to clipboard
fun setInterval(callback: Runnable, ms: Int): Int

Run callback repeatedly every ms.

Link copied to clipboard
fun setTimeout(callback: Runnable, ms: Int): Int

Run callback once after ms (resolution ~1 tick).

Link copied to clipboard