aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com>2024-08-08 17:35:48 +1000
committerGitHub <noreply@github.com>2024-08-08 17:35:48 +1000
commit805cc17bddfadf38627612a7447cb69c43f8c06b (patch)
tree1b869e2ea98b205e81c9eef37e5fdde6943efea3
parent0c32a484cac42ff546b035b9e9d4086a6c4ee64d (diff)
downloadnotenoughupdates-805cc17bddfadf38627612a7447cb69c43f8c06b.tar.gz
notenoughupdates-805cc17bddfadf38627612a7447cb69c43f8c06b.tar.bz2
notenoughupdates-805cc17bddfadf38627612a7447cb69c43f8c06b.zip
Fix T Rex pet not display properly in pet overlay (#1292)
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java19
1 files changed, 17 insertions, 2 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 47badadb..5749656e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
@@ -430,7 +430,7 @@ public class PetInfoOverlay extends TextOverlay {
String petName =
EnumChatFormatting.GREEN + "[Lvl " + currentPet.petLevel.getCurrentLevel() + "] " +
currentPet.rarity.chatFormatting +
- WordUtils.capitalizeFully(currentPet.petType.replace("_", " "));
+ getPetNameFromId(currentPet.petType);
float levelPercent = getLevelPercent(currentPet);
String lvlStringShort = null;
@@ -998,7 +998,7 @@ public class PetInfoOverlay extends TextOverlay {
Matcher petNameMatcher = TAB_LIST_PET_NAME.matcher(line);
if (petNameMatcher.matches()) {
String petName = petNameMatcher.group(2);
- if (!currentPet.petType.replace("_", " ").equalsIgnoreCase(petName)) {
+ if (!getPetNameFromId(currentPet.petType).equalsIgnoreCase(petName)) {
break;
}
@@ -1169,4 +1169,19 @@ public class PetInfoOverlay extends TextOverlay {
}
return rarity;
}
+
+ private static String getPetNameFromId(String petId) {
+ JsonObject pets = Constants.PETS;
+ String defaultName = WordUtils.capitalizeFully(petId.replace("_", " "));
+ if (pets == null) return defaultName;
+ if (!pets.has("id_to_display_name")) {
+ Utils.showOutdatedRepoNotification("pets.json id_to_display_name");
+ return defaultName;
+ }
+ JsonObject idToDisplayName = pets.get("id_to_display_name").getAsJsonObject();
+ if (idToDisplayName.has(petId)) {
+ return idToDisplayName.get(petId).getAsString();
+ }
+ return defaultName;
+ }
}