From 978d6d8f5798c98b1041f040bb4b2e79813aa370 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sun, 23 May 2021 16:19:49 +0900 Subject: Display room name and fix styledtextrenderer crashing minecraft. --- .../dungeonsguide/cosmetics/CosmeticsManager.java | 6 +- .../dungeonsguide/features/FeatureRegistry.java | 1 + .../impl/dungeon/FeatureDungeonRoomName.java | 98 ++++++++++++++++++++++ .../features/text/StyledTextRenderer.java | 2 +- 4 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRoomName.java (limited to 'src/main/java/kr/syeyoung/dungeonsguide') diff --git a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java index db79f329..faa41214 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/cosmetics/CosmeticsManager.java @@ -244,13 +244,13 @@ public class CosmeticsManager implements StompMessageHandler { str = str.replace("{HYPIXEL_RANKED_NAME}", "{ANY_COLOR}(?:\\[[a-zA-Z\\+§0-9]+\\] )?{MC_NAME}"); str = str.replace("{HYPIXEL_RANKED_NAME_PAT}", "({ANY_COLOR}(?:\\[[a-zA-Z\\+§0-9]+\\] )?)({MC_NAME})"); str = str.replace("{ISLAND_VISITOR}", "(?:§r§a\\[✌\\] )"); - str = str.replace("{RANK}", "(?:{ANY_COLOR}\\[.+\\] )"); + str = str.replace("{RANK}", "(?:{ANY_COLOR}\\[[a-zA-Z0-9_ ]+\\] )"); str = str.replace("{MC_NAME}", "[a-zA-Z0-9_]+"); str = str.replace("{ANY_COLOR}", "(?:§[a-zA-Z0-9])*"); return str; } - private static final Pattern PARTY_MSG = Pattern.compile(substitute("§r§9Party §8> {HYPIXEL_RANKED_NAME_PAT}({ANY_COLOR}): (.+)")); - private static final Pattern GUILD_MSG = Pattern.compile(substitute("§r§2Guild > {HYPIXEL_RANKED_NAME_PAT}((?: {ANY_COLOR}\\[.+\\])?{ANY_COLOR}): (.+)")); + private static final Pattern PARTY_MSG = Pattern.compile(substitute("§r§9P(?:arty)? §8> {HYPIXEL_RANKED_NAME_PAT}({ANY_COLOR}): (.+)")); + private static final Pattern GUILD_MSG = Pattern.compile(substitute("§r§2G(?:uild)? > {HYPIXEL_RANKED_NAME_PAT}((?: {ANY_COLOR}\\[.+\\])?{ANY_COLOR}): (.+)")); private static final Pattern CHAT_MSG = Pattern.compile(substitute("({ISLAND_VISITOR}?{RANK}?){HYPIXEL_RANKED_NAME_PAT}({ANY_COLOR}): (.+)")); private static final Pattern COOP_MSG = Pattern.compile(substitute("§r§bCo-op > {HYPIXEL_RANKED_NAME_PAT}({ANY_COLOR}): (.+)")); private static final Pattern DM_TO = Pattern.compile(substitute("§dTo §r{HYPIXEL_RANKED_NAME_PAT}§r§7: (.+)")); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java index 341f235a..927684e4 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/FeatureRegistry.java @@ -128,6 +128,7 @@ public class FeatureRegistry { public static final FeatureDungeonMap DUNGEON_MAP = register(new FeatureDungeonMap()); + public static final FeatureDungeonRoomName DUNGEON_ROOMNAME = register(new FeatureDungeonRoomName()); public static final FeaturePressAnyKeyToCloseChest DUNGEON_CLOSECHEST = register(new FeaturePressAnyKeyToCloseChest()); public static final FeatureBoxSkelemaster DUNGEON_BOXSKELEMASTER = register(new FeatureBoxSkelemaster()); public static final FeatureBoxBats DUNGEON_BOXBAT = register(new FeatureBoxBats()); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRoomName.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRoomName.java new file mode 100644 index 00000000..6a1ff781 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeatureDungeonRoomName.java @@ -0,0 +1,98 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2021 cyoung06 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package kr.syeyoung.dungeonsguide.features.impl.dungeon; + +import kr.syeyoung.dungeonsguide.DungeonsGuide; +import kr.syeyoung.dungeonsguide.SkyblockStatus; +import kr.syeyoung.dungeonsguide.config.types.AColor; +import kr.syeyoung.dungeonsguide.dungeon.DungeonContext; +import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoom; +import kr.syeyoung.dungeonsguide.features.text.StyledText; +import kr.syeyoung.dungeonsguide.features.text.TextHUDFeature; +import kr.syeyoung.dungeonsguide.features.text.TextStyle; +import kr.syeyoung.dungeonsguide.utils.TextUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.scoreboard.ScorePlayerTeam; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class FeatureDungeonRoomName extends TextHUDFeature { + public FeatureDungeonRoomName() { + super("Dungeon", "Display name of the room you are in", "Display name of the room you are in", "dungeon.roomname", false, getFontRenderer().getStringWidth("You're in puzzle-tictactoe"), getFontRenderer().FONT_HEIGHT); + getStyles().add(new TextStyle("in", new AColor(0x00, 0xAA,0xAA,255), new AColor(0, 0,0,0), false)); + getStyles().add(new TextStyle("roomname", new AColor(0x55, 0xFF,0xFF,255), new AColor(0, 0,0,0), false)); + } + + SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus(); + + public int getTotalSecretsInt() { + DungeonContext context = skyblockStatus.getContext(); + int totalSecrets = 0; + for (DungeonRoom dungeonRoom : context.getDungeonRoomList()) { + if (dungeonRoom.getTotalSecrets() != -1) + totalSecrets += dungeonRoom.getTotalSecrets(); + } + return totalSecrets; + } + + private static final List dummyText= new ArrayList(); + static { + dummyText.add(new StyledText("You're in ","in")); + dummyText.add(new StyledText("puzzle-tictactoe","roomname")); + } + + @Override + public boolean isHUDViewable() { + return skyblockStatus.isOnDungeon() && skyblockStatus.getContext() != null && skyblockStatus.getContext().getMapProcessor() != null; + } + + @Override + public List getUsedTextStyle() { + return Arrays.asList("roomname"); + } + + @Override + public List getDummyText() { + return dummyText; + } + + @Override + public List getText() { + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + + Point roomPt = skyblockStatus.getContext().getMapProcessor().worldPointToRoomPoint(player.getPosition()); + DungeonRoom dungeonRoom = skyblockStatus.getContext().getRoomMapper().get(roomPt); + List actualBit = new ArrayList(); + dummyText.add(new StyledText("You're in ","in")); + if (dungeonRoom == null) { + actualBit.add(new StyledText("Unknown","roomname")); + } else { + actualBit.add(new StyledText(dungeonRoom.getDungeonRoomInfo().getName(),"roomname")); + } + + + return actualBit; + } + +} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java index fc37cf70..ae30e113 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/text/StyledTextRenderer.java @@ -43,7 +43,7 @@ public class StyledTextRenderer { public static List drawTextWithStylesAssociated(List texts, int x, int y,int width, Map styleMap, Alignment alignment) { - String[] totalLines = texts.stream().map( a-> a.getText()).collect(Collectors.joining()).split("\n"); + String[] totalLines = (texts.stream().map( a-> a.getText()).collect(Collectors.joining())+" ").split("\n"); int currentLine = 0; -- cgit