check isAir instead of null
Some checks are pending
Java CI with Gradle / build (push) Waiting to run

This commit is contained in:
alexcrea 2026-07-16 19:16:57 +02:00
parent 3bf083b762
commit f2f39dc326
Signed by: alexcrea
GPG key ID: E59DF23EE2A2266C
2 changed files with 5 additions and 4 deletions

View file

@ -82,6 +82,6 @@ object ItemUtil {
* The two items should either be the same type, or, the [other] is a book * The two items should either be the same type, or, the [other] is a book
*/ */
fun ItemStack.canMergeWith( fun ItemStack.canMergeWith(
other: ItemStack? other: ItemStack
) = (other != null) && (customType == other.customType || (other.isEnchantedBook())) ) = customType == other.customType || (other.isEnchantedBook())
} }

View file

@ -31,6 +31,7 @@ import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_INPUT_
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_INPUT_RIGHT import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_INPUT_RIGHT
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT
import xyz.alexcrea.cuanvil.util.CustomRecipeUtil import xyz.alexcrea.cuanvil.util.CustomRecipeUtil
import xyz.alexcrea.cuanvil.util.MaterialUtil.isAir
import xyz.alexcrea.cuanvil.util.MiniMessageUtil import xyz.alexcrea.cuanvil.util.MiniMessageUtil
import xyz.alexcrea.cuanvil.util.anvil.AnvilLoreEditUtil import xyz.alexcrea.cuanvil.util.anvil.AnvilLoreEditUtil
import xyz.alexcrea.cuanvil.util.anvil.AnvilXpUtil import xyz.alexcrea.cuanvil.util.anvil.AnvilXpUtil
@ -92,7 +93,7 @@ class AnvilResultListener : Listener {
} }
// Rename // Rename
if (rightItem == null) { if (rightItem.isAir) {
val result = AnvilMergeLogic.doRenaming(view, player, leftItem) val result = AnvilMergeLogic.doRenaming(view, player, leftItem)
if (result.isEmpty()) return if (result.isEmpty()) return
@ -106,7 +107,7 @@ class AnvilResultListener : Listener {
} }
// Merge // Merge
val canMerge = leftItem.canMergeWith(rightItem) val canMerge = leftItem.canMergeWith(rightItem!!)
if (canMerge) { if (canMerge) {
val result = AnvilMergeLogic.doMerge(view, player, leftItem, rightItem) val result = AnvilMergeLogic.doMerge(view, player, leftItem, rightItem)