diff options
Diffstat (limited to 'src/main/java/io')
7 files changed, 228 insertions, 186 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index eeb6f096..17886a04 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -295,14 +295,8 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new OldAnimationChecker()); MinecraftForge.EVENT_BUS.register(new SignCalculator()); MinecraftForge.EVENT_BUS.register(TrophyRewardOverlay.getInstance()); - - MinecraftForge.EVENT_BUS.register(MinionHelperInventoryLoader.getInstance()); - MinecraftForge.EVENT_BUS.register(MinionHelperOverlay.getInstance()); - MinecraftForge.EVENT_BUS.register(MinionHelperTooltips.getInstance()); - MinecraftForge.EVENT_BUS.register(MinionHelperManager.getInstance()); - MinecraftForge.EVENT_BUS.register(MinionHelperChatLoader.getInstance()); - MinecraftForge.EVENT_BUS.register(PowerStoneStatsDisplay.getInstance()); + MinecraftForge.EVENT_BUS.register(MinionHelperManager.getInstance()); MinecraftForge.EVENT_BUS.register(navigation); if (Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) { 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 ac11be50..53fb06d3 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 @@ -21,6 +21,8 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders.MinionHelperApiLoader; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders.MinionHelperChatLoader; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders.MinionHelperInventoryLoader; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders.MinionHelperRepoLoader; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -41,6 +43,10 @@ public class MinionHelperManager { private final MinionHelperRequirementsManager requirementsManager = new MinionHelperRequirementsManager(this); private final MinionHelperApiLoader api = new MinionHelperApiLoader(this); private final MinionHelperRepoLoader repo = new MinionHelperRepoLoader(this); + private final MinionHelperOverlay overlay = new MinionHelperOverlay(this); + private final MinionHelperTooltips tooltips = new MinionHelperTooltips(this); + private final MinionHelperChatLoader chatLoader = new MinionHelperChatLoader(this); + private final MinionHelperInventoryLoader inventoryLoader = new MinionHelperInventoryLoader(this); public static MinionHelperManager getInstance() { if (instance == null) { @@ -53,6 +59,10 @@ public class MinionHelperManager { MinecraftForge.EVENT_BUS.register(priceCalculation); MinecraftForge.EVENT_BUS.register(api); MinecraftForge.EVENT_BUS.register(repo); + MinecraftForge.EVENT_BUS.register(overlay); + MinecraftForge.EVENT_BUS.register(tooltips); + MinecraftForge.EVENT_BUS.register(chatLoader); + MinecraftForge.EVENT_BUS.register(inventoryLoader); } public boolean inCraftedMinionsInventory() { @@ -188,4 +198,8 @@ public class MinionHelperManager { public MinionHelperRepoLoader getRepo() { return repo; } + + public MinionHelperOverlay getOverlay() { + return overlay; + } } 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 81fd0801..e9cb0a53 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 @@ -19,18 +19,12 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper; -import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Lists; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscgui.TrophyRewardOverlay; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders.MinionHelperRepoLoader; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.renderables.RenderableObject; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.renderables.RenderableText; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.CollectionRequirement; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.MinionRequirement; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.CraftingSource; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.MinionSource; -import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.NpcSource; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer; import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.Utils; @@ -49,25 +43,20 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; public class MinionHelperOverlay { - private static MinionHelperOverlay instance = null; - private final MinionHelperManager manager = MinionHelperManager.getInstance(); - private Minion lastHovered = null; + private final MinionHelperManager manager; + private final MinionHelperOverlayHover hover; private LinkedHashMap<String, RenderableObject> cacheRenderMapShift = null; private LinkedHashMap<String, RenderableObject> cacheRenderMapNoShift = null; - public static MinionHelperOverlay getInstance() { - if (instance == null) { - instance = new MinionHelperOverlay(); - } - return instance; + public MinionHelperOverlay(MinionHelperManager manager) { + this.manager = manager; + hover = new MinionHelperOverlayHover(this, manager); } @SubscribeEvent @@ -101,7 +90,7 @@ public class MinionHelperOverlay { LinkedHashMap<String, RenderableObject> renderMap = getRenderMap(); - renderHover(renderMap); + hover.renderHover(renderMap); render(event, renderMap); } @@ -111,9 +100,7 @@ public class MinionHelperOverlay { if (!manager.isReadyToUse()) return; if (!Mouse.getEventButtonState()) return; - LinkedHashMap<String, RenderableObject> renderMap = getRenderMap(); - - RenderableObject mouseObject = getObjectOverMouse(renderMap); + RenderableObject mouseObject = getObjectOverMouse(getRenderMap()); if (mouseObject != null) { if (mouseObject instanceof MinionSource) { @@ -124,139 +111,6 @@ public class MinionHelperOverlay { } } - private RenderableObject getObjectOverMouse(LinkedHashMap<String, RenderableObject> renderMap) { - GuiScreen gui = Minecraft.getMinecraft().currentScreen; - if (!(gui instanceof GuiChest)) return null; - - int xSize = ((AccessorGuiContainer) gui).getXSize(); - int guiLeft = ((AccessorGuiContainer) gui).getGuiLeft(); - int guiTop = ((AccessorGuiContainer) gui).getGuiTop(); - - int x = guiLeft + xSize + 4; - int y = guiTop; - - final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); - final int scaledWidth = scaledresolution.getScaledWidth(); - final int scaledHeight = scaledresolution.getScaledHeight(); - int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; - int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; - - int index = 0; - for (RenderableObject renderableObject : renderMap.values()) { - - if (mouseX > x && mouseX < x + 130 && - mouseY > y + index && mouseY < y + 13 + index) { - return renderableObject; - } - index += 10; - } - - return null; - } - - private void renderHover(LinkedHashMap<String, RenderableObject> renderMap) { - lastHovered = null; - - if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return; - - final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); - final int scaledWidth = scaledresolution.getScaledWidth(); - final int scaledHeight = scaledresolution.getScaledHeight(); - int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; - int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; - - RenderableObject mouseObject = getObjectOverMouse(renderMap); - if (mouseObject != null) { - GlStateManager.pushMatrix(); - GlStateManager.scale(2f / scaledresolution.getScaleFactor(), 2f / scaledresolution.getScaleFactor(), 1); - Utils.drawHoveringText(getTooltip(mouseObject), - mouseX * scaledresolution.getScaleFactor() / 2, - mouseY * scaledresolution.getScaleFactor() / 2, - scaledWidth * scaledresolution.getScaleFactor() / 2, - scaledHeight * scaledresolution.getScaleFactor() / 2, -1, Minecraft.getMinecraft().fontRendererObj - ); - GlStateManager.popMatrix(); - } - } - - private List<String> getTooltip(RenderableObject renderableObject) { - List<String> lines = new ArrayList<>(); - - if (renderableObject instanceof RenderableText) { - RenderableText renderableText = (RenderableText) renderableObject; - lines.addAll(renderableText.getLines()); - } else if (renderableObject instanceof MinionSource) { - MinionSource minionSource = (MinionSource) renderableObject; - - Minion minion = minionSource.getMinion(); - lastHovered = minion; - String displayName = minion.getDisplayName(); - lines.add("§9" + displayName + " " + minion.getTier()); - List<MinionRequirement> requirements = manager.getRequirementsManager().getRequirements(minionSource.getMinion()); - if (!requirements.isEmpty()) { - for (MinionRequirement requirement : requirements) { - //TODO maybe change the §7 color - String color = manager.getRequirementsManager().meetRequirement(minion, requirement) ? "§a" : "§7"; - if (requirement instanceof CollectionRequirement && manager.getApi().isCollectionApiDisabled()) { - color = "§cAPI DISABLED! §7"; - } - lines.add(" §8- " + color + requirement.printDescription()); - } - } else { - lines.add("§cNo requirements loaded!"); - } - - if (minionSource instanceof CraftingSource) { - CraftingSource craftingSource = (CraftingSource) minionSource; - lines.add(""); - String format = manager.getPriceCalculation().calculateUpgradeCostsFormat(craftingSource, true); - if (minion.getTier() == 1) { - lines.add("§7Full crafting costs: " + format); - } else { - lines.add("§7Upgrade costs: " + format); - } - formatItems(lines, grabAllItems(craftingSource.getItems())); - - } else if (minionSource instanceof NpcSource) { - NpcSource npcSource = (NpcSource) minionSource; - String npcName = npcSource.getNpcName(); - lines.add(""); - lines.add("§7Buy from: §9" + npcName + " (NPC)"); - lines.add(""); - lines.add("§7Buy costs: " + manager.getPriceCalculation().calculateUpgradeCostsFormat(npcSource, true)); - lines.add(" §8- " + manager.getPriceCalculation().formatCoins(npcSource.getCoins())); - formatItems(lines, grabAllItems(npcSource.getItems())); - } - - lines.add(""); - lines.add("§eClick to view recipe"); - } - return lines; - } - - private void formatItems(List<String> lines, Map<String, Integer> allItems) { - for (Map.Entry<String, Integer> entry : allItems.entrySet()) { - String internalName = entry.getKey(); - String name = manager.getRepo().getDisplayName(internalName); - - int amount = entry.getValue(); - String amountText = amount != 1 ? amount + "§7x " : ""; - String price = manager.getPriceCalculation().formatCoins(manager.getPriceCalculation().getPrice(internalName) * amount); - lines.add(" §8- §a" + amountText + "§f" + name + " " + price); - } - } - - private Map<String, Integer> grabAllItems(ArrayListMultimap<String, Integer> multimap) { - Map<String, Integer> allItems = new HashMap<>(); - for (Map.Entry<String, Integer> entry : multimap.entries()) { - String name = entry.getKey(); - int amount = entry.getValue(); - amount = allItems.getOrDefault(name, 0) + amount; - allItems.put(name, amount); - } - return allItems; - } - private Map<Minion, Long> getMissing(boolean shift) { Map<Minion, Long> prices = new HashMap<>(); for (Minion minion : manager.getAllMinions().values()) { @@ -292,7 +146,7 @@ public class MinionHelperOverlay { String prefix = ""; if (renderableObject instanceof MinionSource) { Minion minion = ((MinionSource) renderableObject).getMinion(); - if (lastHovered == minion) { + if (minion == hover.getLastHovered()) { prefix = "§e"; } } @@ -354,4 +208,34 @@ public class MinionHelperOverlay { return renderMap; } + + RenderableObject getObjectOverMouse(LinkedHashMap<String, RenderableObject> renderMap) { + GuiScreen gui = Minecraft.getMinecraft().currentScreen; + if (!(gui instanceof GuiChest)) return null; + + int xSize = ((AccessorGuiContainer) gui).getXSize(); + int guiLeft = ((AccessorGuiContainer) gui).getGuiLeft(); + int guiTop = ((AccessorGuiContainer) gui).getGuiTop(); + + int x = guiLeft + xSize + 4; + int y = guiTop; + + final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + final int scaledWidth = scaledresolution.getScaledWidth(); + final int scaledHeight = scaledresolution.getScaledHeight(); + int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; + int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; + + int index = 0; + for (RenderableObject renderableObject : renderMap.values()) { + + if (mouseX > x && mouseX < x + 130 && + mouseY > y + index && mouseY < y + 13 + index) { + return renderableObject; + } + index += 10; + } + + return null; + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlayHover.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlayHover.java new file mode 100644 index 00000000..8bc04731 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperOverlayHover.java @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.miscgui.minionhelper; + +import com.google.common.collect.ArrayListMultimap; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.renderables.RenderableObject; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.renderables.RenderableText; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.CollectionRequirement; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.requirements.MinionRequirement; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.CraftingSource; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.MinionSource; +import io.github.moulberry.notenoughupdates.miscgui.minionhelper.sources.NpcSource; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.input.Mouse; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +public class MinionHelperOverlayHover { + + private final MinionHelperOverlay overlay; + private final MinionHelperManager manager; + private Minion lastHovered = null; + + public MinionHelperOverlayHover(MinionHelperOverlay overlay, MinionHelperManager manager) { + this.overlay = overlay; + this.manager = manager; + } + + void renderHover(LinkedHashMap<String, RenderableObject> renderMap) { + lastHovered = null; + + if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return; + + final ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + final int scaledWidth = scaledresolution.getScaledWidth(); + final int scaledHeight = scaledresolution.getScaledHeight(); + int mouseX = Mouse.getX() * scaledWidth / Minecraft.getMinecraft().displayWidth; + int mouseY = scaledHeight - Mouse.getY() * scaledHeight / Minecraft.getMinecraft().displayHeight - 1; + + RenderableObject mouseObject = overlay.getObjectOverMouse(renderMap); + if (mouseObject != null) { + GlStateManager.pushMatrix(); + GlStateManager.scale(2f / scaledresolution.getScaleFactor(), 2f / scaledresolution.getScaleFactor(), 1); + Utils.drawHoveringText(getTooltip(mouseObject), + mouseX * scaledresolution.getScaleFactor() / 2, + mouseY * scaledresolution.getScaleFactor() / 2, + scaledWidth * scaledresolution.getScaleFactor() / 2, + scaledHeight * scaledresolution.getScaleFactor() / 2, -1, Minecraft.getMinecraft().fontRendererObj + ); + GlStateManager.popMatrix(); + } + } + + private List<String> getTooltip(RenderableObject renderableObject) { + List<String> lines = new ArrayList<>(); + + if (renderableObject instanceof RenderableText) { + RenderableText renderableText = (RenderableText) renderableObject; + lines.addAll(renderableText.getLines()); + } else if (renderableObject instanceof MinionSource) { + MinionSource minionSource = (MinionSource) renderableObject; + + Minion minion = minionSource.getMinion(); + lastHovered = minion; + String displayName = minion.getDisplayName(); + lines.add("§9" + displayName + " " + minion.getTier()); + List<MinionRequirement> requirements = manager.getRequirementsManager().getRequirements(minionSource.getMinion()); + if (!requirements.isEmpty()) { + for (MinionRequirement requirement : requirements) { + //TODO maybe change the §7 color + String color = manager.getRequirementsManager().meetRequirement(minion, requirement) ? "§a" : "§7"; + if (requirement instanceof CollectionRequirement && manager.getApi().isCollectionApiDisabled()) { + color = "§cAPI DISABLED! §7"; + } + lines.add(" §8- " + color + requirement.printDescription()); + } + } else { + lines.add("§cNo requirements loaded!"); + } + + if (minionSource instanceof CraftingSource) { + CraftingSource craftingSource = (CraftingSource) minionSource; + lines.add(""); + String format = manager.getPriceCalculation().calculateUpgradeCostsFormat(craftingSource, true); + if (minion.getTier() == 1) { + lines.add("§7Full crafting costs: " + format); + } else { + lines.add("§7Upgrade costs: " + format); + } + formatItems(lines, grabAllItems(craftingSource.getItems())); + + } else if (minionSource instanceof NpcSource) { + NpcSource npcSource = (NpcSource) minionSource; + String npcName = npcSource.getNpcName(); + lines.add(""); + lines.add("§7Buy from: §9" + npcName + " (NPC)"); + lines.add(""); + lines.add("§7Buy costs: " + manager.getPriceCalculation().calculateUpgradeCostsFormat(npcSource, true)); + lines.add(" §8- " + manager.getPriceCalculation().formatCoins(npcSource.getCoins())); + formatItems(lines, grabAllItems(npcSource.getItems())); + } + + lines.add(""); + lines.add("§eClick to view recipe"); + } + return lines; + } + + private void formatItems(List<String> lines, Map<String, Integer> allItems) { + for (Map.Entry<String, Integer> entry : allItems.entrySet()) { + String internalName = entry.getKey(); + String name = manager.getRepo().getDisplayName(internalName); + + int amount = entry.getValue(); + String amountText = amount != 1 ? amount + "§7x " : ""; + String price = manager.getPriceCalculation().formatCoins( + manager.getPriceCalculation().getPrice(internalName) * amount); + lines.add(" §8- §a" + amountText + "§f" + name + " " + price); + } + } + + private Map<String, Integer> grabAllItems(ArrayListMultimap<String, Integer> multimap) { + Map<String, Integer> allItems = new HashMap<>(); + for (Map.Entry<String, Integer> entry : multimap.entries()) { + String name = entry.getKey(); + int amount = entry.getValue(); + amount = allItems.getOrDefault(name, 0) + amount; + allItems.put(name, amount); + } + return allItems; + } + + public Minion getLastHovered() { + return lastHovered; + } +} 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 b92ee768..ee250b89 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 @@ -32,16 +32,12 @@ import org.lwjgl.input.Keyboard; import java.util.List; public class MinionHelperTooltips { - private static MinionHelperTooltips instance = null; - private final MinionHelperManager manager = MinionHelperManager.getInstance(); + private final MinionHelperManager manager; private boolean pressedShiftLast = false; private boolean showFullCost = false; - public static MinionHelperTooltips getInstance() { - if (instance == null) { - instance = new MinionHelperTooltips(); - } - return instance; + public MinionHelperTooltips(MinionHelperManager manager) { + this.manager = manager; } @SubscribeEvent(priority = EventPriority.LOW) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperChatLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperChatLoader.java index ed379354..36f6b515 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperChatLoader.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperChatLoader.java @@ -29,14 +29,11 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class MinionHelperChatLoader { - private static MinionHelperChatLoader instance = null; - private final MinionHelperManager manager = MinionHelperManager.getInstance(); - public static MinionHelperChatLoader getInstance() { - if (instance == null) { - instance = new MinionHelperChatLoader(); - } - return instance; + private final MinionHelperManager manager; + + public MinionHelperChatLoader(MinionHelperManager manager) { + this.manager = manager; } @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) @@ -61,7 +58,7 @@ public class MinionHelperChatLoader { String name = text.substring(rawTier.length() + 1); setCrafted(manager.getMinionByName(name, tier)); - MinionHelperOverlay.getInstance().resetCache(); + manager.getOverlay().resetCache(); } if (message.startsWith("§r§7Switching to profile ")) { 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 249b49ee..b8943c38 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 @@ -38,19 +38,15 @@ import java.util.ArrayList; import java.util.List; public class MinionHelperInventoryLoader { - private static MinionHelperInventoryLoader instance = null; - private final MinionHelperManager manager = MinionHelperManager.getInstance(); private final List<String> loadedAlready = new ArrayList<>(); - - public static MinionHelperInventoryLoader getInstance() { - if (instance == null) { - instance = new MinionHelperInventoryLoader(); - } - return instance; - } + private final MinionHelperManager manager; int ticks = 0; + public MinionHelperInventoryLoader(MinionHelperManager manager) { + this.manager = manager; + } + @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; @@ -112,7 +108,7 @@ public class MinionHelperInventoryLoader { } } if (crafted > 0) { - MinionHelperOverlay.getInstance().resetCache(); + manager.getOverlay().resetCache(); } } } |