From b97506ae70651ec0d0d752526a2eab400f273ab8 Mon Sep 17 00:00:00 2001 From: Will FP Date: Sun, 14 Jan 2024 16:44:09 +0000 Subject: [PATCH] Fixed bugs on spigot and old paper versions --- eco-api/src/main/kotlin/com/willfp/eco/core/items/Items.kt | 5 +++++ .../com/willfp/eco/internal/gui/menu/RenderedInventory.kt | 3 ++- .../willfp/eco/internal/spigot/arrows/ArrowDataListener.kt | 4 ++-- .../eco/internal/spigot/recipes/StackedRecipeListener.kt | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/eco-api/src/main/kotlin/com/willfp/eco/core/items/Items.kt b/eco-api/src/main/kotlin/com/willfp/eco/core/items/Items.kt index 7cf81af11..5d56d7798 100644 --- a/eco-api/src/main/kotlin/com/willfp/eco/core/items/Items.kt +++ b/eco-api/src/main/kotlin/com/willfp/eco/core/items/Items.kt @@ -37,9 +37,14 @@ fun ItemStack.toSNBT() = Items.toSNBT(this) /** @see Items.isEmpty */ +@Deprecated("Use ItemStack.isEcoEmpty", ReplaceWith("Items.isEmpty(this)")) val ItemStack?.isEmpty: Boolean get() = Items.isEmpty(this) +/** @see Items.isEmpty */ +val ItemStack?.isEcoEmpty: Boolean + get() = Items.isEmpty(this) + /** @see Items.matchesAny */ fun Collection.matches(item: ItemStack): Boolean = Items.matchesAny(item, this) diff --git a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/gui/menu/RenderedInventory.kt b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/gui/menu/RenderedInventory.kt index dcdd097e3..718645ad9 100644 --- a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/gui/menu/RenderedInventory.kt +++ b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/gui/menu/RenderedInventory.kt @@ -1,6 +1,7 @@ package com.willfp.eco.internal.gui.menu import com.willfp.eco.core.gui.menu.events.CaptiveItemChangeEvent +import com.willfp.eco.core.items.isEcoEmpty import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.eco.util.MenuUtils import com.willfp.eco.util.openMenu @@ -54,7 +55,7 @@ class RenderedInventory( val actualItem = inventory.getItem(bukkit) ?: continue if (slot.isCaptiveFromEmpty) { - if (!actualItem.isEmpty) { + if (!actualItem.isEcoEmpty) { newCaptive[position] = actualItem } } else { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/arrows/ArrowDataListener.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/arrows/ArrowDataListener.kt index 385d8dad3..6e0efe7bf 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/arrows/ArrowDataListener.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/arrows/ArrowDataListener.kt @@ -1,7 +1,7 @@ package com.willfp.eco.internal.spigot.arrows import com.willfp.eco.core.EcoPlugin -import com.willfp.eco.core.items.isEmpty +import com.willfp.eco.core.items.isEcoEmpty import org.bukkit.entity.Arrow import org.bukkit.entity.LivingEntity import org.bukkit.event.EventHandler @@ -29,7 +29,7 @@ class ArrowDataListener( val item = entity.equipment?.itemInMainHand - if (item.isEmpty || item == null) { + if (item.isEcoEmpty || item == null) { return } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/StackedRecipeListener.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/StackedRecipeListener.kt index bfd6560b0..36fcd28c0 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/StackedRecipeListener.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/recipes/StackedRecipeListener.kt @@ -2,7 +2,7 @@ package com.willfp.eco.internal.spigot.recipes import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.items.TestableItem -import com.willfp.eco.core.items.isEmpty +import com.willfp.eco.core.items.isEcoEmpty import com.willfp.eco.core.recipe.Recipes import com.willfp.eco.core.recipe.parts.GroupedTestableItems import com.willfp.eco.core.recipe.parts.TestableStack @@ -33,7 +33,7 @@ class StackedRecipeListener( } // Just in case - if (inventory.getItem(event.slot).isEmpty) { + if (inventory.getItem(event.slot).isEcoEmpty) { return }