Skip to content

Commit

Permalink
Merge pull request #20 from MCreeper12731/master
Browse files Browse the repository at this point in the history
  • Loading branch information
SamJakob authored Mar 12, 2023
2 parents 59256bd + 636c0ea commit 9b244e8
Showing 1 changed file with 6 additions and 5 deletions.
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

0 comments on commit 9b244e8

Please sign in to comment.