diff options
| author | NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> | 2024-07-15 05:08:46 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-14 21:08:46 +0200 |
| commit | e222ef31708a0bef2bfb645255cf41d462b3da11 (patch) | |
| tree | 50b9368714508e24b2de452ea02049772844828b | |
| parent | 017512e3224dacba0d0c433b4966b52d239e1261 (diff) | |
| download | notenoughupdates-e222ef31708a0bef2bfb645255cf41d462b3da11.tar.gz notenoughupdates-e222ef31708a0bef2bfb645255cf41d462b3da11.tar.bz2 notenoughupdates-e222ef31708a0bef2bfb645255cf41d462b3da11.zip | |
Fix cookie with months or less than a hour (#1244)
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java | 14 |
1 files changed, 12 insertions, 2 deletions
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 50259538..6de6b365 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java @@ -79,8 +79,11 @@ public class CookieWarning { } private static long getMillisecondsRemaining(String timeLine) { + if ("Less than an hour".equals(timeLine)) { + return 10 * 60 * 1000; //Return 10 minutes, they need more cookie! + } String clean = timeLine.replaceAll("(ยง.)", ""); - clean = clean.replaceAll("(\\d)([smhdy])", "$1 $2"); + clean = clean.replaceAll("(\\d)([smhdMy])", "$1 $2"); String[] digits = clean.split(" "); long ms = 0; try { @@ -92,7 +95,7 @@ public class CookieWarning { long val = Integer.parseInt(number); ms += (getEffectRemainingInMilliseconds(unit, val)); } - } catch (NumberFormatException e) { + } catch (Exception e) { if (!hasErrorMessage) { e.printStackTrace(); Utils.addChatMessage(EnumChatFormatting.RED + @@ -165,6 +168,13 @@ public class CookieWarning { } public static long getEffectRemainingInMilliseconds(String remainingTimeType, long remainingTime) { + switch (remainingTimeType.replace(",", "")) { + case "months": + case "month": + case "mo": + case "M": + return remainingTime * 24 * 60 * 60 * 1000 * 30; + } switch (remainingTimeType.toLowerCase(Locale.ROOT).replace(",", "")) { case "years": case "year": |
