Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5799

InventoryCloseEvent fires after PlayerQuitEvent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • git-Spigot-a99063f-8ea9b13 (MC: 1.15.2)
    • Yes

      InventoryCloseEvent fires twice when a player quits the game, once before PlayerQuitEvent and once more after PlayerQuitEvent.

      This causes problems with plugins that clear up player states in PlayerQuitEvent, as the players would not be present when InventoryCloseEvent is called.

      This is the plugin that was used to generate the output captured in the above screenshot:

      import org.bukkit.Bukkit;
      import org.bukkit.event.EventHandler;
      import org.bukkit.event.Listener;
      import org.bukkit.event.inventory.InventoryCloseEvent;
      import org.bukkit.event.player.PlayerQuitEvent;
      import org.bukkit.plugin.java.JavaPlugin;
      
      public final class EventOrderTest extends JavaPlugin implements Listener {
      
          @Override
          public void onEnable() {
              Bukkit.getServer().getPluginManager().registerEvents(this, this);
          }
      
          @EventHandler
          public void onPlayerQuit(final PlayerQuitEvent event) {
              getLogger().info("PlayerQuitEvent");
          }
      
          @EventHandler
          public void onInventoryClose(final InventoryCloseEvent event) {
              getLogger().info("InventoryCloseEvent");
          }
      
      }
      

            Unassigned Unassigned
            Sauilitired Alexander Söderberg
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: