diff options
author | Cow <cow@volloeko.de> | 2023-07-16 12:08:10 +0200 |
---|---|---|
committer | Cow <cow@volloeko.de> | 2023-07-16 12:08:10 +0200 |
commit | 24c9e641a1dc0c109d94504ef707a10171b837c4 (patch) | |
tree | add8049a1cb0f2e81fca4d0b1a8d50eb8f0e8992 | |
parent | f30851154f185fba3ce8877fa2ee17894844003d (diff) | |
download | Cowlection-24c9e641a1dc0c109d94504ef707a10171b837c4.tar.gz Cowlection-24c9e641a1dc0c109d94504ef707a10171b837c4.tar.bz2 Cowlection-24c9e641a1dc0c109d94504ef707a10171b837c4.zip |
Fixed rare crash caused by unexpected NBT data typing
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java | 8 |
2 files changed, 6 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index e71b817..65dab68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [1.8.9-0.16.0] - unreleased ### Fixed +- Pet exp in tooltips: fixed rare crash caused by unexpected NBT data typing - Bazaar: fixed "Show items left to buy/sell" not working anymore ## [1.8.9-0.15.1] - 22.12.2022 diff --git a/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java b/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java index 21fa20d..f1d9108 100644 --- a/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java +++ b/src/main/java/de/cowtipper/cowlection/listener/skyblock/SkyBlockListener.java @@ -207,11 +207,13 @@ public class SkyBlockListener { if ((MooConfig.getTooltipPetExpDisplay() == MooConfig.Setting.ALWAYS || MooConfig.getTooltipPetExpDisplay() == MooConfig.Setting.SPECIAL && MooConfig.isTooltipToggleKeyBindingPressed()) && e.itemStack.getItem() == Items.skull) { - if (extraAttributes != null && extraAttributes.hasKey("petInfo")) { + if (extraAttributes != null && extraAttributes.hasKey("petInfo", (byte) 8 /* string */)) { // pet in inventory, auction house or similar HySkyBlockStats.Profile.Pet petInfo = GsonUtils.fromJson(extraAttributes.getString("petInfo"), HySkyBlockStats.Profile.Pet.class); - int index = Math.max(0, e.toolTip.size() - (e.showAdvancedItemTooltips ? /* item name & nbt info */ 2 : 0)); - e.toolTip.add(index, EnumChatFormatting.GRAY + "Pet exp: " + EnumChatFormatting.GOLD + numberFormatter.format(petInfo.getExp())); + if (petInfo != null) { + int index = Math.max(0, e.toolTip.size() - (e.showAdvancedItemTooltips ? /* item name & nbt info */ 2 : 0)); + e.toolTip.add(index, EnumChatFormatting.GRAY + "Pet exp: " + EnumChatFormatting.GOLD + numberFormatter.format(petInfo.getExp())); + } } else if (e.itemStack.getDisplayName().contains("[Lvl ")) { // pet in pets menu for (int i = e.toolTip.size() - 1; i >= 0; i--) { |