From 833da9c47db2973280d4b359f49ea3a837495bf2 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 24 Jun 2020 09:54:59 +1000 Subject: [PATCH] SPIGOT-5799: InventoryCloseEvent fires after PlayerQuitEvent --- nms-patches/PlayerList.patch | 4 ++-- .../java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nms-patches/PlayerList.patch b/nms-patches/PlayerList.patch index 925b41861c..44e2f2667d 100644 --- a/nms-patches/PlayerList.patch +++ b/nms-patches/PlayerList.patch @@ -265,13 +265,13 @@ entityplayer.a(StatisticList.LEAVE_GAME); + + // 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); ++ entityplayer.closeInventory(); + + PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game"); + cserver.getPluginManager().callEvent(playerQuitEvent); + entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); + -+ entityplayer.playerTick();// SPIGOT-924 ++ entityplayer.playerTick(); // SPIGOT-924 + // CraftBukkit end + this.savePlayerFile(entityplayer); diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 75cae10710..2929cac69a 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1236,6 +1236,10 @@ public class CraftEventFactory { } public static void handleInventoryCloseEvent(EntityHuman human) { + // SPIGOT-5799 - no need to fire for when no inventory open + if (human.activeContainer == human.defaultContainer) { + return; + } InventoryCloseEvent event = new InventoryCloseEvent(human.activeContainer.getBukkitView()); human.world.getServer().getPluginManager().callEvent(event); human.activeContainer.transferTo(human.defaultContainer, human.getBukkitEntity());