aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-07-30 16:43:09 +0200
committerLorenz <lo.scherf@gmail.com>2022-07-30 16:43:09 +0200
commit75e07d9bbcd92ffd42f1bb901f9a8890582afa9f (patch)
tree8f45a583eb7da499b4fbfb7f3b762a38f7c8141c /src/main
parent201f2853f7b87889159c0eb7ed24952c3a2fa9c2 (diff)
downloadNotEnoughUpdates-75e07d9bbcd92ffd42f1bb901f9a8890582afa9f.tar.gz
NotEnoughUpdates-75e07d9bbcd92ffd42f1bb901f9a8890582afa9f.tar.bz2
NotEnoughUpdates-75e07d9bbcd92ffd42f1bb901f9a8890582afa9f.zip
fixed internal problems with data loading order
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java25
-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/MinionHelperTooltips.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java19
6 files changed, 40 insertions, 15 deletions
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 af9a0c44..0a6c4a99 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
@@ -91,6 +91,10 @@ public class MinionHelperManager {
.getUnformattedText().equalsIgnoreCase("Crafted Minions");
}
+ public boolean isReadyToUse() {
+ return MinionHelperRepoLoader.getInstance().isRepoReadyToUse();
+ }
+
public Minion getMinionById(String internalName) {
if (minions.containsKey(internalName)) {
return minions.get(internalName);
@@ -320,28 +324,35 @@ public class MinionHelperManager {
public void handleCommand(String[] args) {
if (args.length == 2) {
String parameter = args[1];
- if (parameter.equals("clear")) {
+ if (parameter.equals("clearminion")) {
minions.clear();
- Utils.addChatMessage("minions cleared");
+ Utils.addChatMessage("minion map cleared");
return;
}
- if (parameter.equals("resetrepo")) {
+ if (parameter.equals("reloadrepo")) {
MinionHelperRepoLoader.getInstance().setDirty();
Utils.addChatMessage("repo reload requested");
return;
}
- if (parameter.equals("resetapi")) {
+ if (parameter.equals("reloadapi")) {
+ apiData = null;
MinionHelperApiLoader.getInstance().setDirty();
Utils.addChatMessage("api reload requested");
return;
}
+ if (parameter.equals("clearapi")) {
+ apiData = null;
+ Utils.addChatMessage("api data cleared");
+ return;
+ }
}
Utils.addChatMessage("");
Utils.addChatMessage("§3NEU Minion Helper commands: §c((for testing only!)");
- Utils.addChatMessage("§6/neudevtest minion clear §7Clears the internal minion data");
- Utils.addChatMessage("§6/neudevtest minion resetrepo §7Manually loading the data from repo");
- Utils.addChatMessage("§6/neudevtest minion resetapi §7Manually loading the data from api");
+ Utils.addChatMessage("§6/neudevtest minion clearminion §7Clears the minion map");
+ Utils.addChatMessage("§6/neudevtest minion reloadrepo §7Manually loading the data from repo");
+ Utils.addChatMessage("§6/neudevtest minion reloadapi §7Manually loading the data from api");
+ Utils.addChatMessage("§6/neudevtest minion clearapi §7Clears the api data");
Utils.addChatMessage("");
}
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 9ca7c107..e455e61c 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
@@ -86,6 +86,7 @@ public class MinionHelperOverlay {
@SubscribeEvent
public void onDrawBackground(GuiScreenEvent.BackgroundDrawnEvent event) {
if (!manager.inCraftedMinionsInventory()) return;
+ if (!manager.isReadyToUse()) return;
if (manager.isShouldNotifyNoCollectionApi()) {
NotificationHandler.displayNotification(Lists.newArrayList(
@@ -107,6 +108,7 @@ public class MinionHelperOverlay {
@SubscribeEvent
public void onMouseClick(GuiScreenEvent.MouseInputEvent.Pre event) {
if (!manager.inCraftedMinionsInventory()) return;
+ if (!manager.isReadyToUse()) return;
if (!Mouse.getEventButtonState()) return;
LinkedHashMap<String, RenderableObject> renderMap = getRenderMap();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperTooltips.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperTooltips.java
index 71293815..135a8b64 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperTooltips.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperTooltips.java
@@ -45,9 +45,9 @@ public class MinionHelperTooltips {
}
@SubscribeEvent(priority = EventPriority.LOW)
- public void onItemTooltipLow(ItemTooltipEvent event) {
+ public void onItemTooltip(ItemTooltipEvent event) {
if (!manager.inCraftedMinionsInventory()) return;
- if (!NotEnoughUpdates.INSTANCE.config.fishing.trophyRewardTooltips) return;
+ if (!manager.isReadyToUse()) return;
boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
if (!pressedShiftLast && shift) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java
index 3f1ec62c..03c7e271 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java
@@ -26,6 +26,7 @@ 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.MinionHelperManager;
+import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperOverlay;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.SBInfo;
@@ -46,7 +47,7 @@ public class MinionHelperApiLoader {
private final MinionHelperManager manager = MinionHelperManager.getInstance();
private boolean dirty = true;
private int ticks = 0;
- boolean collectionApiEnabled = true;
+ private boolean collectionApiEnabled = true;
public static MinionHelperApiLoader getInstance() {
if (instance == null) {
@@ -191,6 +192,7 @@ public class MinionHelperApiLoader {
!collectionApiEnabled
));
manager.reloadRequirements();
+ MinionHelperOverlay.getInstance().resetCache();
}
public void setDirty() {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java
index e4f6aace..249b49ee 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java
@@ -54,6 +54,7 @@ public class MinionHelperInventoryLoader {
@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (!manager.isReadyToUse()) return;
ticks++;
if (ticks % 5 != 0) return;
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 d275909d..7fecea6b 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
@@ -52,6 +52,7 @@ public class MinionHelperRepoLoader {
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) {
@@ -65,8 +66,7 @@ public class MinionHelperRepoLoader {
*/
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onRepoReload(RepositoryReloadEvent event) {
- dirty = true;
- displayNameCache.clear();
+ setDirty();
}
@SubscribeEvent
@@ -95,7 +95,10 @@ public class MinionHelperRepoLoader {
loadMinionData();
loadCustomSources();
- checkMissingData();
+ testForMissingData();
+
+ manager.reloadRequirements();
+ repoReadyToUse = true;
if (error) {
Utils.showOutdatedRepoNotification();
@@ -175,7 +178,7 @@ public class MinionHelperRepoLoader {
}
}
- private void checkMissingData() {
+ private void testForMissingData() {
for (Minion minion : manager.getAllMinions().values()) {
if (minion.getMinionSource() == null) {
error = true;
@@ -368,6 +371,12 @@ public class MinionHelperRepoLoader {
}
public void setDirty() {
- this.dirty = true;
+ dirty = true;
+ displayNameCache.clear();
+ repoReadyToUse = false;
+ }
+
+ public boolean isRepoReadyToUse() {
+ return repoReadyToUse;
}
}