aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java29
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java27
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java11
3 files changed, 35 insertions, 32 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index f1220b34..4d8f3967 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -132,6 +132,8 @@ public class NEUManager {
private final HashMap<String, Set<NeuRecipe>> recipesMap = new HashMap<>();
private final HashMap<String, Set<NeuRecipe>> usagesMap = new HashMap<>();
+ private final Map<String, String> displayNameCache = new HashMap<>();
+
public String latestRepoCommit = null;
public File configLocation;
@@ -1565,6 +1567,7 @@ public class NEUManager {
new RepositoryReloadEvent(repoLocation, !hasBeenLoadedBefore).post();
hasBeenLoadedBefore = true;
comp.complete(null);
+ displayNameCache.clear();
} catch (Exception e) {
comp.completeExceptionally(e);
}
@@ -1577,4 +1580,30 @@ public class NEUManager {
if (jsonObject == null) return null;
return jsonToStack(jsonObject);
}
+
+ public String getDisplayName(String internalName) {
+ if (displayNameCache.containsKey(internalName)) {
+ return displayNameCache.get(internalName);
+ }
+
+ String displayName = null;
+ TreeMap<String, JsonObject> itemInformation = NotEnoughUpdates.INSTANCE.manager.getItemInformation();
+ if (itemInformation.containsKey(internalName)) {
+ JsonObject jsonObject = itemInformation.get(internalName);
+ if (jsonObject.has("displayname")) {
+ displayName = jsonObject.get("displayname").getAsString();
+ }
+ }
+
+ if (displayName == null) {
+ displayName = internalName;
+ Utils.showOutdatedRepoNotification();
+ if (NotEnoughUpdates.INSTANCE.config.hidden.dev) {
+ Utils.addChatMessage("§c[NEU] Found no display name in repo for '" + internalName + "'!");
+ }
+ }
+
+ displayNameCache.put(internalName, displayName);
+ return displayName;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java
index 857d206c..8cfe88e5 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/repo/MinionHelperRepoLoader.java
@@ -208,33 +208,6 @@ public class MinionHelperRepoLoader {
}
}
- //TODO move into utils class or somewhere
- public String getDisplayName(String internalName) {
- if (displayNameCache.containsKey(internalName)) {
- return displayNameCache.get(internalName);
- }
-
- String displayName = null;
- TreeMap<String, JsonObject> itemInformation = NotEnoughUpdates.INSTANCE.manager.getItemInformation();
- if (itemInformation.containsKey(internalName)) {
- JsonObject jsonObject = itemInformation.get(internalName);
- if (jsonObject.has("displayname")) {
- displayName = jsonObject.get("displayname").getAsString();
- }
- }
-
- if (displayName == null) {
- displayName = internalName;
- Utils.showOutdatedRepoNotification();
- if (NotEnoughUpdates.INSTANCE.config.hidden.dev) {
- Utils.addChatMessage("§c[NEU] Found no display name in repo for '" + internalName + "'!");
- }
- }
-
- displayNameCache.put(internalName, displayName);
- return displayName;
- }
-
public void setDirty() {
dirty = true;
displayNameCache.clear();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java
index 249c0324..ff2024d4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlayHover.java
@@ -20,6 +20,7 @@
package io.github.moulberry.notenoughupdates.miscgui.minionhelper.render;
import com.google.common.collect.ArrayListMultimap;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.ApiData;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.Minion;
@@ -235,12 +236,12 @@ public class MinionHelperOverlayHover {
continue;
}
- String name = manager.getRepo().getDisplayName(internalName);
-
+ String name = NotEnoughUpdates.INSTANCE.manager.getDisplayName(internalName);
String amountText = amount != 1 ? amount + "§7x " : "";
- String price = manager.getPriceCalculation().formatCoins(
- manager.getPriceCalculation().getPrice(internalName) * amount);
- lines.add(" §8- §a" + amountText + "§f" + name + " " + price);
+ long price = manager.getPriceCalculation().getPrice(internalName);
+ String priceFormat = manager.getPriceCalculation().formatCoins(
+ price * amount);
+ lines.add(" §8- §a" + amountText + "§f" + name + " " + priceFormat);
}
}