diff options
Diffstat (limited to 'src')
4 files changed, 119 insertions, 0 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/util/Ico.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/util/Ico.java index 82394a78..96ab35d5 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/util/Ico.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/util/Ico.java @@ -60,4 +60,5 @@ public class Ico { public static final ItemStack EXPERIENCE_BOTTLE = new ItemStack(Items.EXPERIENCE_BOTTLE); public static final ItemStack PINK_DYE = new ItemStack(Items.PINK_DYE); public static final ItemStack ENCHANTED_BOOK = new ItemStack(Items.ENCHANTED_BOOK); + public static final ItemStack SPIDER_EYE = new ItemStack(Items.SPIDER_EYE); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/SpidersDenServerWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/SpidersDenServerWidget.java new file mode 100644 index 00000000..3c32f534 --- /dev/null +++ b/src/main/java/de/hysky/skyblocker/skyblock/tabhud/widget/SpidersDenServerWidget.java @@ -0,0 +1,84 @@ +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; + +import java.util.Arrays; + +/** + * This widget shows info about the Spider's Den server + */ +public class SpidersDenServerWidget extends Widget { + + private static final MutableText TITLE = + Text.literal("Server Info").formatted(Formatting.DARK_AQUA, Formatting.BOLD); + + /** + * Broodmother Mini-Boss tab states + */ + private enum BroodmotherState { + SOON("Soon", Formatting.GOLD), + AWAKENING("Awakening", Formatting.GOLD), + ALIVE("Alive!", Formatting.DARK_RED), + DORMANT("Dormant", Formatting.YELLOW), + UNKNOWN("Unknown", Formatting.GRAY); + + private final String text; + private final Formatting formatting; + + + BroodmotherState(String text, Formatting formatting) { + this.text = text; + this.formatting = formatting; + } + + public String text() { + return this.text; + } + + public Formatting formatting() { + return this.formatting; + } + + /** + * Returns a state object by text + * + * @param text text state from tab + * @return Broodmother State object + */ + public static BroodmotherState from(String text) { + return Arrays.stream(BroodmotherState.values()) + .filter(broodmotherState -> text.equals(broodmotherState.text())).findFirst().orElse(UNKNOWN); + } + } + + public SpidersDenServerWidget() { + super(TITLE, Formatting.DARK_AQUA.getColorValue()); + } + + /** + * Parses the Broodmother string from tab and returns a state object. + * + * @return Broodmother State object + */ + private static BroodmotherState parseTab() { + String state = PlayerListMgr.strAt(45); + if (state == null || !state.contains(": ")) return BroodmotherState.UNKNOWN; + + return BroodmotherState.from(state.split(": ")[1]); + } + + @Override + public void updateContent() { + 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); + + BroodmotherState broodmotherState = parseTab(); + this.addSimpleIcoText( + Ico.SPIDER_EYE, "Broodmother: ", broodmotherState.formatting(), broodmotherState.text()); + } +} diff --git a/src/main/resources/assets/skyblocker/tabhud/standard/spider_den.json b/src/main/resources/assets/skyblocker/tabhud/standard/spider_den.json new file mode 100644 index 00000000..faa437ac --- /dev/null +++ b/src/main/resources/assets/skyblocker/tabhud/standard/spider_den.json @@ -0,0 +1,17 @@ +{ + "widgets": [ + { + "name": "SpidersDenServerWidget", + "alias": "psw" + } + ], + "layout": [ + { + "op": "place", + "where": "center", + "apply_to": [ + "psw" + ] + } + ] +}
\ No newline at end of file diff --git a/src/main/resources/resourcepacks/top_aligned/assets/skyblocker/tabhud/standard/spider_den.json b/src/main/resources/resourcepacks/top_aligned/assets/skyblocker/tabhud/standard/spider_den.json new file mode 100644 index 00000000..0df51096 --- /dev/null +++ b/src/main/resources/resourcepacks/top_aligned/assets/skyblocker/tabhud/standard/spider_den.json @@ -0,0 +1,17 @@ +{ + "widgets": [ + { + "name": "SpidersDenServerWidget", + "alias": "psw" + } + ], + "layout": [ + { + "op": "place", + "where": "centerTop", + "apply_to": [ + "psw" + ] + } + ] +}
\ No newline at end of file |