From 8d596c5f1d24ea2e319e5172b2c954a8caa46f67 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 10 Jun 2018 20:10:41 -0700 Subject: [PATCH] Closes panels when clicked outside. https://github.com/tastybento/bskyblock/issues/180 --- .../bskyblock/listeners/PanelListenerManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/us/tastybento/bskyblock/listeners/PanelListenerManager.java b/src/main/java/us/tastybento/bskyblock/listeners/PanelListenerManager.java index 285c6cbc6..937ef9ec0 100644 --- a/src/main/java/us/tastybento/bskyblock/listeners/PanelListenerManager.java +++ b/src/main/java/us/tastybento/bskyblock/listeners/PanelListenerManager.java @@ -9,6 +9,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; +import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.Inventory; @@ -21,6 +22,11 @@ public class PanelListenerManager implements Listener { @EventHandler(priority = EventPriority.LOWEST) public void onInventoryClick(InventoryClickEvent event) { + // Close inventory if clicked outside + if (event.getSlotType().equals(SlotType.OUTSIDE)) { + event.getWhoClicked().closeInventory(); + return; + } User user = User.getInstance(event.getWhoClicked()); // The player that // clicked the item Inventory inventory = event.getInventory(); // The inventory that was