From 2d920a7f83fd700cc2b0d9bfda387e66c683f885 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 16 Sep 2023 13:22:30 +0200 Subject: create and use JsonPrimitive.asIntOrNull --- src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/config') 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 { -- cgit