From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alfie Cleveland <alfeh@me.com>
Date: Tue, 27 Dec 2016 01:57:57 +0000
Subject: [PATCH] Properly fix item duplication bug

Credit to prplz for figuring out the real issue

diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 3cde25c2479adcc4ce3014e5ac2ec0710bffeea9..4ff66138fa43cf932b95d6d3dc050a9cd7b28ad4 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -2066,8 +2066,8 @@ public class ServerPlayer extends Player implements ContainerListener {
     }
 
     @Override
-    public boolean isImmobile() {
-        return super.isImmobile() || !getBukkitEntity().isOnline();
+    protected boolean isImmobile() {
+        return super.isImmobile() || (this.connection != null && this.connection.isDisconnected()); // Paper
     }
 
     @Override
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 1b92c669bbe69bcc07a554b7b43ee99bfebc1af4..ecc393ad94332ec2a59d29f30bd60bade4e1f18e 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2818,7 +2818,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
     }
 
     public final boolean isDisconnected() {
-        return !this.player.joining && !this.connection.isConnected();
+        return (!this.player.joining && !this.connection.isConnected()) || this.processedDisconnect; // Paper
     }
     // CraftBukkit end