Interface IServerControl


public interface IServerControl
Server-control facet of the framework: command execution, console output, platform, filesystem access, process lifecycle, tick counter, and captured server errors.

Obtained from ILightkeeperFramework.server().

  • Method Details

    • executeCommand

      CommandResult executeCommand(CommandSource source, String command)
      Executes a command from the requested source.
      Parameters:
      source - The command source.
      command - The command text.
      Returns:
      Command result.
    • output

      List<String> 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() and start() — because the server reads most files once at boot and may overwrite them on shutdown.

      Returns:
      The server directory.
    • pluginDataDirectory

      Path pluginDataDirectory(String pluginName)
      Gets the data directory of a plugin inside the server's plugins directory.

      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 the name from its plugin.yml).
      Returns:
      The plugin data directory.
    • plugin

      Optional<ServerPluginSnapshot> plugin(String pluginName)
      Gets the data of the plugin with the given name.
      Parameters:
      pluginName - The plugin's name from its plugin.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() or restart() before the next test method runs, otherwise that method fails fast; annotate the test with @FreshServer to receive a new server per method instead.

    • stop

      void stop()
      Stops the Minecraft server gracefully via the console stop command, 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 — see directory().

      Throws:
      IllegalStateException - If the server is not running.
    • start

      void start()
      Starts the Minecraft server after a stop() or crash() 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()
      Restarts the Minecraft server: a graceful stop() when it is running, followed by start().

      Also valid when the server is already down (after stop() or crash()), in which case it only starts the server. See start() for what is — and is not — restored.

    • currentTick

      long currentTick()
      Gets the agent's monotonic tick counter, for correlating against CapturedEventSnapshot.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

      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.