Skip to content

Commit

Permalink
Fixed FastItemStack bug
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Aug 7, 2021
1 parent a408e34 commit e758ceb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.lang.reflect.Field
import kotlin.experimental.and

class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemStack<ItemStack>(
getNMSStack(itemStack), itemStack
getNMSStack(itemStack)!!, itemStack
) {
private var loreCache: List<String>? = null
override fun getEnchantmentsOnItem(checkStored: Boolean): Map<Enchantment, Int> {
Expand Down Expand Up @@ -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
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import java.lang.reflect.Field
import kotlin.experimental.and

class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemStack<ItemStack>(
getNMSStack(itemStack), itemStack
getNMSStack(itemStack)!!, itemStack
) {
private var loreCache: List<String>? = null

Expand Down Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit e758ceb

Please sign in to comment.