From 6206ae4d22742d917b76e1ad6a09360b94d83c89 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sat, 3 Jun 2023 15:19:38 +0100 Subject: [PATCH] Fixed custom placeholders not allowing evaluation to zero --- core/build.gradle.kts | 2 +- .../com/willfp/libreforge/LibreforgeSpigotPlugin.kt | 2 +- .../libreforge/placeholders/CustomPlaceholder.kt | 10 +++------- .../com/willfp/libreforge/loader/LibreforgePlugin.kt | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 7b695d79b..1268f7fbc 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -3,7 +3,7 @@ dependencies { isTransitive = false } - compileOnly("com.willfp:eco:6.60.0") + compileOnly("com.willfp:eco:6.63.0") compileOnly("io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT") compileOnly("com.github.Archy-X:AureliumSkills:Beta1.2.4") diff --git a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt index d6c083901..cebf434aa 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt @@ -146,7 +146,7 @@ class LibreforgeSpigotPlugin : EcoPlugin() { } override fun getMinimumEcoVersion(): String { - return "6.60.0" + return "6.63.0" } /** diff --git a/core/src/main/kotlin/com/willfp/libreforge/placeholders/CustomPlaceholder.kt b/core/src/main/kotlin/com/willfp/libreforge/placeholders/CustomPlaceholder.kt index 858fa88a0..0657071b4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/placeholders/CustomPlaceholder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/placeholders/CustomPlaceholder.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.placeholders import com.willfp.eco.core.placeholder.RegistrablePlaceholder import com.willfp.eco.core.placeholder.context.PlaceholderContext import com.willfp.eco.core.registry.KRegistrable -import com.willfp.eco.util.evaluateExpression +import com.willfp.eco.util.evaluateExpressionOrNull import com.willfp.eco.util.formatEco import com.willfp.eco.util.toNiceString @@ -13,16 +13,12 @@ abstract class CustomPlaceholder( abstract val placeholder: RegistrablePlaceholder protected fun parseValue(expression: String, ctx: PlaceholderContext): String { - val asNumber = evaluateExpression( + val asNumber = evaluateExpressionOrNull( expression, ctx ) - return if (asNumber != 0.0) { - asNumber.toNiceString() - } else { - expression.formatEco(ctx) - } + return asNumber?.toNiceString() ?: expression.formatEco(ctx) } override fun onRegister() { diff --git a/loader/src/main/kotlin/com/willfp/libreforge/loader/LibreforgePlugin.kt b/loader/src/main/kotlin/com/willfp/libreforge/loader/LibreforgePlugin.kt index 9db6b8ba1..5929f51ac 100644 --- a/loader/src/main/kotlin/com/willfp/libreforge/loader/LibreforgePlugin.kt +++ b/loader/src/main/kotlin/com/willfp/libreforge/loader/LibreforgePlugin.kt @@ -203,7 +203,7 @@ abstract class LibreforgePlugin : EcoPlugin() { } override fun getMinimumEcoVersion(): String { - return "6.60.0" + return "6.63.0" } /**