aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authormsg-programs <msgdoesstuff@gmail.com>2023-09-01 11:06:14 +0200
committermsg-programs <msgdoesstuff@gmail.com>2023-09-01 11:06:14 +0200
commit232b0b472a7e473d1fee6b8798d21fd1bb920260 (patch)
tree04dc866287ee477673f1e58bcaa5c4c62dca438a /src/main/java
parentd41a1fd81f5bac6e3617147389f6cbcd3434cfff (diff)
downloadSkyblocker-232b0b472a7e473d1fee6b8798d21fd1bb920260.tar.gz
Skyblocker-232b0b472a7e473d1fee6b8798d21fd1bb920260.tar.bz2
Skyblocker-232b0b472a7e473d1fee6b8798d21fd1bb920260.zip
Fix minion widget displaying wrong info when player has 11/12 minions
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/MinionWidget.java59
1 files changed, 37 insertions, 22 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/MinionWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/MinionWidget.java
index 039871b2..579828d4 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/MinionWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/MinionWidget.java
@@ -97,29 +97,13 @@ public class MinionWidget extends Widget {
@Override
public void updateContent() {
- for (int i = 48; i < 59; i++) {
- Matcher m = PlayerListMgr.regexAt(i, MINION_PATTERN);
- if (m != null) {
-
- String min = m.group("name");
- String lvl = m.group("level");
- String stat = m.group("status");
-
- MutableText mt = Text.literal(min + " " + lvl).append(Text.literal(": "));
- Formatting format = Formatting.RED;
- if (stat.equals("ACTIVE")) {
- format = Formatting.GREEN;
- } else if (stat.equals("SLOW")) {
- format = Formatting.YELLOW;
- }
- // makes "BLOCKED" also red. in reality, it's some kind of crimson
- mt.append(Text.literal(stat).formatted(format));
+ // this looks a bit weird because if we used regex mismatch as a stop condition,
+ // it'd spam the chat.
+ // not sure if not having that debug output is worth the cleaner solution here...
- IcoTextComponent itc = new IcoTextComponent(MIN_ICOS.get(min), mt);
- this.addComponent(itc);
-
- } else {
+ for (int i = 48; i < 59; i++) {
+ if (!this.addMinionComponent(i)) {
break;
}
}
@@ -128,8 +112,39 @@ public class MinionWidget extends Widget {
// a "And X more..." text is shown
// look for that and add it to the widget
String more = PlayerListMgr.strAt(59);
- if (more != null) {
+ if (more == null) {
+ return;
+ } else if (more.startsWith("And ")) {
this.addComponent(new PlainTextComponent(Text.of(more)));
+ } else {
+ this.addMinionComponent(59);
+ }
+ }
+
+ public boolean addMinionComponent(int i) {
+ Matcher m = PlayerListMgr.regexAt(i, MINION_PATTERN);
+ if (m != null) {
+
+ String min = m.group("name");
+ String lvl = m.group("level");
+ String stat = m.group("status");
+
+ MutableText mt = Text.literal(min + " " + lvl).append(Text.literal(": "));
+
+ Formatting format = Formatting.RED;
+ if (stat.equals("ACTIVE")) {
+ format = Formatting.GREEN;
+ } else if (stat.equals("SLOW")) {
+ format = Formatting.YELLOW;
+ }
+ // makes "BLOCKED" also red. in reality, it's some kind of crimson
+ mt.append(Text.literal(stat).formatted(format));
+
+ IcoTextComponent itc = new IcoTextComponent(MIN_ICOS.get(min), mt);
+ this.addComponent(itc);
+ return true;
+ } else {
+ return false;
}
}