From 183c4cfaef952a229bc0abca297269dd8804498c Mon Sep 17 00:00:00 2001 From: Lorenz Date: Sun, 17 Jul 2022 12:14:29 +0200 Subject: fixed nasty npe around skyblock item id fetch --- src/main/java/at/hannibal2/skyhanni/utils/ItemUtil.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtil.kt index d10adc06c..73f507964 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtil.kt @@ -96,13 +96,15 @@ object ItemUtil { fun getItemLore(itemStack: ItemStack): List { if (itemStack.hasTagCompound() && itemStack.tagCompound.hasKey("display", NBT_COMPOUND)) { val display = itemStack.tagCompound.getCompoundTag("display") - if (display.hasKey("Lore", NBT_LIST)) { - val lore = display.getTagList("Lore", NBT_STRING) - val loreAsList = ArrayList(lore.tagCount()) - for (lineNumber in 0 until lore.tagCount()) { - loreAsList.add(lore.getStringTagAt(lineNumber)) + if (display != null) { + if (display.hasKey("Lore", NBT_LIST)) { + val lore = display.getTagList("Lore", NBT_STRING) + val loreAsList = ArrayList(lore.tagCount()) + for (lineNumber in 0 until lore.tagCount()) { + loreAsList.add(lore.getStringTagAt(lineNumber)) + } + return Collections.unmodifiableList(loreAsList) } - return Collections.unmodifiableList(loreAsList) } } return emptyList() -- cgit