HytaleJS

Utilities

Logger, Scheduler, Commands, and Messages

Logger

Log messages to the server console via the global logger.

Prop

Type

Usage

logger.info("Information message");
logger.warning("Warning message");
logger.severe("Error message");
logger.fine("Debug message");

Scheduler

Run delayed and repeating tasks via the global scheduler.

Prop

Type

ScriptTask

Returned by scheduler methods to control the task.

Prop

Type

Usage

scheduler.runLater(() => {
  logger.info("Runs once after 5 seconds");
}, 5000);

const task = scheduler.runRepeating(() => {
  logger.info("Runs every 10 seconds");
}, 10000, 10000);

task.cancel();

Commands

Register custom commands via the global commands.

Use commands.registerWorld(...) for commands that should run on the world thread (e.g., heavy block edits). This avoids per-block scheduling overhead but can stall world ticks if the command runs too long.

Prop

Type

CommandContext

Provided to command callbacks.

Prop

Type

Usage

commands.register("hello", "Say hello", (ctx) => {
  ctx.sendMessage("Hello, " + ctx.getSenderName() + "!");
});

commands.register("admin", "Admin only", "admin.use", (ctx) => {
  ctx.sendMessage("You have admin access!");
});

commands.registerWorld("sphere", "Run on world thread", (ctx) => {
  ctx.sendMessage("This command runs on the world executor.");
});

Messages

Create styled messages via the global Message.

Prop

Type

MessageStatic

Prop

Type

Usage

const msg = Message.raw("Hello!")
  .color(Colors.GREEN)
  .bold(true);

player.sendMessage(msg);

Event Handler

EventHandler

Internal type used by the event system.

Prop

Type

EventType

Union of all valid event type names.

type EventType =
  | "BootEvent"
  | "ShutdownEvent"
  | "PlayerConnectEvent"
  | "PlayerDisconnectEvent"
  | "PlayerChatEvent"
  // ... and 25+ more

On this page