Skip to content

Commit 49ba4db

Browse files
committed
Replace Crunch with EvalEx 3.6.1 for BigDecimal-native math evaluation
1 parent 2abe95b commit 49ba4db

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

core/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies {
2929
compileOnly("me.TechsCode:UltraEconomyAPI:1.1.2")
3030
compileOnly("com.willfp:EcoBits:1.8.4")
3131
compileOnly(files("lib/RoyaleEconomyAPI.jar"))
32-
implementation("com.github.Redempt:Crunch:2.0")
32+
implementation("com.ezylang:EvalEx:3.6.1")
3333
compileOnly("com.bencodez:votingplugin:6.16.3")
3434
compileOnly(files("lib/SCore-5.26.5.17.jar"))
3535
compileOnly(files("lib/ExecutableItems-7.26.5.17.jar"))

core/src/main/java/cn/superiormc/ultimateshop/utils/MathUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import cn.superiormc.ultimateshop.managers.ConfigManager;
44
import cn.superiormc.ultimateshop.managers.ErrorManager;
5-
import redempt.crunch.Crunch;
5+
import com.ezylang.evalex.Expression;
66

77
import java.math.BigDecimal;
88
import java.math.RoundingMode;
@@ -57,7 +57,7 @@ public static BigDecimal doCalculate(String mathStr, int scale) {
5757
if (!ConfigManager.configManager.getBoolean("math.enabled")) {
5858
return new BigDecimal(mathStr);
5959
}
60-
return BigDecimal.valueOf(Crunch.evaluateExpression(mathStr)).setScale(scale, RoundingMode.HALF_UP);
60+
return new Expression(mathStr).evaluate().getNumberValue().setScale(scale, RoundingMode.HALF_UP);
6161
}
6262
catch (Throwable throwable) {
6363
if (ConfigManager.configManager.getBoolean("debug")) {

plugin/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ tasks.shadowJar {
1717
relocate("org.bstats", "cn.superiormc.ultimateshop.bstats")
1818
relocate("com.zaxxer.hikari", "cn.superiormc.ultimateshop.libs.hikari")
1919
relocate("com.cronutils", "cn.superiormc.ultimateshop.libs.cronutils")
20-
relocate("redempt.crunch", "cn.superiormc.ultimateshop.libs.crunch")
20+
relocate("com.ezylang", "cn.superiormc.ultimateshop.libs.evalex")
2121
relocate("org.json", "cn.superiormc.ultimateshop.libs.json")
2222
relocate("org.slf4j", "cn.superiormc.ultimateshop.libs.slf4j")
23-
relocate("javax.el", "cn.superiormc.ultimateshop.libs.javax.el")
24-
relocate("com.sun.el", "cn.superiormc.ultimateshop.libs.com.sun.el")
2523
relocate("cn.gtemc.itembridge", "cn.superiormc.ultimateshop.libs.itembridge")
2624

2725
mergeServiceFiles()

0 commit comments

Comments
 (0)