Skip to content

Server, Net & Assets

Wraps HytaleServer and TaskRegistry.

  • server.runLater(delayMs, fn) → task handle { id, cancel(), cancelled() }
  • server.runRepeating(initialDelayMs, periodMs, fn) → repeating task handle
  • server.shutdown(reason?)
  • server.isBooted() → boolean
  • server.name() → server name
  • server.runCommand(commandLine) — executes any server command as the console sender (full permissions).
    • Throws IllegalArgumentException for empty input.
    • Throws IllegalStateException if the command cannot be executed.
    • Runs on the calling thread; target commands may still perform async work.

Usage guidelines

  • Validate user input before concatenating into commandLine to avoid unintended commands.
  • Because it runs as console, add your own permission checks when exposing this to players.
  • Expect delayed feedback if the target command is async.

Examples

// Reload another plugin
server.runCommand("pluginmanager:reload MyPlugin");
// Give items using an existing command
server.runCommand(`give Alice diamond 64`);
// Trigger a world save
server.runCommand("save-all");
var task = server.runLater(5000, function() {
log.info("5s passed");
});
server.runRepeating(0, 1000, function() {
log.info("tick");
});
// task.cancel();

Raw packet APIs are not exposed; this is a safe messaging helper.

  • net.broadcast(text)
  • net.send(username, text)
  • net.kick(username, reason?)
  • net.warn(message) — logs server-side

Messages may be strings or ui builders.

net.broadcast("Server restart in 1 minute");
net.send("Bob", "You have mail!");

The native AssetRegistry is not exposed yet. Two helpers are provided:

  • assets.info(message) — informational log
  • assets.warnUnsupported() — quick warning that a feature is not supported
assets.warnUnsupported();