Compare commits

...
2 Commits
3 changed files with 28 additions and 4 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ val nexusUser = providers.gradleProperty("alttdSnapshotUsername").orNull ?: Syst
val nexusPass = providers.gradleProperty("alttdSnapshotPassword").orNull ?: System.getenv("NEXUS_PASSWORD")
group = "com.alttd.inventory_gui"
version = "1.1.3-SNAPSHOT"
version = "1.1.5-SNAPSHOT"
repositories {
mavenCentral()
@@ -20,7 +20,6 @@ import java.util.Optional;
* 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.
*/
@SuppressWarnings("ClassCanBeRecord")
public final class GuiListener implements Listener {
/**
@@ -29,6 +28,30 @@ public final class GuiListener implements Listener {
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
* 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
*/
@EventHandler
public void onInventoryInteract(InventoryInteractEvent event) {
if (!(event.getWhoClicked() instanceof Player player)) {
return;
@@ -88,6 +88,9 @@ public class InventoryGui {
}
Inventory inv = entry.inv();
render(inv);
if (humanEntity instanceof Player player) {
player.updateInventory();
}
}
/**
@@ -121,7 +124,6 @@ public class InventoryGui {
}
if (!item.isClickable()) {
event.setCancelled(true);
return;
}
item.handle(event);