From e758cebe7755148dbeb7b86730f7b59e20bbad24 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sat, 7 Aug 2021 22:09:50 +0100 Subject: [PATCH] Fixed FastItemStack bug --- .../com/willfp/eco/proxy/v1_16_R3/fast/NMSFastItemStack.kt | 6 +++--- .../com/willfp/eco/proxy/v1_17_R1/fast/NMSFastItemStack.kt | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eco-core/core-nms/v1_16_R3/src/main/kotlin/com/willfp/eco/proxy/v1_16_R3/fast/NMSFastItemStack.kt b/eco-core/core-nms/v1_16_R3/src/main/kotlin/com/willfp/eco/proxy/v1_16_R3/fast/NMSFastItemStack.kt index 73ac4970e..cad9e0deb 100644 --- a/eco-core/core-nms/v1_16_R3/src/main/kotlin/com/willfp/eco/proxy/v1_16_R3/fast/NMSFastItemStack.kt +++ b/eco-core/core-nms/v1_16_R3/src/main/kotlin/com/willfp/eco/proxy/v1_16_R3/fast/NMSFastItemStack.kt @@ -11,7 +11,7 @@ import java.lang.reflect.Field import kotlin.experimental.and class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemStack( - getNMSStack(itemStack), itemStack + getNMSStack(itemStack)!!, itemStack ) { private var loreCache: List? = null override fun getEnchantmentsOnItem(checkStored: Boolean): Map { @@ -116,11 +116,11 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS field = temp } - fun getNMSStack(itemStack: org.bukkit.inventory.ItemStack): ItemStack { + fun getNMSStack(itemStack: org.bukkit.inventory.ItemStack): ItemStack? { return if (itemStack !is CraftItemStack) { CraftItemStack.asNMSCopy(itemStack) } else { - field[itemStack] as ItemStack + field.get(itemStack) as ItemStack } } } diff --git a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/fast/NMSFastItemStack.kt b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/fast/NMSFastItemStack.kt index 48093fdad..da1e1195a 100644 --- a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/fast/NMSFastItemStack.kt +++ b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/proxy/v1_17_R1/fast/NMSFastItemStack.kt @@ -16,7 +16,7 @@ import java.lang.reflect.Field import kotlin.experimental.and class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemStack( - getNMSStack(itemStack), itemStack + getNMSStack(itemStack)!!, itemStack ) { private var loreCache: List? = null @@ -136,11 +136,11 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS field = temp } - fun getNMSStack(itemStack: org.bukkit.inventory.ItemStack): ItemStack { + fun getNMSStack(itemStack: org.bukkit.inventory.ItemStack): ItemStack? { return if (itemStack !is CraftItemStack) { CraftItemStack.asNMSCopy(itemStack) } else { - field[itemStack] as ItemStack + field.get(itemStack) as ItemStack } } }