Interface ScriptManager


public interface ScriptManager
Per-Connection script lifecycle manager: lists, starts, stops, reloads, and schedules scripts running against one Client.

This type is framework-internal — it is not exposed through the BotScript SPI. A BotScript is bound to one Client and should not start or stop peers. The public surface for cross-Client script control (including scheduling) is ClientOrchestrator on ManagementContext; the orchestrator routes each call to the appropriate per-Connection ScriptManager / ScriptScheduler.

Surface (for framework callers that hold a ScriptManager instance)

// See what's available
mgr.listAll().forEach(s ->
    log.info("{} [{}]", s.name(), s.running() ? "RUNNING" : "STOPPED"));

// Start a script
mgr.start("Woodcutter");

// Start with config
mgr.start("Fisher", Map.of("location", "Barbarian Village", "dropFish", true));

// Stop it later
mgr.stop("Woodcutter");

// Reload scripts from disk (picks up new JARs)
List<ScriptInfo> fresh = mgr.reloadLocal();

// Schedule scripts
ScriptScheduler scheduler = mgr.getScheduler();
scheduler.runAfter("Miner", Duration.ofMinutes(10));
scheduler.runEvery("Crafter", Duration.ofHours(1), Duration.ofMinutes(30));
  • Method Details

    • listAll

      List<ScriptInfo> listAll()
      Returns info about all known scripts (running and stopped).
    • listRunning

      List<ScriptInfo> listRunning()
      Returns info about currently running scripts only.
    • getInfo

      ScriptInfo getInfo(String name)
      Returns info for a single script by name, or null if not found.
    • isRunning

      boolean isRunning(String name)
      Returns true if the named script is currently running.
    • start

      boolean start(String name)
      Starts a script by name. The script must already be loaded (discovered).
      Parameters:
      name - the script name (from ScriptManifest)
      Returns:
      true if the script was found and started
      Throws:
      IllegalStateException - if the script is already running
    • start

      boolean start(String name, Map<String,Object> config)
      Starts a script with the given configuration values.
      Parameters:
      name - the script name
      config - key-value pairs matching the script's config field names
      Returns:
      true if the script was found and started
      Throws:
      IllegalStateException - if the script is already running
    • stop

      boolean stop(String name)
      Stops a running script.
      Parameters:
      name - the script name
      Returns:
      true if the script was found and stopped
    • restart

      boolean restart(String name)
      Stops and restarts a script. If the script is not running, just starts it.
      Parameters:
      name - the script name
      Returns:
      true if the script was found
    • stopAll

      void stopAll()
      Stops all running scripts.
    • reloadLocal

      List<ScriptInfo> reloadLocal()
      Reloads scripts from the local scripts/ directory. Newly discovered scripts are registered but not started.
      Returns:
      list of all scripts after reload
    • getScheduler

      ScriptScheduler getScheduler()
      Returns the scheduler for running scripts on a timer or interval.