-
Notifications
You must be signed in to change notification settings - Fork 0
Bukkit Scheduler Extension
Potato Destroyer edited this page Mar 24, 2018
·
1 revision
launch(SchedulerThread) {
Thread.sleep(3000)
runOnServerThread {
player.world.spawnEntity<Pig>(player.location)
}
}If you have a coroutine which has blocking task, this coroutine must run on Bukkit Scheduler Thread.
In some cases, you need access Bukkit API, this activity should be run on Server Thread, it's not worth to create a new coroutine run on Server Thread which only has some sync statement, so you can use function runOnServerThread.
bukkitAsync {
Thread.sleep(3000)
}Sometimes it's not necessary to use kotlin coroutine. The block after this function will be post to Bukkit Scheduler.