From b1fa15a4b7fc857f68b08d4ca6ba0b5a8ad21d99 Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Thu, 26 Aug 2021 14:54:16 +0200 Subject: fix max + save max to config --- .../moulberry/notenoughupdates/options/NEUConfig.java | 2 ++ .../notenoughupdates/overlays/MiningOverlay.java | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/main') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index 22d3f6ff..98816714 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -23,6 +23,7 @@ import org.lwjgl.util.vector.Vector2f; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; public class NEUConfig extends Config { @@ -285,6 +286,7 @@ public class NEUConfig extends Config { @Expose public ArrayList enchantColours = createDefaultEnchantColours(); @Expose public String repoURL = "https://github.com/Moulberry/NotEnoughUpdates-REPO/archive/master.zip"; @Expose public String repoCommitsURL = "https://api.github.com/repos/Moulberry/NotEnoughUpdates-REPO/commits/master"; + @Expose public Map commissionMaxes = new HashMap<>(); @Expose public boolean firstTimeSearchFocus = true; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java index 0ef6de52..dfc12246 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -38,8 +38,7 @@ public class MiningOverlay extends TextOverlay { super(position, dummyStrings, styleSupplier); } - private static final Pattern NUMBER_PATTERN = Pattern.compile("\\d+(?: |$)"); - private static Map commissionMaxes = new HashMap<>(); + private static final Pattern NUMBER_PATTERN = Pattern.compile("(?\\d*,?\\d+)(?: |$)"); public static Map commissionProgress = new LinkedHashMap<>(); @Override @@ -67,8 +66,10 @@ public class MiningOverlay extends TextOverlay { Matcher matcher = NUMBER_PATTERN.matcher(clean); if(matcher.find()) { try { - numberValue = Integer.parseInt(matcher.group()); - } catch(NumberFormatException ignored) {} + numberValue = Integer.parseInt(matcher.group("number").replace(",", "")); + } catch(NumberFormatException ignored) { + ignored.printStackTrace(); + } } } } @@ -80,7 +81,7 @@ public class MiningOverlay extends TextOverlay { } } if(name != null && numberValue > 0) { - commissionMaxes.put(name, numberValue); + NotEnoughUpdates.INSTANCE.config.hidden.commissionMaxes.put(name, numberValue); } } } @@ -343,8 +344,8 @@ public class MiningOverlay extends TextOverlay { } else if (entry.getValue() >= 0.25) { col = GOLD; } - if (true && commissionMaxes.containsKey(entry.getKey())) { - int max = commissionMaxes.get(entry.getKey()); + if (NotEnoughUpdates.INSTANCE.config.hidden.commissionMaxes.containsKey(entry.getKey())) { + int max = NotEnoughUpdates.INSTANCE.config.hidden.commissionMaxes.get(entry.getKey()); commissionsStrings.add(DARK_AQUA + entry.getKey() + ": " + col + Math.round(entry.getValue() * max) + "/" + max); } else { String valS = Utils.floatToString(entry.getValue() * 100, 1); -- cgit