diff options
author | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2023-11-17 17:59:25 -0500 |
---|---|---|
committer | Aaron <51387595+AzureAaron@users.noreply.github.com> | 2023-11-20 00:52:05 -0500 |
commit | 57034bc96510cc190130d1f5aef67ad4da7c1fed (patch) | |
tree | 21ee278c6ba6244fead13e3d5c04b8dd52aa2759 /src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget | |
parent | a144b3272e327dbb73ee515537c5147fc940be05 (diff) | |
download | Skyblocker-57034bc96510cc190130d1f5aef67ad4da7c1fed.tar.gz Skyblocker-57034bc96510cc190130d1f5aef67ad4da7c1fed.tar.bz2 Skyblocker-57034bc96510cc190130d1f5aef67ad4da7c1fed.zip |
Fix Garden Tab Hud
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget')
5 files changed, 81 insertions, 37 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComposterWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComposterWidget.java index fbeb5ae5..f50b617b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComposterWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/ComposterWidget.java @@ -2,7 +2,7 @@ package de.hysky.skyblocker.skyblock.tabhud.widget; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; - +import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -20,11 +20,11 @@ public class ComposterWidget extends Widget { @Override public void updateContent() { - this.addSimpleIcoText(Ico.SAPLING, "Organic Matter:", Formatting.YELLOW, 48); - this.addSimpleIcoText(Ico.FURNACE, "Fuel:", Formatting.BLUE, 49); - this.addSimpleIcoText(Ico.CLOCK, "Time Left:", Formatting.RED, 50); - this.addSimpleIcoText(Ico.COMPOSTER, "Stored Compost:", Formatting.DARK_GREEN, 51); + int offset = (PlayerListMgr.strAt(46) != null) ? 1 : 0; + this.addSimpleIcoText(Ico.SAPLING, "Organic Matter:", Formatting.YELLOW, 48 + offset); + this.addSimpleIcoText(Ico.FURNACE, "Fuel:", Formatting.BLUE, 49 + offset); + this.addSimpleIcoText(Ico.CLOCK, "Time Left:", Formatting.RED, 50 + offset); + this.addSimpleIcoText(Ico.COMPOSTER, "Stored Compost:", Formatting.DARK_GREEN, 51 + offset); } - } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenServerWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenServerWidget.java index 221f8b08..b6b65896 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenServerWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenServerWidget.java @@ -6,7 +6,7 @@ import java.util.regex.Pattern; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; import de.hysky.skyblocker.skyblock.tabhud.widget.component.IcoTextComponent; - +import de.hysky.skyblocker.utils.Constants; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -14,13 +14,14 @@ import net.minecraft.util.Formatting; // this widget shows info about the garden server public class GardenServerWidget extends Widget { - private static final MutableText TITLE = Text.literal("Server Info").formatted(Formatting.DARK_AQUA, Formatting.BOLD); + //From the armor trim tooltip + private static final int COPPER_COLOR = 11823181; // match the next visitor in the garden // group 1: visitor name - private static final Pattern VISITOR_PATTERN = Pattern.compile("Next Visitor: (?<vis>.*)"); + private static final Pattern VISITOR_PATTERN = Pattern.compile("Visitors: (?<vis>.*)"); public GardenServerWidget() { super(TITLE, Formatting.DARK_AQUA.getColorValue()); @@ -31,17 +32,29 @@ public class GardenServerWidget extends Widget { this.addSimpleIcoText(Ico.MAP, "Area:", Formatting.DARK_AQUA, 41); this.addSimpleIcoText(Ico.NTAG, "Server ID:", Formatting.GRAY, 42); this.addSimpleIcoText(Ico.EMERALD, "Gems:", Formatting.GREEN, 43); - this.addSimpleIcoText(Ico.COPPER, "Copper:", Formatting.GOLD, 44); - Matcher m = PlayerListMgr.regexAt(45, VISITOR_PATTERN); + Text copperText = Widget.simpleEntryText(44, "Copper:", Formatting.WHITE); + ((MutableText) copperText.getSiblings().get(0)).styled(Constants.WITH_COLOR.apply(COPPER_COLOR)); + + this.addComponent(new IcoTextComponent(Ico.COPPER, copperText)); + + boolean hasPesthunterBonus = PlayerListMgr.strAt(46) != null; + + if (hasPesthunterBonus) { + this.addComponent(new IcoTextComponent(Ico.NETHERITE_UPGRADE_ST, PlayerListMgr.textAt(46))); + } + + int offset = hasPesthunterBonus ? 1 : 0; + + Matcher m = PlayerListMgr.regexAt(53 + offset, VISITOR_PATTERN); if (m == null ) { this.addComponent(new IcoTextComponent()); return; } - String vis = m.group("vis"); + String vis = m.group("vis").replaceAll("[()]*", ""); Formatting col; - if (vis.equals("Not Unlocked!")) { + if (vis.equals("Not Unlocked!") || vis.equals("Queue Full!")) { col = Formatting.RED; } else { col = Formatting.GREEN; diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenSkillsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenSkillsWidget.java index 41eee8d6..75652b33 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenSkillsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenSkillsWidget.java @@ -26,6 +26,8 @@ public class GardenSkillsWidget extends Widget { private static final Pattern SKILL_PATTERN = Pattern .compile("Skills: (?<skill>[A-Za-z]* [0-9]*): (?<progress>[0-9.MAX]*)%?"); + private static final Pattern GARDEN_LEVEL_PATTERN = Pattern.compile("Garden Level: (?<level>[IVX0-9]+)(?: \\((?<progress>[0-9.]+)% to [IVX0-9]+\\))?"); + // same, more or less private static final Pattern MS_PATTERN = Pattern .compile("Milestone: (?<milestone>[A-Za-z ]* [0-9]*): (?<progress>[0-9.]*)%"); @@ -36,26 +38,46 @@ public class GardenSkillsWidget extends Widget { @Override public void updateContent() { - ProgressComponent pc; - Matcher m = PlayerListMgr.regexAt(66, SKILL_PATTERN); - if (m == null) { - pc = new ProgressComponent(); + ProgressComponent spc; + Matcher skillMatcher = PlayerListMgr.regexAt(66, SKILL_PATTERN); + if (skillMatcher == null) { + spc = new ProgressComponent(); } else { - String strpcnt = m.group("progress"); - String skill = m.group("skill"); + String strpcnt = skillMatcher.group("progress"); + String skill = skillMatcher.group("skill"); if (strpcnt.equals("MAX")) { - pc = new ProgressComponent(Ico.LANTERN, Text.of(skill), Text.of("MAX"), 100f, + spc = new ProgressComponent(Ico.LANTERN, Text.of(skill), Text.of("MAX"), 100f, Formatting.RED.getColorValue()); } else { float pcnt = Float.parseFloat(strpcnt); - pc = new ProgressComponent(Ico.LANTERN, Text.of(skill), pcnt, + spc = new ProgressComponent(Ico.LANTERN, Text.of(skill), pcnt, Formatting.GOLD.getColorValue()); } } - this.addComponent(pc); + this.addComponent(spc); + + ProgressComponent glpc; + Matcher glMatcher = PlayerListMgr.regexAt(45, GARDEN_LEVEL_PATTERN); + + if (glMatcher == null) { + glpc = new ProgressComponent(); + } else { + String level = glMatcher.group("level"); + + if (level.equals("15") || level.equals("XV")) { + glpc = new ProgressComponent(Ico.SEEDS, Text.literal("Garden Level " + level), 100f, Formatting.RED.getColorValue()); + } else { + String strpcnt = glMatcher.group("progress"); + float pcnt = Float.parseFloat(strpcnt); + + glpc = new ProgressComponent(Ico.SEEDS, Text.literal("Garden Level " + level), pcnt, Formatting.DARK_GREEN.getColorValue()); + } + } + + this.addComponent(glpc); Text speed = Widget.simpleEntryText(67, "SPD", Formatting.WHITE); IcoTextComponent spd = new IcoTextComponent(Ico.SUGAR, speed); @@ -66,22 +88,21 @@ public class GardenSkillsWidget extends Widget { tc.addToCell(0, 0, spd); tc.addToCell(1, 0, ffo); this.addComponent(tc); + + this.addComponent(new IcoTextComponent(Ico.HOE, PlayerListMgr.textAt(70))); ProgressComponent pc2; - m = PlayerListMgr.regexAt(69, MS_PATTERN); - if (m == null) { + Matcher milestoneMatcher = PlayerListMgr.regexAt(69, MS_PATTERN); + if (milestoneMatcher == null) { pc2 = new ProgressComponent(); } else { - String strpcnt = m.group("progress"); - String milestone = m.group("milestone"); + String strpcnt = milestoneMatcher.group("progress"); + String milestone = milestoneMatcher.group("milestone"); float pcnt = Float.parseFloat(strpcnt); pc2 = new ProgressComponent(Ico.MILESTONE, Text.of(milestone), pcnt, Formatting.GREEN.getColorValue()); - } this.addComponent(pc2); - } - } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenVisitorsWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenVisitorsWidget.java index cfbd6cd0..2b0036ad 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenVisitorsWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/GardenVisitorsWidget.java @@ -15,16 +15,17 @@ public class GardenVisitorsWidget extends Widget { @Override public void updateContent() { - if (PlayerListMgr.textAt(54) == null) { + int offset = (PlayerListMgr.strAt(46) != null) ? 1 : 0; + + if (PlayerListMgr.textAt(54 + offset) == null) { this.addComponent(new PlainTextComponent(Text.literal("No visitors!").formatted(Formatting.GRAY))); return; } - for (int i = 54; i < 59; i++) { + for (int i = 54 + offset; i < 59 + offset; i++) { String text = PlayerListMgr.strAt(i); if (text != null) this.addComponent(new PlainTextComponent(Text.literal(text))); } - } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/JacobsContestWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/JacobsContestWidget.java index 5ae0bd3d..39f0ba73 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/JacobsContestWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/JacobsContestWidget.java @@ -1,6 +1,8 @@ package de.hysky.skyblocker.skyblock.tabhud.widget; import java.util.HashMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import de.hysky.skyblocker.skyblock.tabhud.util.Ico; import de.hysky.skyblocker.skyblock.tabhud.util.PlayerListMgr; @@ -19,6 +21,8 @@ public class JacobsContestWidget extends Widget { private static final MutableText TITLE = Text.literal("Jacob's Contest").formatted(Formatting.YELLOW, Formatting.BOLD); + private static final Pattern CROP_PATTERN = Pattern.compile("(?:☘|○) (?<crop>[A-Za-z ]+)"); + private static final HashMap<String, ItemStack> FARM_DATA = new HashMap<>(); // again, there HAS to be a better way to do this @@ -41,22 +45,27 @@ public class JacobsContestWidget extends Widget { @Override public void updateContent() { - this.addSimpleIcoText(Ico.CLOCK, "Starts in:", Formatting.GOLD, 76); + Text jacobStatus = PlayerListMgr.textAt(76); + + if (jacobStatus.getString().equals("ACTIVE")) { + this.addComponent(new IcoTextComponent(Ico.CLOCK, jacobStatus)); + } else { + this.addSimpleIcoText(Ico.CLOCK, "Starts in:", Formatting.GOLD, 76); + } TableComponent tc = new TableComponent(1, 3, Formatting.YELLOW .getColorValue()); for (int i = 77; i < 80; i++) { - String item = PlayerListMgr.strAt(i); + Matcher item = PlayerListMgr.regexAt(i, CROP_PATTERN); IcoTextComponent itc; if (item == null) { itc = new IcoTextComponent(); } else { - itc = new IcoTextComponent(FARM_DATA.get(item), Text.of(item)); + String cropName = item.group("crop"); + itc = new IcoTextComponent(FARM_DATA.get(cropName), Text.of(cropName)); } tc.addToCell(0, i - 77, itc); } this.addComponent(tc); - } - } |