Add InventoryClick and InventoryDrag event handlers. bump version to 1.1.4-SNAPSHOT

This commit is contained in:
akastijn 2026-02-02 00:06:22 +01:00
parent d0398b1486
commit 02f78d0a23
3 changed files with 25 additions and 4 deletions

View File

@ -9,7 +9,7 @@ val nexusUser = providers.gradleProperty("alttdSnapshotUsername").orNull ?: Syst
val nexusPass = providers.gradleProperty("alttdSnapshotPassword").orNull ?: System.getenv("NEXUS_PASSWORD") val nexusPass = providers.gradleProperty("alttdSnapshotPassword").orNull ?: System.getenv("NEXUS_PASSWORD")
group = "com.alttd.inventory_gui" group = "com.alttd.inventory_gui"
version = "1.1.3-SNAPSHOT" version = "1.1.4-SNAPSHOT"
repositories { repositories {
mavenCentral() mavenCentral()

View File

@ -20,7 +20,6 @@ import java.util.Optional;
* The {@code GuiListener} is associated with a specific plugin by its name to ensure * The {@code GuiListener} is associated with a specific plugin by its name to ensure
* that event handling is scoped to the appropriate plugin's GUI instances. * that event handling is scoped to the appropriate plugin's GUI instances.
*/ */
@SuppressWarnings("ClassCanBeRecord")
public final class GuiListener implements Listener { public final class GuiListener implements Listener {
/** /**
@ -29,6 +28,30 @@ public final class GuiListener implements Listener {
public GuiListener() { public GuiListener() {
} }
/**
* Handles inventory click interactions in the context of GUI sessions. This method ensures
* that the event is processed consistently with other inventory interactions by delegating
* the handling to the {@code onInventoryInteract} method.
*
* @param event the {@code InventoryClickEvent} triggered when a player clicks within an inventory
*/
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
onInventoryInteract(event);
}
/**
* Handles inventory drag interactions in the context of GUI sessions. This method delegates
* the handling of the event to the {@code onInventoryInteract} method to ensure consistent
* processing of inventory interactions.
*
* @param event the {@code InventoryDragEvent} triggered when a player drags items within an inventory
*/
@EventHandler
public void onInventoryDrag(InventoryDragEvent event) {
onInventoryInteract(event);
}
/** /**
* Handles interactions with inventories in the context of GUI sessions. This method ensures * Handles interactions with inventories in the context of GUI sessions. This method ensures
* that the interaction is processed only if the player is part of an active GUI session. * that the interaction is processed only if the player is part of an active GUI session.
@ -37,7 +60,6 @@ public final class GuiListener implements Listener {
* *
* @param event the {@code InventoryInteractEvent} triggered when a player interacts with an inventory * @param event the {@code InventoryInteractEvent} triggered when a player interacts with an inventory
*/ */
@EventHandler
public void onInventoryInteract(InventoryInteractEvent event) { public void onInventoryInteract(InventoryInteractEvent event) {
if (!(event.getWhoClicked() instanceof Player player)) { if (!(event.getWhoClicked() instanceof Player player)) {
return; return;

View File

@ -121,7 +121,6 @@ public class InventoryGui {
} }
if (!item.isClickable()) { if (!item.isClickable()) {
event.setCancelled(true);
return; return;
} }
item.handle(event); item.handle(event);