From f34220a92af85a33d979edb24ac5c3e698498fe3 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Wed, 22 Jun 2022 14:41:15 +0200 Subject: bug fixes (#172) * yikes * cookie warning * better wording in docs * edit items in parent that are the bounds of the item list * totalCount not updating when not present * unplayable * comment? * outdated repo notification * more notification * crash * more crash * cookie bug --- .../moulberry/notenoughupdates/NEUManager.java | 2 +- .../moulberry/notenoughupdates/NEUOverlay.java | 2 +- .../listener/NEUEventListener.java | 39 +++++++++------------- .../miscfeatures/CookieWarning.java | 28 ++++++---------- .../miscfeatures/PetInfoOverlay.java | 7 +--- .../profileviewer/GuiProfileViewer.java | 9 ++--- .../profileviewer/ProfileViewer.java | 10 ++++-- .../profileviewer/trophy/TrophyFishingPage.java | 1 + .../notenoughupdates/util/NotificationHandler.java | 7 ++++ .../moulberry/notenoughupdates/util/Utils.java | 20 +++++++++++ 10 files changed, 70 insertions(+), 55 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index c4efeb15..18d756d8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -835,7 +835,7 @@ public class NEUManager { case "viewrecipe": displayGuiItemRecipe(internalName); break; - case "viewoption": + case "viewpotion": neu.sendChatMessage("/viewpotion " + internalName.split(";")[0].toLowerCase(Locale.ROOT)); } displayGuiItemRecipe(internalName); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 8ed11dd8..e5a09f2c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1119,7 +1119,7 @@ public class NEUOverlay extends Gui { internalname.set(manager.getInternalNameForItem(hover)); itemstack.set(hover); } - } else if (!hoverInv) { + } else { Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.itemlist.paneGuiScale); int width = Utils.peekGuiScale().getScaledWidth(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java index ec459ad0..8b924d78 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/NEUEventListener.java @@ -19,12 +19,14 @@ package io.github.moulberry.notenoughupdates.listener; +import com.google.common.collect.Lists; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; +import io.github.moulberry.notenoughupdates.miscfeatures.CookieWarning; import io.github.moulberry.notenoughupdates.miscfeatures.CrystalMetalDetectorSolver; import io.github.moulberry.notenoughupdates.miscfeatures.CrystalOverlay; import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; @@ -36,6 +38,7 @@ import io.github.moulberry.notenoughupdates.miscgui.StorageOverlay; import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.ProfileApiSyncer; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; @@ -60,19 +63,11 @@ import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import static io.github.moulberry.notenoughupdates.util.NotificationHandler.notificationLines; - public class NEUEventListener { - private static long notificationDisplayMillis = 0; private final NotEnoughUpdates neu; private final ExecutorService itemPreloader = Executors.newFixedThreadPool(10); private final List toPreload = new ArrayList<>(); - /** - * When opening a GuiContainer, will reset the overlay and load the config. - * When closing a GuiContainer, will save the config. - * Also includes a dev feature used for automatically acquiring crafting information from the "Crafting Table" GUI. - */ private boolean joinedSB = false; private boolean preloadedItems = false; @@ -239,6 +234,7 @@ public class NEUEventListener { BackgroundBlur.markDirty(); NPCRetexturing.getInstance().tick(); StorageOverlay.getInstance().markDirty(); + CookieWarning.checkCookie(); if (neu.hasSkyblockScoreboard()) { for (TextOverlay overlay : OverlayManager.textOverlays) { @@ -278,8 +274,6 @@ public class NEUEventListener { if (!joinedSB) { joinedSB = true; - //SBGamemodes.loadFromFile(); - if (NotEnoughUpdates.INSTANCE.config.notifications.showUpdateMsg) { displayUpdateMessageIfOutOfDate(); } @@ -287,19 +281,18 @@ public class NEUEventListener { if (NotEnoughUpdates.INSTANCE.config.notifications.doRamNotif) { long maxMemoryMB = Runtime.getRuntime().maxMemory() / 1024L / 1024L; if (maxMemoryMB > 4100) { - notificationDisplayMillis = System.currentTimeMillis(); - notificationLines = new ArrayList<>(); - notificationLines.add(EnumChatFormatting.GRAY + "Too much memory allocated!"); - notificationLines.add(String.format( - EnumChatFormatting.DARK_GRAY + "NEU has detected %03dMB of memory allocated to Minecraft!", - maxMemoryMB - )); - notificationLines.add(EnumChatFormatting.GRAY + "It is recommended to allocated between 2-4GB of memory"); - notificationLines.add( - EnumChatFormatting.GRAY + "More than 4GB MAY cause FPS issues, EVEN if you have 16GB+ available"); - notificationLines.add(""); - notificationLines.add( - EnumChatFormatting.GRAY + "For more information, visit #ram-info in discord.gg/moulberry"); + NotificationHandler.displayNotification(Lists.newArrayList( + EnumChatFormatting.GRAY + "Too much memory allocated!", + String.format( + EnumChatFormatting.DARK_GRAY + "NEU has detected %03dMB of memory allocated to Minecraft!", + maxMemoryMB + ), + EnumChatFormatting.GRAY + "It is recommended to allocated between 2-4GB of memory", + EnumChatFormatting.GRAY + "More than 4GB MAY cause FPS issues, EVEN if you have 16GB+ available", + EnumChatFormatting.GRAY + "For more information, visit #ram-info in discord.gg/moulberry", + "", + EnumChatFormatting.GRAY + "Press X on your keyboard to close this notification" + ), false); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java index 2aec0fbe..ca1865cd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java @@ -26,34 +26,23 @@ import io.github.moulberry.notenoughupdates.util.NotificationHandler; import net.minecraft.client.Minecraft; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class CookieWarning { private static boolean hasNotified; - public CookieWarning() { - hasNotified = false; - } - - @SubscribeEvent - public void onJoinWorld(EntityJoinWorldEvent e) { - if (e.entity == Minecraft.getMinecraft().thePlayer) { - this.checkCookie(); - } - } - public static void resetNotification() { hasNotified = false; + NotificationHandler.cancelNotification(); } /** - * Checks the tab list for a cookie timer, and sends a chat message if the timer is within the tolerance + * Checks the tab list for a cookie timer, and sends a notification if the timer is within the tolerance */ - private void checkCookie() { - if (!hasNotified && NotEnoughUpdates.INSTANCE.config.notifications.doBoosterNotif) { - String[] lines = {}; + public static void checkCookie() { + if (NotEnoughUpdates.INSTANCE.config.notifications.doBoosterNotif && + NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) { + String[] lines; try { lines = ((AccessorGuiPlayerTabOverlay) Minecraft.getMinecraft().ingameGUI.getTabList()) .getFooter() @@ -106,6 +95,7 @@ public class CookieWarning { Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( EnumChatFormatting.RED + "NEU ran into an issue when retrieving the Booster Cookie Timer. Check the logs for details.")); + hasNotified = true; } if (minutes < NotEnoughUpdates.INSTANCE.config.notifications.boosterCookieWarningMins) { NotificationHandler.displayNotification(Lists.newArrayList( @@ -115,8 +105,12 @@ public class CookieWarning { "\u00a77Press X on your keyboard to close this notification" ), true, true); hasNotified = true; + } else if (hasNotified) { + NotificationHandler.cancelNotification(); + hasNotified = false; } } } + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index 4cf076d8..e910a802 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -639,12 +639,7 @@ public class PetInfoOverlay extends TextOverlay { public static Pet getPetFromStack(String name, String[] lore) { if (Constants.PETS == null || Constants.PETS.get("pet_levels") == null || Constants.PETS.get("pet_levels") instanceof JsonNull) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - "\u00a7cInvalid PET constants. Please run " + EnumChatFormatting.BOLD + "/neuresetrepo" + - EnumChatFormatting.RESET + EnumChatFormatting.RED + " and " + EnumChatFormatting.BOLD + "restart your game" + - EnumChatFormatting.RESET + EnumChatFormatting.RED + " in order to fix. " + EnumChatFormatting.DARK_RED + - EnumChatFormatting.BOLD + "If that doesn't fix it" + EnumChatFormatting.RESET + EnumChatFormatting.RED + - ", please join discord.gg/moulberry and post in #neu-support")); + Utils.showOutdatedRepoNotification(); return null; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java index 40445298..b1e76dcc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -958,6 +958,7 @@ public class GuiProfileViewer extends GuiScreen { List configList = NotEnoughUpdates.INSTANCE.config.profileViewer.pageLayout; for (int i = 0; i < configList.size(); i++) { ProfileViewerPage page = ProfileViewerPage.getById(configList.get(i)); + if (page == null) continue; if (page.stack == null || (page == ProfileViewerPage.BINGO && !showBingoPage)) { ignoredTabs++; continue; @@ -1324,7 +1325,7 @@ public class GuiProfileViewer extends GuiScreen { dungeonLevelTextField.setCustomBorderColour(0xffffffff); floorLevelTo = Integer.parseInt(dungeonLevelTextField.getText()); - JsonArray levelingArray = Utils.getElement(leveling, "catacombs").getAsJsonArray(); + JsonArray levelingArray = Utils.getElementOrDefault(leveling, "catacombs", new JsonArray()).getAsJsonArray(); float remaining = -((levelObjCata.level % 1) * levelObjCata.maxXpForLevel); @@ -1373,7 +1374,7 @@ public class GuiProfileViewer extends GuiScreen { profileInfo, "dungeons.dungeon_types.catacombs.experience" ), 0); - levelObjCata = ProfileViewer.getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(), + levelObjCata = ProfileViewer.getLevel(Utils.getElementOrDefault(leveling, "catacombs", new JsonArray()).getAsJsonArray(), cataXp, 99, false ); levelObjCata.totalXp = cataXp; @@ -1852,7 +1853,7 @@ public class GuiProfileViewer extends GuiScreen { "dungeons.player_classes." + skillName.toLowerCase() + ".experience" ), 0); ProfileViewer.Level levelObj = - ProfileViewer.getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(), + ProfileViewer.getLevel(Utils.getElementOrDefault(leveling, "catacombs", new JsonArray()).getAsJsonArray(), cataXp, 50, false ); levelObjClasses.put(skillName, levelObj); @@ -3616,7 +3617,7 @@ public class GuiProfileViewer extends GuiScreen { ProfileViewer.Level levelObjhotm = levelObjhotms.get(profileId); if (levelObjhotm == null) { float hotmXp = Utils.getElementAsFloat(Utils.getElement(profileInfo, "mining_core.experience"), 0); - levelObjhotm = ProfileViewer.getLevel(Utils.getElement(leveling, "HOTM").getAsJsonArray(), + levelObjhotm = ProfileViewer.getLevel(Utils.getElementOrDefault(leveling, "HOTM", new JsonArray()).getAsJsonArray(), hotmXp, 7, false ); levelObjhotms.put(profileId, levelObjhotm); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java index 9da55d64..d8e47fa3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -862,8 +862,10 @@ public class ProfileViewer { if (profileId == null) profileId = latestProfile; if (skillInfoMap.containsKey(profileId)) return skillInfoMap.get(profileId); JsonObject leveling = Constants.LEVELING; - if (leveling == null) return null; - + if (leveling == null || !leveling.has("social")) { + Utils.showOutdatedRepoNotification(); + return null; + } float experience_skill_taming = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_taming"), 0); float experience_skill_mining = @@ -952,7 +954,9 @@ public class ProfileViewer { Level level_skill_runecrafting = getLevel(Utils.getElement(leveling, "runecrafting_xp").getAsJsonArray(), experience_skill_runecrafting, getCap(leveling, "runecrafting"), false ); - Level level_skill_social = getLevel(Utils.getElement(leveling, "social").getAsJsonArray(), + Level level_skill_social = getLevel(Utils + .getElementOrDefault(leveling, "social", new JsonArray()) + .getAsJsonArray(), experience_skill_social, getCap(leveling, "social"), false ); Level level_skill_catacombs = getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(), diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishingPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishingPage.java index ece6f275..668cb8f2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishingPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishingPage.java @@ -378,6 +378,7 @@ public class TrophyFishingPage { } JsonObject trophyObject = trophyFishInformation.get("trophy_fish").getAsJsonObject(); Map>> trophyFishRarityIntegerMap = new HashMap<>(); + totalCount = 0; for (Map.Entry stringJsonElementEntry : trophyObject.entrySet()) { String key = stringJsonElementEntry.getKey(); if (key.equalsIgnoreCase("rewards") || key.equalsIgnoreCase("total_caught")) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java b/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java index c64fdb56..d373ef2c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/NotificationHandler.java @@ -49,6 +49,13 @@ public class NotificationHandler { showNotificationOverInv = overInventory; } + /** + * Stops rendering the notification, if one is displayed + */ + public static void cancelNotification() { + notificationDisplayMillis = 0; + } + public static void renderNotification() { long timeRemaining = 15000 - (System.currentTimeMillis() - notificationDisplayMillis); boolean display = timeRemaining > 0 || notificationDisplayMillis == -420; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index b6447706..ce0ecc4a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -1391,6 +1391,11 @@ public class Utils { } } + public static JsonElement getElementOrDefault(JsonElement element, String path, JsonElement def) { + JsonElement result = getElement(element, path); + return result != null ? result : def; + } + public static ChatStyle createClickStyle(ClickEvent.Action action, String value) { ChatStyle style = new ChatStyle(); style.setChatClickEvent(new ClickEvent(action, value)); @@ -1927,4 +1932,19 @@ public class Utils { } return stringBuilder.toString(); } + + public static void showOutdatedRepoNotification() { + NotificationHandler.displayNotification(Lists.newArrayList( + EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "Missing repo data", + EnumChatFormatting.RED + "Data used for many NEU features is not up to date, this should normally not be the case.", + EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + + EnumChatFormatting.RED + " to see if that fixes the issue.", + EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + + "discord.gg/moulberry" + + EnumChatFormatting.RESET + EnumChatFormatting.RED + " and message in " + EnumChatFormatting.BOLD + + "#neu-support" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " to get support" + ), + true, true + ); + } } -- cgit