Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97fba3e243 | ||
|
|
e47c6387a2 | ||
|
|
00df39097c | ||
|
|
efcb406e9a | ||
|
|
9e92ea6062 |
@@ -211,6 +211,7 @@ open class EcoJSONConfigWrapper : JSONConfig {
|
||||
override fun injectPlaceholders(placeholders: Iterable<StaticPlaceholder>) {
|
||||
injections.removeIf { placeholders.any { placeholder -> it.identifier == placeholder.identifier } }
|
||||
injections.addAll(placeholders)
|
||||
this.clearCache()
|
||||
}
|
||||
|
||||
override fun getInjectedPlaceholders(): List<StaticPlaceholder> {
|
||||
@@ -219,6 +220,7 @@ open class EcoJSONConfigWrapper : JSONConfig {
|
||||
|
||||
override fun clearInjectedPlaceholders() {
|
||||
injections.clear()
|
||||
this.clearCache()
|
||||
}
|
||||
|
||||
override fun getType(): ConfigType {
|
||||
|
||||
@@ -230,6 +230,7 @@ open class EcoYamlConfigWrapper<T : ConfigurationSection> : Config {
|
||||
override fun injectPlaceholders(placeholders: Iterable<StaticPlaceholder>) {
|
||||
injections.removeIf { placeholders.any { placeholder -> it.identifier == placeholder.identifier } }
|
||||
injections.addAll(placeholders)
|
||||
this.clearCache()
|
||||
}
|
||||
|
||||
override fun getInjectedPlaceholders(): List<StaticPlaceholder> {
|
||||
@@ -238,6 +239,7 @@ open class EcoYamlConfigWrapper<T : ConfigurationSection> : Config {
|
||||
|
||||
override fun clearInjectedPlaceholders() {
|
||||
injections.clear()
|
||||
this.clearCache()
|
||||
}
|
||||
|
||||
override fun getType(): ConfigType {
|
||||
|
||||
@@ -15,14 +15,12 @@ private val goToZero = Crunch.compileExpression("0")
|
||||
|
||||
fun evaluateExpression(expression: String, player: Player?, statics: Iterable<StaticPlaceholder>): Double {
|
||||
val placeholderValues = PlaceholderManager.findPlaceholdersIn(expression)
|
||||
.map { PlaceholderManager.translatePlaceholders(it, player) }
|
||||
.union(statics.map { it.value })
|
||||
.toList()
|
||||
.map { PlaceholderManager.translatePlaceholders(it, player, statics.toList()) }
|
||||
.map { runCatching { FastNumberParsing.parseDouble(it) }.getOrDefault(0.0) }
|
||||
.toDoubleArray()
|
||||
|
||||
val compiled = cache.get(expression) {
|
||||
val placeholders = PlaceholderManager.findPlaceholdersIn(it) union statics.map { static -> "%${static.identifier}%" }
|
||||
val placeholders = PlaceholderManager.findPlaceholdersIn(it)
|
||||
val env = EvaluationEnvironment()
|
||||
env.setVariableNames(*placeholders.toTypedArray())
|
||||
runCatching { Crunch.compileExpression(expression, env) }.getOrDefault(goToZero)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version = 6.28.0
|
||||
version = 6.28.1
|
||||
plugin-name = eco
|
||||
kotlin.code.style = official
|
||||
Reference in New Issue
Block a user