diff --git a/gradle.properties b/gradle.properties index 8ce6fb6..8d8610b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.14.6 # Mod Properties - mod_version = 3.0.6 + mod_version = 3.0.7 maven_group = ca.rttv archives_base_name = chatcalc diff --git a/src/main/java/ca/rttv/chatcalc/MathEngine.java b/src/main/java/ca/rttv/chatcalc/MathEngine.java index b1e14bc..7daefaf 100644 --- a/src/main/java/ca/rttv/chatcalc/MathEngine.java +++ b/src/main/java/ca/rttv/chatcalc/MathEngine.java @@ -115,14 +115,13 @@ private static double eval(List tokens, boolean abs) { // recursive evalu } } else if (token instanceof OperatorToken operatorToken) { Token before = i == 0 ? null : tokens.get(i - 1); + double next = tokens.get(i + 1) instanceof NumberToken numberToken ? numberToken.val() : eval(tokens.subList(i + 1, tokens.size()), abs); if (before instanceof NumberToken) { double prev = ((NumberToken) before).val(); - double next = eval(tokens.subList(i + 1, tokens.size()), abs); tokens.set(i - 1, new NumberToken(operatorToken.apply(prev, next))); tokens.remove(i); tokens.remove(i); } else if (operatorToken.val == 45) { - double next = tokens.get(i + 1) instanceof NumberToken numberToken ? numberToken.val() : eval(tokens.subList(i + 1, tokens.size()), abs); tokens.set(i, new NumberToken(-next)); tokens.remove(i + 1); }