diff options
author | Lorenz <ESs95s3P5z8Pheb> | 2022-07-17 12:14:29 +0200 |
---|---|---|
committer | Lorenz <ESs95s3P5z8Pheb> | 2022-07-17 12:14:29 +0200 |
commit | 183c4cfaef952a229bc0abca297269dd8804498c (patch) | |
tree | cc8bf413c52a24bd4857f9aa914ba9f46fe289f9 /src | |
parent | 36b887ad01eff9bae8d520b4811fce98672ed792 (diff) | |
download | skyhanni-183c4cfaef952a229bc0abca297269dd8804498c.tar.gz skyhanni-183c4cfaef952a229bc0abca297269dd8804498c.tar.bz2 skyhanni-183c4cfaef952a229bc0abca297269dd8804498c.zip |
fixed nasty npe around skyblock item id fetch
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/ItemUtil.kt | 14 |
1 files changed, 8 insertions, 6 deletions
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<String> { 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<String>(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<String>(lore.tagCount()) + for (lineNumber in 0 until lore.tagCount()) { + loreAsList.add(lore.getStringTagAt(lineNumber)) + } + return Collections.unmodifiableList(loreAsList) } - return Collections.unmodifiableList(loreAsList) } } return emptyList() |