Package com.ranull.graves.listener
Class InventoryClickListener
java.lang.Object
com.ranull.graves.listener.InventoryClickListener
- All Implemented Interfaces:
org.bukkit.event.Listener
Listener for handling InventoryClickEvent to manage grave-related inventory interactions.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInventoryClickListener
(Graves plugin) Constructs an InventoryClickListener with the specified Graves plugin. -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
checkIfXPGivingInventory
(org.bukkit.event.inventory.InventoryType inventoryType) Checks if the inventory type is one that grants XP (e.g., Furnace, Anvil, Grindstone).private UUID
getGraveUUIDFromItemStack
(org.bukkit.inventory.ItemStack itemStack) Retrieves the Grave UUID from the item stack.private void
handleGraveInventoryClick
(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player, Grave grave) Handles inventory clicks when the inventory holder is a Grave.private void
handleGraveListClick
(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player, GraveList graveList) Handles inventory clicks for GraveList inventories.private void
handleGraveMenuClick
(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player, GraveMenu graveMenu) Handles inventory clicks for GraveMenu inventories.private void
handlePlayerInventoryClick
(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player, org.bukkit.inventory.InventoryHolder inventoryHolder) Handles inventory clicks when the player interacts with GraveList or GraveMenu inventories.private void
handleShiftClick
(org.bukkit.event.inventory.InventoryClickEvent event) Handle shift-clicking logic, preventing players from shift-clicking the compass into a restricted inventory.private void
isCompassItem
(org.bukkit.event.inventory.InventoryClickEvent event) Checks if a specific type of compass (e.g., RECOVERY_COMPASS) was clicked in the player's inventory.void
onInventoryClick
(org.bukkit.event.inventory.InventoryClickEvent event) Handles the InventoryClickEvent to perform actions based on the type of inventory holder.
-
Field Details
-
plugin
-
-
Constructor Details
-
InventoryClickListener
Constructs an InventoryClickListener with the specified Graves plugin.- Parameters:
plugin
- The Graves plugin instance.
-
-
Method Details
-
onInventoryClick
public void onInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event) Handles the InventoryClickEvent to perform actions based on the type of inventory holder. Updates grave inventories and handles interactions with GraveList and GraveMenu inventories.- Parameters:
event
- The InventoryClickEvent to handle.
-
isCompassItem
private void isCompassItem(org.bukkit.event.inventory.InventoryClickEvent event) Checks if a specific type of compass (e.g., RECOVERY_COMPASS) was clicked in the player's inventory. Also checks if the clicked inventory involves XP-granting inventories like FURNACE, ANVIL, etc.- Parameters:
event
- The InventoryClickEvent to check.
-
handleShiftClick
private void handleShiftClick(org.bukkit.event.inventory.InventoryClickEvent event) Handle shift-clicking logic, preventing players from shift-clicking the compass into a restricted inventory.- Parameters:
event
- The InventoryClickEvent triggered by the player shift-clicking.
-
checkIfXPGivingInventory
private boolean checkIfXPGivingInventory(org.bukkit.event.inventory.InventoryType inventoryType) Checks if the inventory type is one that grants XP (e.g., Furnace, Anvil, Grindstone).- Parameters:
inventoryType
- The type of the inventory.- Returns:
- true if the inventory grants XP, false otherwise.
-
getGraveUUIDFromItemStack
Retrieves the Grave UUID from the item stack.- Parameters:
itemStack
- The item stack to check.- Returns:
- The UUID of the grave associated with the item stack, or null if not found.
-
handleGraveInventoryClick
private void handleGraveInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player, Grave grave) Handles inventory clicks when the inventory holder is a Grave.- Parameters:
event
- The InventoryClickEvent.grave
- The Grave inventory holder.
-
handlePlayerInventoryClick
private void handlePlayerInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player, org.bukkit.inventory.InventoryHolder inventoryHolder) Handles inventory clicks when the player interacts with GraveList or GraveMenu inventories.- Parameters:
event
- The InventoryClickEvent.player
- The player interacting with the inventory.inventoryHolder
- The inventory holder.
-
handleGraveListClick
private void handleGraveListClick(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player, GraveList graveList) Handles inventory clicks for GraveList inventories.- Parameters:
event
- The InventoryClickEvent.player
- The player interacting with the inventory.graveList
- The GraveList inventory holder.
-
handleGraveMenuClick
private void handleGraveMenuClick(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player, GraveMenu graveMenu) Handles inventory clicks for GraveMenu inventories.- Parameters:
event
- The InventoryClickEvent.player
- The player interacting with the inventory.graveMenu
- The GraveMenu inventory holder.
-