Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/main/java/com/samjakob/spigui/menu/SGMenuListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ public SGMenuListener(JavaPlugin owner, SpiGUI spiGUI) {
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {

// Determine if the inventory was a SpiGUI.
if (event.getInventory().getHolder() != null
&& event.getInventory().getHolder() instanceof SGMenu) {
// Determine if the clicked inventory was a SpiGUI.
if (event.getClickedInventory() != null
&& event.getClickedInventory().getHolder() != null
&& event.getClickedInventory().getHolder() instanceof SGMenu) {

// Get the instance of the SpiGUI that was clicked.
SGMenu clickedGui = (SGMenu) event.getInventory().getHolder();
SGMenu clickedGui = (SGMenu) event.getClickedInventory().getHolder();

// Check if the GUI is owner by the current plugin
// (if not, it'll be deferred to the SGMenuListener registered
// by that plugin that does own the GUI.)
if (!clickedGui.getOwner().equals(owner)) return;

// If the default action is to cancel the event (block default interactions)
// we'll do that now.
// The inventory's value is checked first, so it can be overridden on a
Expand Down