aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/IslandOwnersWidget.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/IslandOwnersWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/IslandOwnersWidget.java
index 1c640ed1..8550b27d 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/IslandOwnersWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/IslandOwnersWidget.java
@@ -18,23 +18,35 @@ public class IslandOwnersWidget extends Widget {
Formatting.BOLD);
// matches an owner
- // group 1: player name (cut off by hypixel for some reason)
- // group 2: last seem
- // TODO: test with owner online
- private static final Pattern OWNER_PATTERN = Pattern.compile("(?<name>.*) \\((?<lastseen>.*)\\)");
+ // group 1: player name
+ // group 2: last seen, if owner not online
+ private static final Pattern OWNER_PATTERN = Pattern
+ .compile("^(?<nameA>.*) \\((?<lastseen>.*)?\\)$|^\\[\\d*\\] (?<nameB>.*)$");
public IslandOwnersWidget() {
super(TITLE, Formatting.DARK_PURPLE.getColorValue());
for (int i = 1; i < 20; i++) {
- Matcher m = PlayerListMgr.regexAt( i, OWNER_PATTERN);
+ Matcher m = PlayerListMgr.regexAt(i, OWNER_PATTERN);
if (m == null) {
break;
}
- Text entry = Text.literal(m.group("name"))
+ String name = null, lastseen = null;
+ Formatting format = null;
+ if (m.group("nameA") != null) {
+ name = m.group("nameA");
+ lastseen = m.group("lastseen");
+ format = Formatting.GRAY;
+ } else {
+ name = m.group("nameB");
+ lastseen = "Online";
+ format = Formatting.WHITE;
+ }
+
+ Text entry = Text.literal(name)
.append(
- Text.literal(" (" + m.group("lastseen") + ")")
- .formatted(Formatting.GRAY));
+ Text.literal(" (" + lastseen + ")")
+ .formatted(format));
PlainTextComponent ptc = new PlainTextComponent(entry);
this.addComponent(ptc);
}