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 db40fa504..89d4dca15 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 @@ -2,6 +2,7 @@ import com.willfp.eco.core.gui.menu.Menu; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -77,12 +78,12 @@ public final boolean isCaptiveFromEmpty() { } @Override - public boolean shouldRenderOnClick() { + public boolean shouldRenderOnClick(@NotNull final ClickType clickType) { if (delegate == null) { throw new IllegalStateException("Custom Slot was not initialized!"); } - return delegate.shouldRenderOnClick(); + return delegate.shouldRenderOnClick(clickType); } @Override 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 03019efb6..b37260629 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 @@ -7,6 +7,7 @@ import com.willfp.eco.core.items.TestableItem; import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -96,8 +97,20 @@ default boolean isCaptiveFromEmpty() { * If the slot should re-render the menu if clicked. * * @return If the slot should re-render. + * @deprecated Use {@link Slot#shouldRenderOnClick(ClickType)} instead. */ + @Deprecated(since = "6.66.0", forRemoval = true) default boolean shouldRenderOnClick() { + return shouldRenderOnClick(ClickType.LEFT); + } + + /** + * If the slot should re-render the menu if clicked. + * + * @param clickType The click type. + * @return If the slot should re-render. + */ + default boolean shouldRenderOnClick(@NotNull final ClickType clickType) { return true; } diff --git a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/gui/slot/EcoSlot.kt b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/gui/slot/EcoSlot.kt index 3080eea24..9f72cbf70 100644 --- a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/gui/slot/EcoSlot.kt +++ b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/gui/slot/EcoSlot.kt @@ -35,5 +35,5 @@ open class EcoSlot( override fun getActionableSlot(player: Player, menu: Menu): EcoSlot = this - override fun shouldRenderOnClick() = handlers.values.any { it.isNotEmpty() } + override fun shouldRenderOnClick(clickType: ClickType) = !handlers[clickType].isNullOrEmpty() } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/gui/GUIListener.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/gui/GUIListener.kt index 944e26307..69a39c164 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/gui/GUIListener.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/internal/spigot/gui/GUIListener.kt @@ -46,7 +46,7 @@ class GUIListener(private val plugin: EcoPlugin) : Listener { if (delegate is EcoSlot) { delegate.handleInventoryClick(event, menu) - if (delegate.shouldRenderOnClick()) { + if (delegate.shouldRenderOnClick(event.click)) { player.renderActiveMenu() } } else if (delegate === this) {