aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAaron <51387595+AzureAaron@users.noreply.github.com>2023-06-17 21:58:01 -0400
committerAaron <51387595+AzureAaron@users.noreply.github.com>2023-06-18 13:12:06 -0400
commit1f15c252969c6c09de7b4b11110b12eccf5e90da (patch)
tree35da0ad6f1938bef9284a399830dd91334b4df40 /src/main/java
parentcafe56cd21b5ebc3cd17b52ee86a81ec469795a5 (diff)
downloadSkyblocker-1f15c252969c6c09de7b4b11110b12eccf5e90da.tar.gz
Skyblocker-1f15c252969c6c09de7b4b11110b12eccf5e90da.tar.bz2
Skyblocker-1f15c252969c6c09de7b4b11110b12eccf5e90da.zip
Improve Crimson Isle Tab HUD
Fixed the reputation widget showing "Max -> Reputation" when you're at max reputation The faction quests text now retains its formatting to be more informative about whether you've not started, started or completed a quest
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/util/PlayerListMgr.java37
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/QuestWidget.java14
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/ReputationWidget.java3
3 files changed, 52 insertions, 2 deletions
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 60915bc1..f797e6d0 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
@@ -4,6 +4,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -13,6 +14,7 @@ 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.MutableText;
import net.minecraft.text.Text;
/**
@@ -93,6 +95,41 @@ public class PlayerListMgr {
}
return str;
}
+
+ /**
+ * Gets the display name at some index of the player list
+ *
+ * @return the text or null, if the display name is null
+ *
+ * @implNote currently designed specifically for crimson isles faction quests widget, might not work correctly without modification
+ * for other stuff. you've been warned!
+ */
+ public static Text textAt4FactionQuests(int idx) {
+
+ if(playerList == null) {
+ return null;
+ }
+
+ if(playerList.size() <= idx) {
+ return null;
+ }
+
+ Text txt = playerList.get(idx).getDisplayName();
+ if(txt == null) {
+ return null;
+ }
+
+ //Rebuild the text object to remove beginning space thats in all faction quest stuff
+ MutableText newTxt = Text.empty();
+
+ for(int i = 0; i < txt.getSiblings().size(); i++) {
+ Text current = txt.getSiblings().get(i);
+ String textToAppend = current.getString();
+ newTxt.append(Text.literal((i == 0) ? StringUtils.removeStart(textToAppend, " ") : textToAppend ).setStyle(current.getStyle()));
+ }
+
+ return newTxt;
+ }
/**
* Get the display name at some index of the player list as Text as seen in the
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/QuestWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/QuestWidget.java
index 5c89964e..d13513e4 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/QuestWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/QuestWidget.java
@@ -1,6 +1,7 @@
package me.xmrvizzy.skyblocker.skyblock.tabhud.widget;
import me.xmrvizzy.skyblocker.skyblock.tabhud.util.Ico;
+import me.xmrvizzy.skyblocker.skyblock.tabhud.util.PlayerListMgr;
import me.xmrvizzy.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent;
import net.minecraft.text.MutableText;
@@ -13,12 +14,23 @@ public class QuestWidget extends Widget {
private static final MutableText TITLE = Text.literal("Faction Quests").formatted(Formatting.AQUA,
Formatting.BOLD);
+
+ /**
+ * @return the entry at idx with it's formatting preserved
+ */
+ public static Text passthroughEntryText(int idx) {
+ Text txt = PlayerListMgr.textAt4FactionQuests(idx);
+ if(txt == null) {
+ return null;
+ }
+ return txt;
+ }
public QuestWidget() {
super(TITLE, Formatting.AQUA.getColorValue());
for (int i = 51; i < 56; i++) {
- Text q = Widget.plainEntryText(i);
+ Text q = passthroughEntryText(i);
IcoTextComponent itc = new IcoTextComponent(Ico.BOOK, q);
this.addComponent(itc);
}
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/ReputationWidget.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/ReputationWidget.java
index c0379623..3685e0ca 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/ReputationWidget.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/tabhud/widget/ReputationWidget.java
@@ -54,8 +54,9 @@ public class ReputationWidget extends Widget {
this.addComponent(new ProgressComponent());
} else {
float pcnt = Float.parseFloat(prog.group("prog"));
+ Text reputationText = state.group("from").equals("Max") ? Text.literal("Max Reputation") : Text.literal(state.group("from") + " -> " + state.group("to"));
ProgressComponent pc = new ProgressComponent(Ico.LANTERN,
- Text.of(state.group("from") + " -> " + state.group("to")), rep, pcnt,
+ reputationText, rep, pcnt,
Formatting.AQUA.getColorValue());
this.addComponent(pc);
}