Interface ScriptScheduler
public interface ScriptScheduler
Schedules scripts to run at a future time or on a recurring interval.
Surface (for framework callers that hold a
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()));
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA snapshot of one scheduled entry. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCancels a scheduled or repeating script.voidCancels all scheduled and repeating scripts.Lists all active schedules.Starts a script after the given delay.Starts a script after the given delay with configuration.Starts a script at a specific time.Repeats a script on a fixed interval.Repeats a script on a fixed interval, automatically stopping it aftermaxDurationeach time.
-
Method Details
-
runAfter
-
runAfter
Starts a script after the given delay with configuration.- Parameters:
scriptName- name of the script to startdelay- how long to wait before startingconfig- configuration values to apply- Returns:
- a unique schedule ID for cancellation
-
runAt
-
runEvery
Repeats a script on a fixed interval. The script is started, and when it stops (or is stopped), it is restarted afterintervalelapses.- Parameters:
scriptName- name of the script to startinterval- time between starts- Returns:
- a unique schedule ID for cancellation
-
runEvery
Repeats a script on a fixed interval, automatically stopping it aftermaxDurationeach time.- Parameters:
scriptName- name of the script to startinterval- time between startsmaxDuration- maximum time the script runs per cycle before being stopped- Returns:
- a unique schedule ID for cancellation
-
cancel
Cancels a scheduled or repeating script.- Parameters:
scheduleId- the ID returned by arun*method- Returns:
trueif the schedule was found and cancelled
-
cancelAll
void cancelAll()Cancels all scheduled and repeating scripts. -
listScheduled
List<ScriptScheduler.ScheduledEntry> listScheduled()Lists all active schedules.- Returns:
- snapshot of currently scheduled entries
-