From a23493fa83be4580bcde04ec2a57fdb60427d100 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sat, 4 May 2024 02:09:55 +0700 Subject: [PATCH] oops --- .../kotlin/ru/dbotthepony/kstarbound/VersionRegistry.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/VersionRegistry.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/VersionRegistry.kt index 199854f6..ad5ce847 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/VersionRegistry.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/VersionRegistry.kt @@ -5,6 +5,9 @@ import com.google.gson.JsonObject import com.google.gson.TypeAdapter import com.google.gson.stream.JsonReader import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap +import kotlinx.coroutines.future.asCompletableFuture +import kotlinx.coroutines.future.await +import kotlinx.coroutines.launch import ru.dbotthepony.kstarbound.json.FastJsonTreeReader import ru.dbotthepony.kstarbound.json.VersionedJson import java.util.concurrent.Future @@ -51,13 +54,13 @@ object VersionRegistry { private val adapter by lazy { Starbound.gson.getAdapter(VersionedJson::class.java) } fun load(): Future<*> { - return Starbound.EXECUTOR.submit(Runnable { - val json = Starbound.loadJsonAsset("/versioning.config") ?: throw NoSuchElementException("Unable to load /versioning.config! Expect HUGE problems!") + return Starbound.GLOBAL_SCOPE.launch { + val json = Starbound.loadJsonAsset("/versioning.config").await() ?: throw NoSuchElementException("Unable to load /versioning.config! Expect HUGE problems!") json as JsonObject for ((k, v) in json.entrySet()) { versions[k] = v.asInt } - }) + }.asCompletableFuture() } }