mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-09-07 12:58:02 +02:00
Secured the handling of InventoryClickEvent for panels (#761)
* Fix Challenges GUI issue 132 Fixed https://github.com/BentoBoxWorld/Challenges/issues/132 This issue happens because AnvilGUIClick event was processed after BentoBox registers new Panel. I add extra check in InventoryClickEvent that not only checks if user has opened panel, but also compares if event and panel has the same inventory, before processing it as BentoBox Panel. * Removed the unneeded PlayerKickEvent
This commit is contained in:
parent
2e84860aa0
commit
ebe2f5aa4c
@ -12,6 +12,7 @@ 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.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
@ -31,7 +32,8 @@ public class PanelListenerManager implements Listener {
|
||||
InventoryView view = event.getView();
|
||||
|
||||
// Open the inventory panel that this player has open (they can only ever have one)
|
||||
if (openPanels.containsKey(user.getUniqueId())) {
|
||||
if (openPanels.containsKey(user.getUniqueId()) &&
|
||||
openPanels.get(user.getUniqueId()).getInventory().equals(event.getClickedInventory())) {
|
||||
// Cancel the event. If they don't want it to be cancelled then the click handler(s) should
|
||||
// uncancel it. If gui was from our environment, then cancel event anyway.
|
||||
event.setCancelled(true);
|
||||
|
Loading…
Reference in New Issue
Block a user