diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/handlers/impl/MongoDBPersistentDataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/handlers/impl/MongoDBPersistentDataHandler.kt index 77bcbb344..99fedea59 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/handlers/impl/MongoDBPersistentDataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/handlers/impl/MongoDBPersistentDataHandler.kt @@ -69,7 +69,12 @@ class MongoDBPersistentDataHandler( } override fun deserialize(value: BsonValue): Int { - return value.asInt32().value + // Handle both INT32 and DOUBLE + return when { + value.isInt32 -> value.asInt32().value + value.isDouble -> value.asDouble().value.toInt() + else -> 0 // default value + } } }) @@ -79,7 +84,12 @@ class MongoDBPersistentDataHandler( } override fun deserialize(value: BsonValue): Double { - return value.asDouble().value + // Handle both DOUBLE and INT32 + return when { + value.isDouble -> value.asDouble().value + value.isInt32 -> value.asInt32().value.toDouble() + else -> 0.0 // default value + } } }) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/handlers/impl/MySQLPersistentDataHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/handlers/impl/MySQLPersistentDataHandler.kt index f7bf7663f..d0ea08ac1 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/handlers/impl/MySQLPersistentDataHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/data/handlers/impl/MySQLPersistentDataHandler.kt @@ -70,15 +70,33 @@ class MySQLPersistentDataHandler( } }.createTable()) - PersistentDataKeyType.INT.registerSerializer(this, object : DirectStoreSerializer() { - override val table = object : KeyTable("int") { - override val value = integer(VALUE_COLUMN_NAME) + PersistentDataKeyType.INT.registerSerializer(this, object : SingleValueSerializer() { + override val table = object : KeyTable("int") { + override val value = varchar(VALUE_COLUMN_NAME, 64) + } + + override fun convertToStored(value: Int): String { + return value.toString() + } + + override fun convertFromStored(value: String): Int { + // Handle both int and double string representations + return value.toDoubleOrNull()?.toInt() ?: value.toIntOrNull() ?: 0 } }.createTable()) - PersistentDataKeyType.DOUBLE.registerSerializer(this, object : DirectStoreSerializer() { - override val table = object : KeyTable("double") { - override val value = double(VALUE_COLUMN_NAME) + PersistentDataKeyType.DOUBLE.registerSerializer(this, object : SingleValueSerializer() { + override val table = object : KeyTable("double") { + override val value = varchar(VALUE_COLUMN_NAME, 64) + } + + override fun convertToStored(value: Double): String { + return value.toString() + } + + override fun convertFromStored(value: String): Double { + // Handle both double and int string representations + return value.toDoubleOrNull() ?: 0.0 } }.createTable()) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/DelegatedExpressionHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/DelegatedExpressionHandler.kt index da3eacdb8..4470625bd 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/DelegatedExpressionHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/DelegatedExpressionHandler.kt @@ -12,8 +12,7 @@ class DelegatedExpressionHandler( ) : ExpressionHandler { private val evaluationCache: Cache = Caffeine.newBuilder() .expireAfterWrite(plugin.configYml.getInt("math-cache-ttl").toLong(), TimeUnit.MILLISECONDS) - .buildAsync() - .synchronous() + .build() override fun evaluate(expression: String, context: PlaceholderContext): Double? { expression.fastToDoubleOrNull()?.let { return it }