From 690d58ec10ffcd18a6662e075d629b12335bb1a6 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:29:00 +0200 Subject: code cleanup --- .../java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 24 +++++++++------------- 1 file 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 -- cgit