diff --git a/eco-api/src/main/java/com/willfp/eco/core/gui/slot/CustomSlot.java b/eco-api/src/main/java/com/willfp/eco/core/gui/slot/CustomSlot.java index b05ac4a4..6a85aefe 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/gui/slot/CustomSlot.java +++ b/eco-api/src/main/java/com/willfp/eco/core/gui/slot/CustomSlot.java @@ -31,7 +31,7 @@ public abstract class CustomSlot implements Slot { } @Override - public ItemStack getItemStack(@NotNull final Player player) { + public @NotNull ItemStack getItemStack(@NotNull final Player player) { if (delegate == null) { throw new IllegalStateException("Custom Slot was not initialized!"); } diff --git a/eco-api/src/main/java/com/willfp/eco/core/gui/slot/ReactiveSlot.java b/eco-api/src/main/java/com/willfp/eco/core/gui/slot/ReactiveSlot.java index 1af5db4a..dafdf8ea 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/gui/slot/ReactiveSlot.java +++ b/eco-api/src/main/java/com/willfp/eco/core/gui/slot/ReactiveSlot.java @@ -29,7 +29,7 @@ public abstract class ReactiveSlot implements Slot { @NotNull final Menu menu); @Override - public ItemStack getItemStack(@NotNull final Player player) { + public @NotNull ItemStack getItemStack(@NotNull final Player player) { return new ItemStack(Material.STONE); } diff --git a/eco-api/src/main/java/com/willfp/eco/core/gui/slot/Slot.java b/eco-api/src/main/java/com/willfp/eco/core/gui/slot/Slot.java index 787653e3..0a0c9256 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/gui/slot/Slot.java +++ b/eco-api/src/main/java/com/willfp/eco/core/gui/slot/Slot.java @@ -30,6 +30,7 @@ public interface Slot extends GUIComponent { * @param player The player. * @return The ItemStack. */ + @NotNull ItemStack getItemStack(@NotNull Player player); /** @@ -60,6 +61,7 @@ public interface Slot extends GUIComponent { * @param menu The menu. * @return The slot. */ + @NotNull default Slot getActionableSlot(@NotNull final Player player, @NotNull final Menu menu) { return this; @@ -125,7 +127,9 @@ public interface Slot extends GUIComponent { * * @param provider The provider. * @return The builder. + * @deprecated This method was written incorrectly, should have been a Player + Menu function. */ + @Deprecated(since = "6.45.0", forRemoval = true) static SlotBuilder builder(@NotNull final Function provider) { return Eco.get().createSlotBuilder((player, menu) -> provider.apply(player)); } 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 412d8e8d..08c85801 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 @@ -31,9 +31,7 @@ class RenderedInventory( val state = mutableMapOf() fun render() { - val previousCaptive = captiveItems.toMap() - - captiveItems.clear() + val newCaptive = mutableMapOf() for (row in (1..menu.rows)) { for (column in (1..menu.columns)) { @@ -48,11 +46,11 @@ class RenderedInventory( if (slot.isCaptiveFromEmpty) { if (!actualItem.isEmpty) { - captiveItems[position] = actualItem + newCaptive[position] = actualItem } } else { if (actualItem != renderedItem && !EmptyTestableItem().matches(actualItem)) { - captiveItems[position] = actualItem + newCaptive[position] = actualItem } } } else { @@ -61,6 +59,10 @@ class RenderedInventory( } } + val previousCaptive = captiveItems.toMap() + captiveItems.clear() + captiveItems.putAll(newCaptive) + menu.runOnRender(player) // Run second render if captive items changed