aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com>2022-11-26 07:57:35 +1100
committerGitHub <noreply@github.com>2022-11-25 21:57:35 +0100
commit7db5251c1cf9558b6d310b39a596d94850738c82 (patch)
tree159931bb08a60a041f588da11ea3ee4f92bb0633
parent72904df8c50260e76a784457a5e78a20e4a80b65 (diff)
downloadNotEnoughUpdates-7db5251c1cf9558b6d310b39a596d94850738c82.tar.gz
NotEnoughUpdates-7db5251c1cf9558b6d310b39a596d94850738c82.tar.bz2
NotEnoughUpdates-7db5251c1cf9558b6d310b39a596d94850738c82.zip
Fix todo overlay (#432)
Co-authored-by: nopo <nopotheemail@gmail.com> Co-authored-by: heyngra <heyngra.wspolpraca@gmail.com> Co-authored-by: jani270 <jani270@gmx.de> Co-authored-by: Taoshi <nicolaikh@live.dk> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
-rw-r--r--Update Notes/2.1.1.md27
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java44
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java142
3 files changed, 128 insertions, 85 deletions
diff --git a/Update Notes/2.1.1.md b/Update Notes/2.1.1.md
index efd067bd..972ef942 100644
--- a/Update Notes/2.1.1.md
+++ b/Update Notes/2.1.1.md
@@ -10,11 +10,7 @@
### **Minor Changes:**
- - Fixed /join command not working for uppercase floors - walker or whalker
- Removed custom option toggle textures in /neu - nopo
- - Fixed Pickaxe Cooldown not being correct on first join - Ascynx
- - Fixed social exp not being correct in /pv - Vixid
- - Fixed a crash when downgrading from future NEU versions - nopo
- Unified writing conventions for "SkyBlock" and similar - walker or whalker
- Added fishing helper to fishing in the main lobby - sharkey300
- Allowed custom delays until skill overlays pause - Cobble8
@@ -28,14 +24,10 @@
- Added class average to dungeons page in /pv - Vixid
- Added recipe history - Vixid
- Added fairy soul waypoint distance - Vixid
- - Fixed buggy cape on player model in /pv - Vixid
- Added abiphone favourites - hannibal2
- Added Abiphone contact requirements and location - hannibal2
- - Fixed rare crash in AH/BZ Graph - DeDiamondPro
- Added the extra MP that abicases give to pv - nopo
- - Fixed presets not having load button when from discord - nopo
- Added support for commas in calculator - nopo
- - Fixed picknumbus not working for ability cooldown - nopo
- Added essence to pv - efefury
- Added Croesus profit overlay - efefury/Lulonaut
- Replaced NEU nw with soopy nw in pv - Soopyboo32
@@ -46,10 +38,23 @@
- Added Powder Grinding Tracker - KingsMMA
- Added AND (& ) | OR (|) to container searchbar - Ascynx
- Added Ctrl + Z / Ctrl + Y / Ctrl + Shift + Z support to searchbar - Ascynx
- - Fixed dungeon page being blank sometimes - nopo
- - Fixed pickaxe cooldown not working on first world join - Ascynx
- Added searchbar to Kills/Deaths section in pv - Cobble8
- Added Ender Node Highlighter, Endermite Nest Alert - GodOfPro
- Added CTRL + F support to searchbar and config menu - Lulonaut
- - Fixed Slayer Overlay to now take Aatrox's +25% Slayer XP buff into account - Taoshi
- Added star cult timer to dwarven mines overlay - efefury
+
+### **Bug Fixes:**
+
+- Fixed dungeon page being blank sometimes - nopo
+- Fixed pickaxe cooldown not working on first world join - Ascynx
+- Fixed picknumbus not working for ability cooldown - nopo
+- Fixed rare crash in AH/BZ Graph - DeDiamondPro
+- Fixed /join command not working for uppercase floors - walker or whalker
+- Fixed Pickaxe Cooldown not being correct on first join - Ascynx
+- Fixed social exp not being correct in /pv - Vixid
+- Fixed a crash when downgrading from future NEU versions - nopo
+- Fixed buggy cape on player model in /pv - Vixid
+- Fixed presets not having load button when from discord - nopo
+- Fixed todo overlay with cookie - nopo
+- Fixed todo overlay with god pot - heyngra
+- Fixed Slayer Overlay to now take Aatrox's +25% Slayer XP buff into account - Taoshi
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 fede9bdf..ab8c5e57 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CookieWarning.java
@@ -74,22 +74,38 @@ public class CookieWarning {
return;
}
if (timeLine != null) {
- String[] digits = timeLine.split(" ");
+ String[] digits = timeLine.replaceAll("(\u00a7.)", "").split(" ");
int minutes = 0;
try {
- for (String digit : digits) {
- if (digit.endsWith("y")) {
- digit = digit.substring(0, digit.length() - 1);
- minutes += Integer.parseInt(digit) * 525600;
- } else if (digit.endsWith("d")) {
- digit = digit.substring(0, digit.length() - 1);
- minutes += Integer.parseInt(digit) * 1440;
- } else if (digit.endsWith("h")) {
- digit = digit.substring(0, digit.length() - 1);
- minutes += Integer.parseInt(digit) * 60;
- } else if (digit.endsWith("m")) {
- digit = digit.substring(0, digit.length() - 1);
- minutes += Integer.parseInt(digit);
+ for (int i = 0; i < digits.length; i++) {
+ if (i % 2 == 1) continue;
+
+ String number = digits[i];
+ String unit = digits[i + 1];
+ long val = Integer.parseInt(number);
+ switch (unit) {
+ case "Years":
+ case "Year":
+ minutes += val * 525600;
+ break;
+ case "Months":
+ case "Month":
+ minutes += val * 43200;
+ break;
+ case "Days":
+ case "Day":
+ minutes += val * 1440;
+ break;
+ case "Hours":
+ case "Hour":
+ case "h":
+ minutes += val * 60;
+ break;
+ case "Minutes":
+ case "Minute":
+ case "m":
+ minutes += val;
+ break;
} // ignore seconds
}
} catch (NumberFormatException e) {
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 730cb17f..a276f207 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java
@@ -53,7 +53,7 @@ import static net.minecraft.util.EnumChatFormatting.DARK_AQUA;
public class TimersOverlay extends TextTabOverlay {
private static final Pattern PATTERN_ACTIVE_EFFECTS = Pattern.compile(
- "\u00a7r\u00a7r\u00a77You have a \u00a7r\u00a7cGod Potion \u00a7r\u00a77active! \u00a7r\u00a7d([0-9]*?:?[0-9]*?:?[0-9]*)\u00a7r");
+ "\u00a7r\u00a7r\u00a77You have a \u00a7r\u00a7cGod Potion \u00a7r\u00a77active! \u00a7r\u00a7d([1-5][0-9]|[0-9])[\\s|^\\S]?(Seconds|Second|Minutes|Minute|Hours|Hour|Day|Days|h|m|s) ?([1-5][0-9]|[0-9])?(m|s)?\u00a7r");
public TimersOverlay(
Position position,
@@ -231,6 +231,8 @@ public class TimersOverlay extends TextTabOverlay {
super.renderLine(line, position, dummy);
}
+ boolean hasErrorMessage = false;
+
@Override
public void update() {
@@ -307,28 +309,44 @@ public class TimersOverlay extends TextTabOverlay {
Matcher activeEffectsMatcher = PATTERN_ACTIVE_EFFECTS.matcher(line);
if (activeEffectsMatcher.matches()) {
foundGodPotText = true;
- String[] godpotRemaingTimeUnformatted = activeEffectsMatcher.group(1).split(":");
long godPotDuration = 0;
try {
- int i = 0;
- if (godpotRemaingTimeUnformatted.length == 4) {
- godPotDuration =
- godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 24 * 60 * 60 * 1000;
- i++;
- }
- if (godpotRemaingTimeUnformatted.length >= 3) {
- godPotDuration =
- godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 60 * 60 * 1000;
- i++;
- }
- if (godpotRemaingTimeUnformatted.length >= 2) {
- godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 60 * 1000;
- i++;
+ long godpotRemainingTime;
+ for (int i = 1; i < activeEffectsMatcher.groupCount(); i += 2) {
+ if (activeEffectsMatcher.group(i) == null) {
+ continue;
+ }
+ godpotRemainingTime = Integer.parseInt(activeEffectsMatcher.group(i));
+ String godpotRemainingTimeType = activeEffectsMatcher.group(i + 1);
+ switch (godpotRemainingTimeType) {
+ case "Days":
+ case "Day":
+ godPotDuration += godpotRemainingTime * 24 * 60 * 60 * 1000;
+ break;
+ case "Hours":
+ case "Hour":
+ case "h":
+ godPotDuration += godpotRemainingTime * 60 * 60 * 1000;
+ break;
+ case "Minutes":
+ case "Minute":
+ case "m":
+ godPotDuration += godpotRemainingTime * 60 * 1000;
+ break;
+ case "Seconds":
+ case "Second":
+ case "s":
+ godPotDuration += godpotRemainingTime * 1000;
+ break;
+ }
}
- if (godpotRemaingTimeUnformatted.length >= 1) {
- godPotDuration = godPotDuration + (long) Integer.parseInt(godpotRemaingTimeUnformatted[i]) * 1000;
+ } catch (Exception e) {
+ e.printStackTrace();
+ if (!hasErrorMessage) {
+ Utils.addChatMessage(EnumChatFormatting.YELLOW + "[NEU] Unable to work out your god pot timer");
+ hasErrorMessage = true;
}
- } catch (Exception ignored) {
+ break;
}
hidden.godPotionDuration = godPotDuration;
@@ -336,50 +354,54 @@ public class TimersOverlay extends TextTabOverlay {
} else if (line.contains("\u00a7d\u00a7lCookie Buff")) {
foundCookieBuffText = true;
} else if (foundCookieBuffText) {
- String cleanNoSpace = line.replaceAll("(\u00a7.| )", "");
-
+ String clean = line.replaceAll("(\u00a7.)", "");
+ String[] cleanSplit = clean.split(" ");
hidden.cookieBuffRemaining = 0;
- StringBuilder number = new StringBuilder();
- for (int i = 0; i < cleanNoSpace.length(); i++) {
- char c = cleanNoSpace.charAt(i);
-
- if (c >= '0' && c <= '9') {
- number.append(c);
- } else {
- if (number.length() == 0) {
- hidden.cookieBuffRemaining = 0;
- break;
- }
- if ("ydhms".contains("" + c)) {
- try {
- long val = Integer.parseInt(number.toString());
- switch (c) {
- case 'y':
- hidden.cookieBuffRemaining += val * 365 * 24 * 60 * 60 * 1000;
- break;
- case 'd':
- hidden.cookieBuffRemaining += val * 24 * 60 * 60 * 1000;
- break;
- case 'h':
- hidden.cookieBuffRemaining += val * 60 * 60 * 1000;
- break;
- case 'm':
- hidden.cookieBuffRemaining += val * 60 * 1000;
- break;
- case 's':
- hidden.cookieBuffRemaining += val * 1000;
- break;
- }
- } catch (NumberFormatException e) {
- hidden.cookieBuffRemaining = 0;
- break;
- }
- number = new StringBuilder();
- } else {
- hidden.cookieBuffRemaining = 0;
- break;
+ for (int i = 0; i < cleanSplit.length; i++) {
+ if (i % 2 == 1) continue;
+
+ String number = cleanSplit[i];
+ String unit = cleanSplit[i + 1];
+ try {
+ long val = Integer.parseInt(number);
+ switch (unit) {
+ case "Years":
+ case "Year":
+ hidden.cookieBuffRemaining += val * 365 * 24 * 60 * 60 * 1000;
+ break;
+ case "Months":
+ case "Month":
+ hidden.cookieBuffRemaining += val * 30 * 24 * 60 * 60 * 1000;
+ break;
+ case "Days":
+ case "Day":
+ hidden.cookieBuffRemaining += val * 24 * 60 * 60 * 1000;
+ break;
+ case "Hours":
+ case "Hour":
+ case "h":
+ hidden.cookieBuffRemaining += val * 60 * 60 * 1000;
+ break;
+ case "Minutes":
+ case "Minute":
+ case "m":
+ hidden.cookieBuffRemaining += val * 60 * 1000;
+ break;
+ case "Seconds":
+ case "Second":
+ case "s":
+ hidden.cookieBuffRemaining += val * 1000;
+ break;
+ }
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ hidden.cookieBuffRemaining = 0;
+ if (!hasErrorMessage) {
+ Utils.addChatMessage(EnumChatFormatting.YELLOW + "[NEU] Unable to work out your cookie buff timer");
+ hasErrorMessage = true;
}
+ break;
}
}