aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/config
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-16 13:22:30 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-16 13:22:30 +0200
commit2d920a7f83fd700cc2b0d9bfda387e66c683f885 (patch)
tree5121bb30dc13c8e665d535879f376d9f764742b5 /src/main/java/at/hannibal2/skyhanni/config
parent6c13cb57483fe7aa11e45fb98f927bda49e0ba73 (diff)
downloadskyhanni-2d920a7f83fd700cc2b0d9bfda387e66c683f885.tar.gz
skyhanni-2d920a7f83fd700cc2b0d9bfda387e66c683f885.tar.bz2
skyhanni-2d920a7f83fd700cc2b0d9bfda387e66c683f885.zip
create and use JsonPrimitive.asIntOrNull
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt4
1 files changed, 2 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 {