diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-07-24 14:29:00 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-07-24 14:29:00 +0200 |
commit | 690d58ec10ffcd18a6662e075d629b12335bb1a6 (patch) | |
tree | f825ffa6840fe445949632daa440ae98636b9aea /src/main/java/at | |
parent | 994f770cc914a009adc9606086698cec6178822d (diff) | |
download | skyhanni-690d58ec10ffcd18a6662e075d629b12335bb1a6.tar.gz skyhanni-690d58ec10ffcd18a6662e075d629b12335bb1a6.tar.bz2 skyhanni-690d58ec10ffcd18a6662e075d629b12335bb1a6.zip |
code cleanup
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt | 24 |
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 |