aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 3f8441629..580ee2a95 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -46,7 +46,7 @@ object ItemUtils {
return list
}
- val ItemStack.extraAttributes : NBTTagCompound get() = this.tagCompound.getCompoundTag("ExtraAttributes")
+ val ItemStack.extraAttributes: NBTTagCompound get() = this.tagCompound.getCompoundTag("ExtraAttributes")
// TODO change else janni is sad
fun ItemStack.isCoopSoulBound(): Boolean =
@@ -79,20 +79,16 @@ object ItemUtils {
}
fun hasAttributes(stack: ItemStack): Boolean {
- if (stack.hasTagCompound()) {
- val tagCompound = stack.tagCompound
- if (tagCompound.hasKey("ExtraAttributes")) {
- val extraAttributes = tagCompound.getCompoundTag("ExtraAttributes")
- try {
- val json = GsonBuilder().create().fromJson(extraAttributes.toString(), JsonObject::class.java)
- if (json.has("attributes")) {
- return true
- }
- } catch (_: Exception) {
- }
- }
+ if (!stack.hasTagCompound()) return false
+ val tagCompound = stack.tagCompound
+ if (!tagCompound.hasKey("ExtraAttributes")) return false
+ val extraAttributes = tagCompound.getCompoundTag("ExtraAttributes")
+ try {
+ val json = GsonBuilder().create().fromJson(extraAttributes.toString(), JsonObject::class.java)
+ return json.has("attributes")
+ } catch (_: Exception) {
+ return false
}
- return false
}
fun ItemStack.getInternalName() = getInternalNameOrNull() ?: NEUInternalName.NONE