From aef389e4bd55a5e482ecee0ff517dc4d6d0ea7a3 Mon Sep 17 00:00:00 2001 From: RTTV Date: Sat, 2 Dec 2023 17:30:52 -0500 Subject: [PATCH] comma begone, im sorry world --- gradle.properties | 2 +- src/main/java/ca/rttv/chatcalc/ChatCalc.java | 2 +- src/main/java/ca/rttv/chatcalc/Config.java | 7 +------ src/main/java/ca/rttv/chatcalc/Testcases.java | 9 ++++++--- .../java/ca/rttv/chatcalc/mixin/ChatScreenMixin.java | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6d2c71f..6aa426e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,6 +8,6 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.14.23 # Mod Properties - mod_version = 3.0.22 + mod_version = 3.0.23 maven_group = ca.rttv archives_base_name = chatcalc diff --git a/src/main/java/ca/rttv/chatcalc/ChatCalc.java b/src/main/java/ca/rttv/chatcalc/ChatCalc.java index 025cd73..b60f271 100644 --- a/src/main/java/ca/rttv/chatcalc/ChatCalc.java +++ b/src/main/java/ca/rttv/chatcalc/ChatCalc.java @@ -16,7 +16,7 @@ public class ChatCalc { public static final Pattern NUMBER = Pattern.compile("[-+]?(\\d,?)+(\\.\\d+)?"); - public static final Pattern FUNCTION = Pattern.compile("[a-zA-Z]+\\(([a-zA-Z]+,)*?([a-zA-Z]+)\\)"); + public static final Pattern FUNCTION = Pattern.compile("[a-zA-Z]+\\(([a-zA-Z]+;)*?([a-zA-Z]+)\\)"); public static final Pattern CONSTANT = Pattern.compile("[a-zA-Z]+"); public static final String SEPARATOR = ";"; public static final char SEPARATOR_CHAR = ';'; diff --git a/src/main/java/ca/rttv/chatcalc/Config.java b/src/main/java/ca/rttv/chatcalc/Config.java index 41118b3..d623d59 100644 --- a/src/main/java/ca/rttv/chatcalc/Config.java +++ b/src/main/java/ca/rttv/chatcalc/Config.java @@ -22,8 +22,7 @@ public class Config { DEFAULTS = ImmutableMap.builder() .put("decimal_format", "#,##0.##") .put("radians", "false") - .put("copy_type", "none") - .put("calculate_last", "true") + .put("copy_type", "chat_history") .put("display_above", "true") .build(); CONFIG_FILE = new File(".", "config/chatcalc.json"); @@ -51,10 +50,6 @@ public class Config { } } - public static boolean calculateLast() { - return Boolean.parseBoolean(JSON.get("calculate_last").getAsString()); - } - public static DecimalFormat getDecimalFormat() { return new DecimalFormat(JSON.get("decimal_format").getAsString()); } diff --git a/src/main/java/ca/rttv/chatcalc/Testcases.java b/src/main/java/ca/rttv/chatcalc/Testcases.java index 9429700..ddac9e2 100644 --- a/src/main/java/ca/rttv/chatcalc/Testcases.java +++ b/src/main/java/ca/rttv/chatcalc/Testcases.java @@ -54,8 +54,9 @@ public interface Testcases { new Pair<>("|-2.5-0.1|", 2.6d), new Pair<>("0.5|-2.5-0.1|", 1.3d), new Pair<>("5%360", 5.0d), - new Pair<>("-5%360", -5.0d), - // add the two remaining signed ones + new Pair<>("-5%360", 355.0d), + new Pair<>("5%-360", -355.0d), + new Pair<>("-5%-360", -5.0d), new Pair<>("min(sqrt(37);6", 6.0d), new Pair<>("max(sqrt(37);7", 7.0d), new Pair<>("max(sqrt(2);sqrt(3);sqrt(5);sqrt(7);sqrt(11);sqrt(13);sqrt(17);sqrt(19);sqrt(23);sqrt(29);sqrt(31);sqrt(37);sqrt(41", (double) MathHelper.sqrt(41)), @@ -64,7 +65,9 @@ public interface Testcases { new Pair<>("clamp(pi;-2;4)", Math.PI), new Pair<>("cmp(-2;3)", -1.0d), new Pair<>("cmp(5;3)", 1.0d), - new Pair<>("cmp(5;3;5)", 0.0d) + new Pair<>("cmp(5;3;5)", 0.0d), + new Pair<>("gcf(4;2)", 2.0d), + new Pair<>("lcm(6;9)", 18.0d) ); static void test(List> list) { diff --git a/src/main/java/ca/rttv/chatcalc/mixin/ChatScreenMixin.java b/src/main/java/ca/rttv/chatcalc/mixin/ChatScreenMixin.java index daaa01c..9a9d575 100644 --- a/src/main/java/ca/rttv/chatcalc/mixin/ChatScreenMixin.java +++ b/src/main/java/ca/rttv/chatcalc/mixin/ChatScreenMixin.java @@ -22,7 +22,7 @@ abstract class ChatScreenMixin { @Inject(at = @At("HEAD"), method = "keyPressed(III)Z", cancellable = true) private void keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable cir) { - if (!Config.calculateLast() || ((ChatInputSuggesterDuck) this.chatInputSuggestor).chatcalc$pendingSuggestions().join().isEmpty()) { + if (((ChatInputSuggesterDuck) this.chatInputSuggestor).chatcalc$pendingSuggestions().join().isEmpty()) { if (keyCode == 258 && ChatCalc.tryParse(chatField)) { cir.setReturnValue(true); }