From 50f217eebef15c00d74b9b20fdd4272e228d7626 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Wed, 5 Jul 2023 15:30:06 +0100 Subject: [PATCH] Switched to a standard map for LazyPlaceholderTranslationExpressionHandler --- .../willfp/eco/internal/spigot/math/ExpressionHandlers.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/ExpressionHandlers.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/ExpressionHandlers.kt index 6f26c5ee0..6021f0e08 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/ExpressionHandlers.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/math/ExpressionHandlers.kt @@ -94,8 +94,7 @@ class ImmediatePlaceholderTranslationExpressionHandler( class LazyPlaceholderTranslationExpressionHandler( private val placeholderParser: PlaceholderParser ) : ExpressionHandler { - private val cache: Cache = Caffeine.newBuilder() - .build() + private val cache = mutableMapOf() override fun evaluate(expression: String, context: PlaceholderContext): Double? { val placeholders = PlaceholderManager.findPlaceholdersIn(expression) @@ -104,7 +103,7 @@ class LazyPlaceholderTranslationExpressionHandler( .map { it.fastToDoubleOrNull() ?: 0.0 } .toDoubleArray() - val compiled = cache.get(expression) { + val compiled = cache.getOrPut(expression) { val env = EvaluationEnvironment() env.setVariableNames(*placeholders.toTypedArray()) env.addFunctions(min, max)