diff --git a/paper-server/patches/sources/net/minecraft/network/Connection.java.patch b/paper-server/patches/sources/net/minecraft/network/Connection.java.patch index ef27d141a0..0209fb4a1a 100644 --- a/paper-server/patches/sources/net/minecraft/network/Connection.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/Connection.java.patch @@ -117,11 +117,32 @@ public void write(ChannelHandlerContext channelhandlercontext, Object object, ChannelPromise channelpromise) throws Exception { super.write(channelhandlercontext, object, channelpromise); } -@@ -661,6 +691,7 @@ +@@ -660,7 +690,28 @@ + }); packetlistener1.onDisconnect(disconnectiondetails); - } ++ } + this.pendingActions.clear(); // Free up packet queue. ++ // Paper start - Add PlayerConnectionCloseEvent ++ final PacketListener packetListener = this.getPacketListener(); ++ if (packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl commonPacketListener) { ++ /* Player was logged in, either game listener or configuration listener */ ++ final com.mojang.authlib.GameProfile profile = commonPacketListener.getOwner(); ++ new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(profile.getId(), ++ profile.getName(), ((InetSocketAddress) this.address).getAddress(), false).callEvent(); ++ } else if (packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginListener) { ++ /* Player is login stage */ ++ switch (loginListener.state) { ++ case VERIFYING: ++ case WAITING_FOR_DUPE_DISCONNECT: ++ case PROTOCOL_SWITCHING: ++ case ACCEPTED: ++ final com.mojang.authlib.GameProfile profile = loginListener.authenticatedProfile; /* Should be non-null at this stage */ ++ new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(profile.getId(), profile.getName(), ++ ((InetSocketAddress) this.address).getAddress(), false).callEvent(); ++ } + } ++ // Paper end - Add PlayerConnectionCloseEvent } } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index 810ca11bb9..d3442bd917 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -56,8 +56,12 @@ private static final int MAX_TICKS_BEFORE_LOGIN = 600; private final byte[] challenge; final MinecraftServer server; -@@ -60,6 +89,7 @@ - private GameProfile authenticatedProfile; +@@ -57,9 +86,10 @@ + @Nullable + String requestedUsername; + @Nullable +- private GameProfile authenticatedProfile; ++ public GameProfile authenticatedProfile; // Paper - public private final String serverId; private final boolean transferred; + private ServerPlayer player; // CraftBukkit