From df7accf52d5e2ec92531e6976616bdc6a61485dc Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Sat, 10 Jul 2021 13:51:58 +0300 Subject: [PATCH] Cancel and join parent job --- .../org/kraftwerk28/spigot_tg_bridge/AsyncJavaPlugin.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/kraftwerk28/spigot_tg_bridge/AsyncJavaPlugin.kt b/src/main/kotlin/org/kraftwerk28/spigot_tg_bridge/AsyncJavaPlugin.kt index 71950cf..1d3e24e 100644 --- a/src/main/kotlin/org/kraftwerk28/spigot_tg_bridge/AsyncJavaPlugin.kt +++ b/src/main/kotlin/org/kraftwerk28/spigot_tg_bridge/AsyncJavaPlugin.kt @@ -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() } }