diff options
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven')
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java index a75ab412..6af480ea 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/dwarven/DwarvenHud.java @@ -18,8 +18,10 @@ public class DwarvenHud { public static MinecraftClient client = MinecraftClient.getInstance(); + public static List<Commission> commissionList = new ArrayList<>(); - public static final List<Pattern> COMMISSIONS = List.of( + + public static final List<Pattern> COMMISSIONS = Stream.of( "(?:Titanium|Mithril|Hard Stone) Miner", "(?:Ice Walker|Goblin|Goblin Raid|Automaton|Sludge|Team Treasurite Member|Yog|Boss Corleone|Thyst) Slayer", "(?:Lava Springs|Cliffside Veins|Rampart's Quarry|Upper Mines|Royal Mines) Mithril", @@ -32,33 +34,39 @@ public class DwarvenHud { "(?:Ruby|Amber|Sapphire|Jade|Amethyst|Topaz) Gemstone Collector", "(?:Amber|Sapphire|Jade|Amethyst|Topaz) Crystal Hunter", "Chest Looter" - ).stream().map(s -> Pattern.compile("^.*(" + s + "): (\\d+\\.?\\d*%|DONE)")) + ).map(s -> Pattern.compile("^.*(" + s + "): (\\d+\\.?\\d*%|DONE)")) .collect(Collectors.toList()); public static void init(){ HudRenderCallback.EVENT.register((matrixStack, tickDelta) -> { - if (SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enabled) { - int hudX = SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.x; - int hudY = SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.y; - List<Commission> commissions = new ArrayList<>(); - client.getNetworkHandler().getPlayerList().forEach(playerListEntry -> { - if (playerListEntry.getDisplayName() != null) { - for (Pattern pattern : COMMISSIONS) { - Matcher matcher = pattern.matcher(playerListEntry.getDisplayName().getString()); - if (matcher.find()) { - commissions.add(new Commission(matcher.group(1), matcher.group(2))); - } + if (!SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enabled || client.player == null || commissionList.isEmpty()) return; + render(matrixStack, SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.x, SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.y, commissionList); + }); + } - } - } - }); - if (commissions.size() > 0){ - if (SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enableBackground) - DrawableHelper.fill(matrixStack, hudX, hudY, hudX + 200, hudY + (20 * commissions.size()), 0x64000000); - int y = 0; - for (Commission commission : commissions) { - client.textRenderer.drawWithShadow(matrixStack, Text.literal(commission.commission).styled(style -> style.withColor(Formatting.AQUA)).append(Text.literal(": " + commission.progression).styled(style -> style.withColor(Formatting.GREEN))), hudX + 5, hudY + y + 5, 0xFFFFFFFF); - y += 20; + public static void render(MatrixStack matrixStack, int hudX, int hudY, List<Commission> commissions) { + if (commissions.size() > 0){ + if (SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enableBackground) + DrawableHelper.fill(matrixStack, hudX, hudY, hudX + 200, hudY + (20 * commissions.size()), 0x64000000); + int y = 0; + for (Commission commission : commissions) { + client.textRenderer.drawWithShadow(matrixStack, Text.literal(commission.commission).styled(style -> style.withColor(Formatting.AQUA)).append(Text.literal(": " + commission.progression).styled(style -> style.withColor(Formatting.GREEN))), hudX + 5, hudY + y + 5, 0xFFFFFFFF); + y += 20; + } + } + } + + public static void update() { + commissionList = new ArrayList<>(); + if (client.player == null || !SkyblockerConfig.get().locations.dwarvenMines.dwarvenHud.enabled) return; + + client.getNetworkHandler().getPlayerList().forEach(playerListEntry -> { + if (playerListEntry.getDisplayName() != null) { + for (Pattern pattern : COMMISSIONS) { + Matcher matcher = pattern.matcher(playerListEntry.getDisplayName().getString()); + if (matcher.find()) { + commissionList.add(new Commission(matcher.group(1), matcher.group(2))); } + } } }); |