aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-17 12:14:29 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-17 12:14:29 +0200
commit2bc020ed5614dca34005500e8f0554d0e77dc677 (patch)
treecc8bf413c52a24bd4857f9aa914ba9f46fe289f9
parent4ec6e7f2bb16591c0cd3392390dbf5c30ca33493 (diff)
downloadSkyHanni-2bc020ed5614dca34005500e8f0554d0e77dc677.tar.gz
SkyHanni-2bc020ed5614dca34005500e8f0554d0e77dc677.tar.bz2
SkyHanni-2bc020ed5614dca34005500e8f0554d0e77dc677.zip
fixed nasty npe around skyblock item id fetch
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtil.kt14
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()