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

OfflinePlayer.isOnline() returns true between disconnecting and leaving

XMLWordPrintable

      I'd say that a player is no longer 'online' after disconnecting.
      So my intuition tells me that PlayerQuitEvent.getPlayer().isOnline() should return false after a player loses connection.

      import org.bukkit.Bukkit;
      import org.bukkit.event.*;
      import org.bukkit.event.player.PlayerQuitEvent;
      import org.bukkit.plugin.java.JavaPlugin;
      
      public class DisconnectedOnlineBugPlugin extends JavaPlugin implements Listener {
      
      	@Override
      	public void onEnable()  {
      		Bukkit.getPluginManager().registerEvents(this, this);
      	}
      
      	@EventHandler
      	public void onLeave(PlayerQuitEvent event) {
      		this.getLogger().info("event.getPlayer().isOnline() = " + event.getPlayer().isOnline());
      	}
      }
      

      DisconnectedOnlineBug.jar
      But infact when a player leaves the console output is:

      Selebrator lost connection: Disconnected
      [DisconnectedOnlineBug] event.getPlayer().isOnline() = true
      Selebrator left the game
      

      I'm open to changing my mind on this. Anyhow I just wanted to raise awareness for this issue.

            Unassigned Unassigned
            Selebrator Selebrator
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: