Skip to content

Commit

Permalink
fix: applyTo never being changed because of ItemStack#withType making…
Browse files Browse the repository at this point in the history
… new ItemStack
  • Loading branch information
Boy0000 committed May 11, 2024
1 parent fff4f47 commit c883fe7
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ data class BaseSerializableItemStack(
applyTo: ItemStack = ItemStack(type ?: Material.AIR),
ignoreProperties: EnumSet<Properties> = EnumSet.noneOf(Properties::class.java)
): ItemStack {
var applyTo = applyTo
// Import ItemStack from Crucible
crucibleItem?.let { id ->
if (Plugins.isEnabled<MythicCrucible>()) {
MythicCrucible.core().itemManager.getItemStack(id)?.let {
applyTo.withType(it.type)
applyTo.itemMeta = it.itemMeta
applyTo = applyTo.withType(it.type)
} ?: idofrontLogger.w("No Crucible item found with id $id")
} else {
idofrontLogger.w("Tried to import Crucible item, but MythicCrucible was not enabled")
Expand All @@ -97,8 +97,7 @@ data class BaseSerializableItemStack(
oraxenItem?.let { id ->
if (Plugins.isEnabled<OraxenPlugin>()) {
OraxenItems.getItemById(id)?.build()?.let {
applyTo.withType(it.type)
applyTo.itemMeta = it.itemMeta
applyTo = applyTo.withType(it.type)
} ?: idofrontLogger.w("No Oraxen item found with id $id")
} else {
idofrontLogger.w("Tried to import Oraxen item, but Oraxen was not enabled")
Expand All @@ -109,8 +108,7 @@ data class BaseSerializableItemStack(
itemsadderItem?.let { id ->
if (Plugins.isEnabled("ItemsAdder")) {
CustomStack.getInstance(id)?.itemStack?.let {
applyTo.withType(it.type)
applyTo.itemMeta = it.itemMeta
applyTo = applyTo.withType(it.type)
} ?: idofrontLogger.w("No ItemsAdder item found with id $id")
} else {
idofrontLogger.w("Tried to import ItemsAdder item, but ItemsAdder was not enabled")
Expand All @@ -124,7 +122,7 @@ data class BaseSerializableItemStack(

// Modify item
amount?.takeIf { Properties.AMOUNT !in ignoreProperties }?.let { applyTo.amount = it }
type?.takeIf { Properties.TYPE !in ignoreProperties }?.let { applyTo.withType(it) }
type?.takeIf { Properties.TYPE !in ignoreProperties }?.let { applyTo = applyTo.withType(it) }

// Modify meta
val meta = applyTo.itemMeta ?: return applyTo
Expand Down

0 comments on commit c883fe7

Please sign in to comment.