From 1e434a53201374f7e459c336c3459220cc9f104e Mon Sep 17 00:00:00 2001 From: David Mills <85420839+Keebler408@users.noreply.github.com> Date: Fri, 24 Sep 2021 16:02:27 -0500 Subject: Introduce location specific config, move commission maxes into it --- .../moulberry/notenoughupdates/options/NEUConfig.java | 18 +++++++++++++++--- .../notenoughupdates/overlays/MiningOverlay.java | 12 ++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) 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 a789acfd..d4a078a9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -264,6 +264,8 @@ public class NEUConfig extends Config { public static class Hidden { @Expose public HashMap profileSpecific = new HashMap<>(); + @Expose + public HashMap locationSpecific = new HashMap<>(); @Expose public List inventoryButtons = createDefaultInventoryButtons(); @Expose public boolean enableItemEditing = false; @@ -284,7 +286,6 @@ 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; @@ -361,9 +362,20 @@ public class NEUConfig extends Config { put("Sapphire", 0); put("Topaz", 0); }}; - } + } + + public HiddenLocationSpecific getLocationSpecific() { + if(SBInfo.getInstance().location == null) { + return null; + } + return hidden.locationSpecific.computeIfAbsent(SBInfo.getInstance().getLocation(), k-> new HiddenLocationSpecific()); + } + + public static class HiddenLocationSpecific { + @Expose public Map commissionMaxes = new HashMap<>(); + } - public static List createDefaultInventoryButtons() { + public static List createDefaultInventoryButtons() { List buttons = new ArrayList<>(); //Below crafting buttons.add(new InventoryButton(87, 63, null, true, false, false, 0, "")); 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 0beb8060..7a888191 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -79,8 +79,10 @@ public class MiningOverlay extends TextOverlay { } } } + + NEUConfig.HiddenLocationSpecific locationSpecific = NotEnoughUpdates.INSTANCE.config.getLocationSpecific(); if(name != null && numberValue > 0) { - NotEnoughUpdates.INSTANCE.config.hidden.commissionMaxes.put(name, numberValue); + locationSpecific.commissionMaxes.put(name, numberValue); } } } @@ -237,12 +239,13 @@ public class MiningOverlay extends TextOverlay { String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info); if (name.contains("Mithril Powder:")) { mithrilPowder = DARK_AQUA + Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", ""); + continue; } if (name.contains("Gemstone Powder:")) { gemstonePowder = DARK_AQUA + Utils.trimIgnoreColour(name).replaceAll("\u00a7[f|F|r]", ""); + continue; } - if (name.matches("\\xa7r\\xa79\\xa7lForges \\xa7r(?:\\xa7f\\(\\+1 more\\)\\xa7r)?")) { commissions = false; forges = true; @@ -343,8 +346,9 @@ public class MiningOverlay extends TextOverlay { } else if (entry.getValue() >= 0.25) { col = GOLD; } - if (NotEnoughUpdates.INSTANCE.config.hidden.commissionMaxes.containsKey(entry.getKey())) { - int max = NotEnoughUpdates.INSTANCE.config.hidden.commissionMaxes.get(entry.getKey()); + NEUConfig.HiddenLocationSpecific locationSpecific = NotEnoughUpdates.INSTANCE.config.getLocationSpecific(); + int max; + if (-1 != (max = locationSpecific.commissionMaxes.getOrDefault(entry.getKey(), -1))) { commissionsStrings.add(DARK_AQUA + entry.getKey() + ": " + col + Math.round(entry.getValue() * max) + "/" + max); } else { String valS = Utils.floatToString(entry.getValue() * 100, 1); -- cgit