Interface IServerControl
Obtained from ILightkeeperFramework.server().
-
Method Summary
Modifier and TypeMethodDescriptionvoidcrash()Crashes the Minecraft server immediately by force-killing the process.longGets the agent's monotonic tick counter, for correlating againstCapturedEventSnapshot.tick()stamps.Gets the Minecraft server's working directory.errors()Gets a handle over the always-on server-error capture.executeCommand(CommandSource source, String command) Executes a command from the requested source.output()Gets a snapshot of captured Minecraft server output lines.platform()Gets the server platform (e.g.Gets the data of the plugin with the given name.pluginDataDirectory(String pluginName) Gets the data directory of a plugin inside the server'spluginsdirectory.voidrestart()voidstart()voidstop()Stops the Minecraft server gracefully via the consolestopcommand, force-killing it only when it does not exit within the shutdown timeout.
-
Method Details
-
executeCommand
Executes a command from the requested source.- Parameters:
source- The command source.command- The command text.- Returns:
- Command result.
-
output
Gets a snapshot of captured Minecraft server output lines.- Returns:
- Captured server output lines ordered oldest-to-newest.
-
platform
Platform platform()Gets the server platform (e.g. PAPER, SPIGOT).- Returns:
- Server platform.
-
directory
Path directory()Gets the Minecraft server's working directory.Filesystem contract: reading is safe at any time; writing (e.g. seeding database files or patching plugin configurations) is only safe while the server is stopped — between
stop()andstart()— because the server reads most files once at boot and may overwrite them on shutdown.- Returns:
- The server directory.
-
pluginDataDirectory
Gets the data directory of a plugin inside the server'spluginsdirectory.The directory may not exist yet, e.g. before the plugin's first boot. The filesystem contract of
directory()applies.- Parameters:
pluginName- The plugin's name, as used for its data directory (usually thenamefrom itsplugin.yml).- Returns:
- The plugin data directory.
-
plugin
Gets the data of the plugin with the given name.- Parameters:
pluginName- The plugin's name from itsplugin.yml).- Returns:
- The plugin snapshot if the plugin exists on the server.
-
crash
void crash()Crashes the Minecraft server immediately by force-killing the process.All fixtures created before the crash are invalidated: player and world handles obtained earlier no longer refer to live server state. In shared-server mode the server must be started again via
start()orrestart()before the next test method runs, otherwise that method fails fast; annotate the test with@FreshServerto receive a new server per method instead. -
stop
void stop()Stops the Minecraft server gracefully via the consolestopcommand, force-killing it only when it does not exit within the shutdown timeout.Synthetic players are removed before the server shuts down so they quit cleanly. All fixtures created before the stop are invalidated, exactly as documented on
crash(). While the server is stopped, the server directory may be modified freely — seedirectory().- Throws:
IllegalStateException- If the server is not running.
-
start
void start()Starts the Minecraft server after astop()orcrash()call.Only worlds configured in the runtime manifest are preloaded again. Players and worlds created at runtime before the server went down are not recreated; tests must re-establish their own fixtures after starting.
- Throws:
IllegalStateException- If the server is already running.
-
restart
void restart() -
currentTick
long currentTick()Gets the agent's monotonic tick counter, for correlating againstCapturedEventSnapshot.tick()stamps.This is an agent-relative counter (ticks since the agent enabled), not the server's absolute game tick: it resets on every server start, so values are only comparable within one server session.
- Returns:
- The monotonic, session-relative server tick.
-
errors
ServerErrorsHandle errors()Gets a handle over the always-on server-error capture.The agent captures every WARN-or-worse log event inside the server as a structured snapshot — with the real throwable class, message, and cause chain — from the moment the agent plugin loads (before any plugin's
onEnable). Failures inside the logging system itself (reported via Log4j's status logger) and stack traces written to the server process's raw stderr file descriptor are captured as well.In shared-server mode the capture buffer is cleared automatically at the end of every test method, so each test observes only the errors of its own window; the first test's window also covers server boot. Known gaps: exceptions that are caught and never logged are invisible, as are log events emitted before the agent plugin loads (use
output()for pre-boot inspection).- Returns:
- A handle exposing the captured server errors.
-