mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
check isAir instead of null
This commit is contained in:
parent
8830b4c4ed
commit
9fc0203456
3 changed files with 5 additions and 5 deletions
|
|
@ -75,6 +75,6 @@ object ItemUtil {
|
|||
* The two items should either be the same type, or, the [other] is a book
|
||||
*/
|
||||
fun ItemStack.canMergeWith(
|
||||
other: ItemStack?
|
||||
) = (other != null) && (customType == other.customType || (other.isEnchantedBook()))
|
||||
other: ItemStack
|
||||
) = customType == other.customType || (other.isEnchantedBook())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_OUTPUT_SLOT
|
||||
import xyz.alexcrea.cuanvil.util.CustomRecipeUtil
|
||||
import xyz.alexcrea.cuanvil.util.MaterialUtil.isAir
|
||||
import xyz.alexcrea.cuanvil.util.MiniMessageUtil
|
||||
import xyz.alexcrea.cuanvil.util.anvil.AnvilLoreEditUtil
|
||||
import xyz.alexcrea.cuanvil.util.anvil.AnvilXpUtil
|
||||
|
|
@ -92,7 +93,7 @@ class AnvilResultListener : Listener {
|
|||
}
|
||||
|
||||
// Rename
|
||||
if (rightItem == null) {
|
||||
if (rightItem.isAir) {
|
||||
val result = AnvilMergeLogic.doRenaming(view, inventory, player, leftItem)
|
||||
if (result.isEmpty()) return
|
||||
|
||||
|
|
@ -106,7 +107,7 @@ class AnvilResultListener : Listener {
|
|||
}
|
||||
|
||||
// Merge
|
||||
val canMerge = leftItem.canMergeWith(rightItem)
|
||||
val canMerge = leftItem.canMergeWith(rightItem!!)
|
||||
if (canMerge) {
|
||||
val result = AnvilMergeLogic.doMerge(view, inventory, player, leftItem, rightItem)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package xyz.alexcrea.cuanvil.util
|
||||
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.NamespacedKey
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue