From 5049a112add648c5666ec8fcfa99843d9b8a5937 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Thu, 2 May 2013 06:05:54 -0500 Subject: [PATCH] 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. By: Travis Watkins --- .../org/bukkit/craftbukkit/event/CraftEventFactory.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 07970c00d..56582bc5e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -58,6 +58,7 @@ import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.entity.*; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.*; @@ -665,4 +666,10 @@ public class CraftEventFactory { world.getServer().getPluginManager().callEvent(event); return event; } + + public static void handleInventoryCloseEvent(EntityHuman human) { + InventoryCloseEvent event = new InventoryCloseEvent(human.activeContainer.getBukkitView()); + human.world.getServer().getPluginManager().callEvent(event); + human.activeContainer.transferTo(human.defaultContainer, human.getBukkitEntity()); + } }