Back to scripts
JS
scheduler_example.js
JavaScript · 19 lines · 549 B
scripts/scheduler_example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
* Example: Task Scheduler Usage
* Demonstrates using the scheduler from JavaScript
*/
console.log("Setting up scheduled tasks...");
// Run a task after 5 seconds (100 ticks)
API.runLater(function() {
API.broadcast("&6[Scheduler] &eThis message was delayed by 5 seconds!");
}, 100);
console.log("Delayed task scheduled");
// NOTE: runTimer() and runAsync() removed due to GraalVM multithreading restrictions
// JavaScript callbacks cannot be called from Bukkit scheduler threads
console.log("Scheduler example loaded successfully!");