Cancel and join parent job

This commit is contained in:
kraftwerk28 2021-07-10 13:51:58 +03:00
parent 8279fc9022
commit df7accf52d

View File

@ -5,6 +5,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancelAndJoin
import org.bukkit.plugin.java.JavaPlugin
open class AsyncJavaPlugin : JavaPlugin() {
@ -17,7 +19,7 @@ open class AsyncJavaPlugin : JavaPlugin() {
override fun onDisable() {
runBlocking {
onDisableAsync()
scope.cancel()
scope.coroutineContext[Job]?.cancelAndJoin()
}
}