Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
comma begone, im sorry world
Browse files Browse the repository at this point in the history
  • Loading branch information
RealRTTV committed Dec 2, 2023
1 parent c7f862e commit aef389e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/main/java/ca/rttv/chatcalc/ChatCalc.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ';';
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/ca/rttv/chatcalc/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public class Config {
DEFAULTS = ImmutableMap.<String, String>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");
Expand Down Expand Up @@ -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());
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/ca/rttv/chatcalc/Testcases.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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<Pair<String, Double>> list) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ca/rttv/chatcalc/mixin/ChatScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean> 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);
}
Expand Down

0 comments on commit aef389e

Please sign in to comment.