Interface ScriptScheduler


public interface ScriptScheduler
Schedules scripts to run at a future time or on a recurring interval.

Obtained from ScriptManager.getScheduler(). Like ScriptManager, this type is framework-internal: each instance is bound to one Client's runtime and is not exposed directly through the BotScript or ManagementScript SPIs. ManagementScripts schedule scripts through ClientOrchestrator (e.g. scheduleScript(client, name, delay) / scheduleScriptOnAllEvery(name, interval)), which routes each call to the appropriate per-Connection scheduler.

Surface (for framework callers that hold a ScriptScheduler instance)

// Run "Woodcutter" once after 10 minutes
String id = scheduler.runAfter("Woodcutter", Duration.ofMinutes(10));

// Run "Fisher" every 2 hours
String id2 = scheduler.runEvery("Fisher", Duration.ofHours(2));

// Run "Miner" at a specific time
String id3 = scheduler.runAt("Miner", Instant.parse("2026-03-09T14:00:00Z"));

// Run "Crafter" every 30 min, stop it after 5 min each time
String id4 = scheduler.runEvery("Crafter", Duration.ofMinutes(30), Duration.ofMinutes(5));

// Cancel
scheduler.cancel(id);

// See what's scheduled
scheduler.listScheduled().forEach(s -> log.info("{} → {}", s.scriptName(), s.nextRun()));
  • Method Details

    • runAfter

      String runAfter(String scriptName, Duration delay)
      Starts a script after the given delay.
      Parameters:
      scriptName - name of the script to start
      delay - how long to wait before starting
      Returns:
      a unique schedule ID for cancellation
    • runAfter

      String runAfter(String scriptName, Duration delay, Map<String,Object> config)
      Starts a script after the given delay with configuration.
      Parameters:
      scriptName - name of the script to start
      delay - how long to wait before starting
      config - configuration values to apply
      Returns:
      a unique schedule ID for cancellation
    • runAt

      String runAt(String scriptName, Instant at)
      Starts a script at a specific time.
      Parameters:
      scriptName - name of the script to start
      at - when to start it
      Returns:
      a unique schedule ID for cancellation
    • runEvery

      String runEvery(String scriptName, Duration interval)
      Repeats a script on a fixed interval. The script is started, and when it stops (or is stopped), it is restarted after interval elapses.
      Parameters:
      scriptName - name of the script to start
      interval - time between starts
      Returns:
      a unique schedule ID for cancellation
    • runEvery

      String runEvery(String scriptName, Duration interval, Duration maxDuration)
      Repeats a script on a fixed interval, automatically stopping it after maxDuration each time.
      Parameters:
      scriptName - name of the script to start
      interval - time between starts
      maxDuration - maximum time the script runs per cycle before being stopped
      Returns:
      a unique schedule ID for cancellation
    • cancel

      boolean cancel(String scheduleId)
      Cancels a scheduled or repeating script.
      Parameters:
      scheduleId - the ID returned by a run* method
      Returns:
      true if the schedule was found and cancelled
    • cancelAll

      void cancelAll()
      Cancels all scheduled and repeating scripts.
    • listScheduled

      Lists all active schedules.
      Returns:
      snapshot of currently scheduled entries