From 24c9e641a1dc0c109d94504ef707a10171b837c4 Mon Sep 17 00:00:00 2001 From: Cow Date: Sun, 16 Jul 2023 12:08:10 +0200 Subject: Fixed rare crash caused by unexpected NBT data typing --- .../cowtipper/cowlection/listener/skyblock/SkyBlockListener.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') 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--) { -- cgit