diff options
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt | 4 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index b0446f62e..bba813430 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.config import at.hannibal2.skyhanni.events.LorenzEvent import at.hannibal2.skyhanni.utils.LorenzLogger +import at.hannibal2.skyhanni.utils.LorenzUtils.asIntOrNull import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.JsonPrimitive @@ -69,8 +70,7 @@ object ConfigUpdaterMigrator { } fun fixConfig(config: JsonObject): JsonObject { - val lV = (config.get("lastVersion") as? JsonPrimitive) - ?.takeIf { it.isNumber }?.asInt ?: -1 + val lV = (config.get("lastVersion") as? JsonPrimitive)?.asIntOrNull ?: -1 if (lV == configVersion) return config logger.log("Starting config transformation from $lV to $configVersion") val migration = ConfigFixEvent(config, JsonObject().also { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 9085b96e8..a96937b88 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.capAtMinecraftLength import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.StringUtils.toDashlessUUID import at.hannibal2.skyhanni.utils.renderables.Renderable +import com.google.gson.JsonPrimitive import io.github.moulberry.moulconfig.observer.Observer import io.github.moulberry.moulconfig.observer.Property import io.github.moulberry.notenoughupdates.util.SkyBlockTime @@ -530,4 +531,6 @@ object LorenzUtils { val modifierHeld = if (SystemUtils.IS_OS_MAC) isCommandKeyDown() else isControlKeyDown() return modifierHeld && OSUtils.isKeyHeld(Keyboard.KEY_V) } + + val JsonPrimitive.asIntOrNull get() = takeIf { it.isNumber }?.asInt } |