From fdea5ffb563a4950581718102ed8b53d72f92ad9 Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Sun, 8 Sep 2024 18:10:33 +1000 Subject: Fix golden dragon egg in pet overlay (#1342) --- .../notenoughupdates/miscfeatures/PetInfoOverlay.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index 66565be2..b9ab7119 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -377,7 +377,7 @@ public class PetInfoOverlay extends TextOverlay { String petName = EnumChatFormatting.GREEN + "[Lvl " + currentPet.petLevel.getCurrentLevel() + "] " + currentPet.rarity.chatFormatting + - getPetNameFromId(currentPet.petType); + getPetNameFromId(currentPet.petType, currentPet.petLevel.getCurrentLevel()); float levelPercent = getLevelPercent(currentPet); String lvlStringShort = null; @@ -946,7 +946,7 @@ public class PetInfoOverlay extends TextOverlay { Matcher petNameMatcher = TAB_LIST_PET_NAME.matcher(line); if (petNameMatcher.matches()) { String petName = petNameMatcher.group(2); - if (!getPetNameFromId(currentPet.petType).equalsIgnoreCase(petName)) { + if (!getPetNameFromId(currentPet.petType, currentPet.petLevel.getCurrentLevel()).equalsIgnoreCase(petName)) { break; } @@ -1118,14 +1118,23 @@ public class PetInfoOverlay extends TextOverlay { return rarity; } - private static String getPetNameFromId(String petId) { + static boolean shownMissingRepo = false; + + private static String getPetNameFromId(String petId, int petLevel) { JsonObject pets = Constants.PETS; String defaultName = WordUtils.capitalizeFully(petId.replace("_", " ")); if (pets == null) return defaultName; - if (!pets.has("id_to_display_name")) { + if (!pets.has("id_to_display_name") && !shownMissingRepo) { Utils.showOutdatedRepoNotification("pets.json id_to_display_name"); + shownMissingRepo = true; return defaultName; } + + if ("GOLDEN_DRAGON".equals(petId)) { + if (petLevel < 100) return "Golden Dragon Egg"; + return defaultName; + } + JsonObject idToDisplayName = pets.get("id_to_display_name").getAsJsonObject(); if (idToDisplayName.has(petId)) { return idToDisplayName.get(petId).getAsString(); -- cgit