Skip to content

Commit

Permalink
Fixed custom placeholders not allowing evaluation to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Jun 3, 2023
1 parent e7a5ae9 commit 6206ae4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class LibreforgeSpigotPlugin : EcoPlugin() {
}

override fun getMinimumEcoVersion(): String {
return "6.60.0"
return "6.63.0"
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ abstract class LibreforgePlugin : EcoPlugin() {
}

override fun getMinimumEcoVersion(): String {
return "6.60.0"
return "6.63.0"
}

/**
Expand Down

0 comments on commit 6206ae4

Please sign in to comment.