From ac34faf4ad240448a8906ab4cc1acd0d4f0614ce Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sat, 31 Dec 2022 03:07:01 +0100 Subject: Probably fixing the cookie buff timer problem (#527) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Co-authored-by: nopo --- .../notenoughupdates/miscfeatures/CookieWarning.java | 14 ++++++++++---- .../moulberry/notenoughupdates/overlays/TimersOverlay.java | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/main/java') 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 ab8c5e57..80751371 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java @@ -30,6 +30,7 @@ import net.minecraft.util.EnumChatFormatting; public class CookieWarning { private static boolean hasNotified; + private static boolean hasErrorMessage; public static void resetNotification() { hasNotified = false; @@ -74,7 +75,9 @@ public class CookieWarning { return; } if (timeLine != null) { - String[] digits = timeLine.replaceAll("(\u00a7.)", "").split(" "); + String clean = timeLine.replaceAll("(\u00a7.)", ""); + clean = clean.replaceAll("(\\d)([smhdy])", "$1 $2"); + String[] digits = clean.split(" "); int minutes = 0; try { for (int i = 0; i < digits.length; i++) { @@ -109,9 +112,12 @@ public class CookieWarning { } // ignore seconds } } catch (NumberFormatException e) { - e.printStackTrace(); - Utils.addChatMessage(EnumChatFormatting.RED + - "NEU ran into an issue when retrieving the Booster Cookie Timer. Check the logs for details."); + if (!hasErrorMessage) { + e.printStackTrace(); + Utils.addChatMessage(EnumChatFormatting.RED + + "NEU ran into an issue when retrieving the Booster Cookie Timer. Check the logs for details."); + hasErrorMessage = true; + } hasNotified = true; } if (minutes < NotEnoughUpdates.INSTANCE.config.notifications.boosterCookieWarningMins && !hasNotified) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java index 74c64972..6e20c77d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -344,9 +344,9 @@ public class TimersOverlay extends TextTabOverlay { } } } catch (Exception e) { - e.printStackTrace(); if (!hasErrorMessage) { Utils.addChatMessage(EnumChatFormatting.YELLOW + "[NEU] Unable to work out your god pot timer"); + e.printStackTrace(); hasErrorMessage = true; } break; @@ -358,6 +358,7 @@ public class TimersOverlay extends TextTabOverlay { foundCookieBuffText = true; } else if (foundCookieBuffText) { String clean = line.replaceAll("(\u00a7.)", ""); + clean = clean.replaceAll("(\\d)([smhdy])", "$1 $2"); String[] cleanSplit = clean.split(" "); hidden.cookieBuffRemaining = 0; if (line.contains("Not")) break; -- cgit