Interface ScriptManager
public interface ScriptManager
Per-Connection script lifecycle manager: lists, starts, stops, reloads, and
schedules scripts running against one Surface (for framework callers that hold a
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 Summary
Modifier and TypeMethodDescriptionReturns info for a single script by name, ornullif not found.Returns the scheduler for running scripts on a timer or interval.booleanReturnstrueif the named script is currently running.listAll()Returns info about all known scripts (running and stopped).Returns info about currently running scripts only.Reloads scripts from the localscripts/directory.booleanStops and restarts a script.booleanStarts a script by name.booleanStarts a script with the given configuration values.booleanStops a running script.voidstopAll()Stops all running scripts.
-
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
Returns info for a single script by name, ornullif not found. -
isRunning
Returnstrueif the named script is currently running. -
start
Starts a script by name. The script must already be loaded (discovered).- Parameters:
name- the script name (fromScriptManifest)- Returns:
trueif the script was found and started- Throws:
IllegalStateException- if the script is already running
-
start
Starts a script with the given configuration values.- Parameters:
name- the script nameconfig- key-value pairs matching the script's config field names- Returns:
trueif the script was found and started- Throws:
IllegalStateException- if the script is already running
-
stop
Stops a running script.- Parameters:
name- the script name- Returns:
trueif the script was found and stopped
-
restart
Stops and restarts a script. If the script is not running, just starts it.- Parameters:
name- the script name- Returns:
trueif the script was found
-
stopAll
void stopAll()Stops all running scripts. -
reloadLocal
List<ScriptInfo> reloadLocal()Reloads scripts from the localscripts/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.
-