Compare commits

..

2 Commits

Author SHA1 Message Date
Auxilor
5ecae0a366 Updated to 6.57.1 2023-05-03 14:19:01 +01:00
Auxilor
5de4914fd7 Fixed expression loading, improved hash codes down evaluation pipeline 2023-05-03 14:18:50 +01:00
5 changed files with 41 additions and 4 deletions

View File

@@ -3,10 +3,12 @@ package com.willfp.eco.core.placeholder.context;
import com.willfp.eco.core.placeholder.InjectablePlaceholder;
import com.willfp.eco.core.placeholder.PlaceholderInjectable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
/**
@@ -67,4 +69,24 @@ public class MergedInjectableContext implements PlaceholderInjectable {
return injections;
}
@Override
public boolean equals(@Nullable final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof MergedInjectableContext that)) {
return false;
}
return Objects.equals(baseContext, that.baseContext)
&& Objects.equals(additionalContext, that.additionalContext)
&& Objects.equals(extraInjections, that.extraInjections);
}
@Override
public int hashCode() {
return Objects.hash(baseContext, additionalContext, extraInjections);
}
}

View File

@@ -251,6 +251,21 @@ open class EcoConfig(
}
override fun hashCode(): Int {
return Objects.hash(values, configType, injections)
/*
The keys are completely redundant, as they are only used to prevent
duplicate keys in the map. Therefore, we can ignore them and just
hash the actual placeholder values.
*/
var injectionHash = 0
for (injection in injections.values) {
injectionHash = injectionHash * 31 + injection.hashCode()
}
return Objects.hash(
values,
configType
) + injectionHash
}
}

View File

@@ -59,7 +59,7 @@ class EcoExtensionLoader(
val pluginVersion = Version(extensionYml.getStringOrNull("plugin-version") ?: "0.0.0")
val pluginName = extensionYml.getStringOrNull("plugin")
if (pluginName != null && pluginName.equals(this.plugin.description.name, ignoreCase = true)) {
if (pluginName != null && !pluginName.equals(this.plugin.description.name, ignoreCase = true)) {
throw ExtensionLoadException("${extensionJar.name} is only compatible with $pluginName!")
}

View File

@@ -10,7 +10,7 @@ import java.util.concurrent.TimeUnit
class DelegatedExpressionHandler(
plugin: EcoPlugin,
private val handler: ExpressionHandler
): ExpressionHandler {
) : ExpressionHandler {
private val evaluationCache: Cache<Int, Double> = Caffeine.newBuilder()
.expireAfterWrite(plugin.configYml.getInt("math-cache-ttl").toLong(), TimeUnit.MILLISECONDS)
.build()

View File

@@ -1,3 +1,3 @@
version = 6.57.0
version = 6.57.1
plugin-name = eco
kotlin.code.style = official