aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java3
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java39
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java9
3 files changed, 37 insertions, 14 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java
index 120cabd8..ca767617 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/Ico.java
@@ -3,6 +3,9 @@ package me.xmrvizzy.skyblocker.skyblock.tabhud.util;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
+/**
+ * Stores convenient shorthands for common ItemStack definitions
+ */
public class Ico {
public static final ItemStack MAP = new ItemStack(Items.FILLED_MAP);
public static final ItemStack NTAG = new ItemStack(Items.NAME_TAG);
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java
index 6243415d..2cab4597 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java
@@ -8,12 +8,19 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import me.xmrvizzy.skyblocker.mixin.PlayerListHudAccessor;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.TabHud;
import me.xmrvizzy.skyblocker.utils.Utils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.text.Text;
+/**
+ * This class may be used to get data from the player list.
+ * It doesn't get its data every frame, instead, a scheduler is used to
+ * update the data this class is holding periodically.
+ * The list is sorted like in the vanilla game.
+ */
public class PlayerListMgr {
public static final Logger LOGGER = LoggerFactory.getLogger("Skyblocker Regex");
@@ -28,9 +35,8 @@ public class PlayerListMgr {
ClientPlayNetworkHandler cpnwh = MinecraftClient.getInstance().getNetworkHandler();
- // check is needed, else crash on server leave
+ // check is needed, else game crash on server leave
if (cpnwh != null) {
-
playerList = cpnwh.getPlayerList()
.stream()
.sorted(PlayerListHudAccessor.getOrdering())
@@ -38,9 +44,12 @@ public class PlayerListMgr {
}
}
- // apply pattern to entry at index of player list.
- // return null if there's nothing to match against in the entry,
- // or if the pattern doesn't fully match.
+ /**
+ * Get the display name at some index of the player list and apply a pattern to
+ * it
+ *
+ * @return the matcher if p fully matches, else null
+ */
public static Matcher regexAt(int idx, Pattern p) {
String str = PlayerListMgr.strAt(idx);
@@ -51,15 +60,19 @@ public class PlayerListMgr {
Matcher m = p.matcher(str);
if (!m.matches()) {
- LOGGER.debug("no match: \"{}\" against \"{}\"", str, p);
+ LOGGER.error("no match: \"{}\" against \"{}\"", str, p);
return null;
} else {
return m;
}
}
- // return string (i.e. displayName) at index of player list.
- // return null if string is null, empty or whitespace only.
+ /**
+ * Get the display name at some index of the player list as string
+ *
+ * @return the string or null, if the display name is null, empty or whitespace
+ * only
+ */
public static String strAt(int idx) {
if (playerList == null) {
@@ -81,8 +94,14 @@ public class PlayerListMgr {
return str;
}
- public static PlayerListEntry getRaw(int i) {
- return playerList.get(i);
+ /**
+ * Get the display name at some index of the player list as Text as seen in the
+ * game
+ *
+ * @return the PlayerListEntry at that index
+ */
+ public static PlayerListEntry getRaw(int idx) {
+ return playerList.get(idx);
}
public static int getSize() {
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java
index eb8210d9..49d080e2 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerLocator.java
@@ -2,6 +2,9 @@ package me.xmrvizzy.skyblocker.skyblock.tabhud.util;
import me.xmrvizzy.skyblocker.utils.Utils;
+/**
+ * Uses data from the player list to determine the area the player is in.
+ */
public class PlayerLocator {
public static enum Location {
@@ -30,10 +33,6 @@ public class PlayerLocator {
return Location.UNKNOWN;
}
- if (Utils.isInDungeons) {
- return Location.DUNGEON;
- }
-
String areaDesciptor = PlayerListMgr.strAt(41);
if (areaDesciptor == null || areaDesciptor.length() < 6) {
@@ -76,6 +75,8 @@ public class PlayerLocator {
return Location.JERRY;
case "Garden":
return Location.GARDEN;
+ case "Catacombs":
+ return Location.DUNGEON;
default:
return Location.UNKNOWN;
}