Server, Net & Assets
Server & Tasks (server)
Section titled “Server & Tasks (server)”Wraps HytaleServer and TaskRegistry.
server.runLater(delayMs, fn)→ task handle{ id, cancel(), cancelled() }server.runRepeating(initialDelayMs, periodMs, fn)→ repeating task handleserver.shutdown(reason?)server.isBooted()→ booleanserver.name()→ server name
Run Console Commands
Section titled “Run Console Commands”server.runCommand(commandLine)— executes any server command as the console sender (full permissions).- Throws
IllegalArgumentExceptionfor empty input. - Throws
IllegalStateExceptionif the command cannot be executed. - Runs on the calling thread; target commands may still perform async work.
- Throws
Usage guidelines
- Validate user input before concatenating into
commandLineto 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 pluginserver.runCommand("pluginmanager:reload MyPlugin");
// Give items using an existing commandserver.runCommand(`give Alice diamond 64`);
// Trigger a world saveserver.runCommand("save-all");Example
Section titled “Example”var task = server.runLater(5000, function() { log.info("5s passed");});
server.runRepeating(0, 1000, function() { log.info("tick");});// task.cancel();Net (net)
Section titled “Net (net)”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.
Example
Section titled “Example”net.broadcast("Server restart in 1 minute");net.send("Bob", "You have mail!");Assets (assets)
Section titled “Assets (assets)”The native AssetRegistry is not exposed yet. Two helpers are provided:
assets.info(message)— informational logassets.warnUnsupported()— quick warning that a feature is not supported
Example
Section titled “Example”assets.warnUnsupported();