aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-07-30 22:45:34 +0200
committerLorenz <lo.scherf@gmail.com>2022-07-30 22:45:34 +0200
commitd7d365997d8e42791403d20c6a0bb1ea8f7a74db (patch)
tree383fd2f9499fa660e94f4cbb74c8ddf3f55f32af /src
parent7bdb944ea83a2255dadaa5f2624b7faa02553d98 (diff)
downloadNotEnoughUpdates-d7d365997d8e42791403d20c6a0bb1ea8f7a74db.tar.gz
NotEnoughUpdates-d7d365997d8e42791403d20c6a0bb1ea8f7a74db.tar.bz2
NotEnoughUpdates-d7d365997d8e42791403d20c6a0bb1ea8f7a74db.zip
moved all of repo logic into api class
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java11
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java10
4 files changed, 12 insertions, 12 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 366ad24c..eeb6f096 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -296,7 +296,6 @@ public class NotEnoughUpdates {
MinecraftForge.EVENT_BUS.register(new SignCalculator());
MinecraftForge.EVENT_BUS.register(TrophyRewardOverlay.getInstance());
- MinecraftForge.EVENT_BUS.register(MinionHelperRepoLoader.getInstance());
MinecraftForge.EVENT_BUS.register(MinionHelperInventoryLoader.getInstance());
MinecraftForge.EVENT_BUS.register(MinionHelperOverlay.getInstance());
MinecraftForge.EVENT_BUS.register(MinionHelperTooltips.getInstance());
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
index 27c7240e..ac11be50 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
@@ -40,6 +40,7 @@ public class MinionHelperManager {
private final MinionHelperPriceCalculation priceCalculation = new MinionHelperPriceCalculation(this);
private final MinionHelperRequirementsManager requirementsManager = new MinionHelperRequirementsManager(this);
private final MinionHelperApiLoader api = new MinionHelperApiLoader(this);
+ private final MinionHelperRepoLoader repo = new MinionHelperRepoLoader(this);
public static MinionHelperManager getInstance() {
if (instance == null) {
@@ -51,6 +52,7 @@ public class MinionHelperManager {
private MinionHelperManager() {
MinecraftForge.EVENT_BUS.register(priceCalculation);
MinecraftForge.EVENT_BUS.register(api);
+ MinecraftForge.EVENT_BUS.register(repo);
}
public boolean inCraftedMinionsInventory() {
@@ -67,8 +69,7 @@ public class MinionHelperManager {
}
public boolean isReadyToUse() {
- return MinionHelperRepoLoader.getInstance().isRepoReadyToUse() &&
- api.isApiReadyToUse();
+ return repo.isRepoReadyToUse() && api.isApiReadyToUse();
}
public Minion getMinionById(String internalName) {
@@ -113,7 +114,7 @@ public class MinionHelperManager {
return;
}
if (parameter.equals("reloadrepo")) {
- MinionHelperRepoLoader.getInstance().setDirty();
+ repo.setDirty();
Utils.addChatMessage("repo reload requested");
return;
}
@@ -183,4 +184,8 @@ public class MinionHelperManager {
public MinionHelperApiLoader getApi() {
return api;
}
+
+ public MinionHelperRepoLoader getRepo() {
+ return repo;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java
index 330d94c2..81fd0801 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlay.java
@@ -237,7 +237,7 @@ public class MinionHelperOverlay {
private void formatItems(List<String> lines, Map<String, Integer> allItems) {
for (Map.Entry<String, Integer> entry : allItems.entrySet()) {
String internalName = entry.getKey();
- String name = MinionHelperRepoLoader.getInstance().getDisplayName(internalName);
+ String name = manager.getRepo().getDisplayName(internalName);
int amount = entry.getValue();
String amountText = amount != 1 ? amount + "ยง7x " : "";
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
index 2bf0d8a0..817a8e3d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
@@ -47,18 +47,14 @@ import java.util.TreeMap;
import java.util.regex.Pattern;
public class MinionHelperRepoLoader {
- private static MinionHelperRepoLoader instance = null;
- private final MinionHelperManager manager = MinionHelperManager.getInstance();
+ private final MinionHelperManager manager;
private boolean dirty = true;
private int ticks = 0;
private final Map<String, String> displayNameCache = new HashMap<>();
private boolean repoReadyToUse = false;
- public static MinionHelperRepoLoader getInstance() {
- if (instance == null) {
- instance = new MinionHelperRepoLoader();
- }
- return instance;
+ public MinionHelperRepoLoader(MinionHelperManager manager) {
+ this.manager = manager;
}
/**