Improve InventoryCloseEvent handling. Fixes BUKKIT-3286

Currently there are several cases where a player will have their inventory
screen closed client side but we will not call an event. To correct this
we call the event when the server is the cause of the inventory closing
instead of just when the client is the cause. We also ensure the server is
closing the inventory reliably so we get the events. Additionally this
commit also calls the event when a player disconnects which will handle
kicks, quits, and server shutdown.
This commit is contained in:
Travis Watkins committed 2013-05-02 06:28:51 -05:00
1 parent 75641a607e
commit 401a6809be
5 files changed
+18 -12

No files matched your search

@@ -250,6 +250,8 @@ public abstract class PlayerList {
if (entityplayer.playerConnection.disconnected) return null; // CraftBukkit - exploitsies fix
// CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
org.bukkit.craftbukkit.event.CraftEventFactory.handleInventoryCloseEvent(entityplayer);
PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(this.cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.name + " left the game.");
this.cserver.getPluginManager().callEvent(playerQuitEvent);
entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());