From b3b961f9d50144a3c131016d0dc8d0efe3f43412 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Tue, 26 Sep 2023 09:20:17 -0700 Subject: [PATCH] Fire PlayerConnectionCloseEvent for configuration packet listener If the player moves to the configuration stage, we also need to fire the event. --- .../0288-Add-PlayerConnectionCloseEvent.patch | 17 ++++++++--------- ...rk-Manager-and-add-advanced-packet-sup.patch | 6 +++--- ...acktraces-in-log-messages-crash-report.patch | 2 +- patches/server/0453-Buffer-joins-to-world.patch | 2 +- .../server/0487-Add-API-for-quit-reason.patch | 2 +- ...7-Add-Channel-initialization-listeners.patch | 2 +- ...elocity-compression-and-cipher-natives.patch | 2 +- ...ail-more-information-in-watchdog-dumps.patch | 2 +- .../server/0701-Add-packet-limiter-config.patch | 2 +- 9 files changed, 18 insertions(+), 19 deletions(-) diff --git a/patches/server/0288-Add-PlayerConnectionCloseEvent.patch b/patches/server/0288-Add-PlayerConnectionCloseEvent.patch index b04dc2e895..5246a24d7d 100644 --- a/patches/server/0288-Add-PlayerConnectionCloseEvent.patch +++ b/patches/server/0288-Add-PlayerConnectionCloseEvent.patch @@ -39,23 +39,22 @@ public net.minecraft.server.network.ServerLoginPacketListenerImpl state public net.minecraft.server.network.ServerLoginPacketListenerImpl gameProfile diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 6fcbf8205e1852d5193a42bfe1154f62ab01e7ad..9f8fbb8231b60c287c9442365c2f95cde92969b8 100644 +index 6fcbf8205e1852d5193a42bfe1154f62ab01e7ad..25881c890c643ce90bdcda6b094d912bafb0ed75 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -644,6 +644,27 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -644,6 +644,26 @@ public class Connection extends SimpleChannelInboundHandler> { packetlistener1.onDisconnect(ichatbasecomponent); } this.pendingActions.clear(); // Free up packet queue. + // Paper start - Add PlayerConnectionCloseEvent + final PacketListener packetListener = this.getPacketListener(); -+ if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl) { -+ /* Player was logged in */ -+ final net.minecraft.server.network.ServerGamePacketListenerImpl playerConnection = (net.minecraft.server.network.ServerGamePacketListenerImpl) packetListener; -+ new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(playerConnection.player.getUUID(), -+ playerConnection.player.getScoreboardName(), ((java.net.InetSocketAddress)address).getAddress(), false).callEvent(); -+ } else if (packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl) { ++ 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(), ((java.net.InetSocketAddress)address).getAddress(), false).callEvent(); ++ } else if (packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginListener) { + /* Player is login stage */ -+ final net.minecraft.server.network.ServerLoginPacketListenerImpl loginListener = (net.minecraft.server.network.ServerLoginPacketListenerImpl) packetListener; + switch (loginListener.state) { + case VERIFYING: + case WAITING_FOR_DUPE_DISCONNECT: diff --git a/patches/server/0301-Optimize-Network-Manager-and-add-advanced-packet-sup.patch b/patches/server/0301-Optimize-Network-Manager-and-add-advanced-packet-sup.patch index 99b56c8ca0..cbd7df1772 100644 --- a/patches/server/0301-Optimize-Network-Manager-and-add-advanced-packet-sup.patch +++ b/patches/server/0301-Optimize-Network-Manager-and-add-advanced-packet-sup.patch @@ -28,7 +28,7 @@ and then catch exceptions and close if they fire. Part of this commit was authored by: Spottedleaf, sandtechnology diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 9f8fbb8231b60c287c9442365c2f95cde92969b8..d8ae86dcc07872c63064782c9864b873f07139d1 100644 +index 25881c890c643ce90bdcda6b094d912bafb0ed75..1931db6936773657bd43b9b16de950cb3e7a2303 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -84,7 +84,7 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -237,8 +237,8 @@ index 9f8fbb8231b60c287c9442365c2f95cde92969b8..d8ae86dcc07872c63064782c9864b873 + this.clearPacketQueue(); // Paper - Optimize network // Paper start - Add PlayerConnectionCloseEvent final PacketListener packetListener = this.getPacketListener(); - if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl) { -@@ -681,4 +765,89 @@ public class Connection extends SimpleChannelInboundHandler> { + if (packetListener instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl commonPacketListener) { +@@ -680,4 +764,89 @@ public class Connection extends SimpleChannelInboundHandler> { public void setBandwidthLogger(SampleLogger log) { this.bandwidthDebugMonitor = new BandwidthDebugMonitor(log); } diff --git a/patches/server/0391-Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/0391-Deobfuscate-stacktraces-in-log-messages-crash-report.patch index efcc6a867b..b4d1ed3a20 100644 --- a/patches/server/0391-Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/0391-Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -494,7 +494,7 @@ index 52eb3176437113f9a0ff85d10ce5c2415e1b5570..b54ddd0ba0b001fbcb1838a838ca4890 } } diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index d8ae86dcc07872c63064782c9864b873f07139d1..af4ded7a31da34ccebb3cfe9c1eb5d5c918950b1 100644 +index 1931db6936773657bd43b9b16de950cb3e7a2303..36a78cc103ddf1cc7ccddefc0b3fd6cef987f67d 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -75,13 +75,13 @@ public class Connection extends SimpleChannelInboundHandler> { diff --git a/patches/server/0453-Buffer-joins-to-world.patch b/patches/server/0453-Buffer-joins-to-world.patch index 4a45ac3b97..a0a51f955d 100644 --- a/patches/server/0453-Buffer-joins-to-world.patch +++ b/patches/server/0453-Buffer-joins-to-world.patch @@ -8,7 +8,7 @@ the world per tick, this attempts to reduce the impact that join floods has on the server diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index af4ded7a31da34ccebb3cfe9c1eb5d5c918950b1..b9d1eefb2afbf24bdc902c6dea06e911e835d698 100644 +index 36a78cc103ddf1cc7ccddefc0b3fd6cef987f67d..f9d7fec242a059a3b056c569ffaf214a361716d6 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -498,14 +498,29 @@ public class Connection extends SimpleChannelInboundHandler> { diff --git a/patches/server/0487-Add-API-for-quit-reason.patch b/patches/server/0487-Add-API-for-quit-reason.patch index 613635d3cd..7e58c53034 100644 --- a/patches/server/0487-Add-API-for-quit-reason.patch +++ b/patches/server/0487-Add-API-for-quit-reason.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add API for quit reason diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index b9d1eefb2afbf24bdc902c6dea06e911e835d698..4f5216cb3ac323de1a79c2b9c4d2ddd7c4875138 100644 +index f9d7fec242a059a3b056c569ffaf214a361716d6..33a3c657bd390b9e8bc23af93c1107f5327181b2 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -183,12 +183,15 @@ public class Connection extends SimpleChannelInboundHandler> { diff --git a/patches/server/0587-Add-Channel-initialization-listeners.patch b/patches/server/0587-Add-Channel-initialization-listeners.patch index 523704b0e0..360d19718e 100644 --- a/patches/server/0587-Add-Channel-initialization-listeners.patch +++ b/patches/server/0587-Add-Channel-initialization-listeners.patch @@ -122,7 +122,7 @@ index 0000000000000000000000000000000000000000..0d7e7db9e37ef0183c32b217bd944fb4 + COMPRESSION_DISABLED +} diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 4f5216cb3ac323de1a79c2b9c4d2ddd7c4875138..c06473f8c6cb116071e256747bc95c38dd2015a6 100644 +index 33a3c657bd390b9e8bc23af93c1107f5327181b2..332a37dbd3ffa05614ae97b90453fcc242b6007d 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -717,6 +717,7 @@ public class Connection extends SimpleChannelInboundHandler> { diff --git a/patches/server/0693-Use-Velocity-compression-and-cipher-natives.patch b/patches/server/0693-Use-Velocity-compression-and-cipher-natives.patch index e24e92a387..f48185f3ff 100644 --- a/patches/server/0693-Use-Velocity-compression-and-cipher-natives.patch +++ b/patches/server/0693-Use-Velocity-compression-and-cipher-natives.patch @@ -264,7 +264,7 @@ index 859af8c845bae9781a62fa4acae56c6e2d449e10..ec7239fd6a2ecf732d2843f9426e4cb6 return this.threshold; } diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index c06473f8c6cb116071e256747bc95c38dd2015a6..cb82729631f3944cbf068ff730df0c2e1c3b2e1f 100644 +index 332a37dbd3ffa05614ae97b90453fcc242b6007d..fc32505422bebd52f5bcd6a6bb7525fa443ee8e0 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -669,11 +669,28 @@ public class Connection extends SimpleChannelInboundHandler> { diff --git a/patches/server/0694-Detail-more-information-in-watchdog-dumps.patch b/patches/server/0694-Detail-more-information-in-watchdog-dumps.patch index 885d71197d..05527ef60a 100644 --- a/patches/server/0694-Detail-more-information-in-watchdog-dumps.patch +++ b/patches/server/0694-Detail-more-information-in-watchdog-dumps.patch @@ -7,7 +7,7 @@ Subject: [PATCH] Detail more information in watchdog dumps - Dump player name, player uuid, position, and world for packet handling diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index cb82729631f3944cbf068ff730df0c2e1c3b2e1f..fdfd07b76b904e5ad70ca63a44f2442500f1e887 100644 +index fc32505422bebd52f5bcd6a6bb7525fa443ee8e0..78e540af673c47f77b5efec4719d5e140da744c2 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -521,7 +521,13 @@ public class Connection extends SimpleChannelInboundHandler> { diff --git a/patches/server/0701-Add-packet-limiter-config.patch b/patches/server/0701-Add-packet-limiter-config.patch index 7d96f03ebb..6b454b34dd 100644 --- a/patches/server/0701-Add-packet-limiter-config.patch +++ b/patches/server/0701-Add-packet-limiter-config.patch @@ -24,7 +24,7 @@ and an action can be defined: DROP or KICK If interval or rate are less-than 0, the limit is ignored diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index fdfd07b76b904e5ad70ca63a44f2442500f1e887..91fcb63835b0b725c53bc75be782b5c5bcc870e7 100644 +index 78e540af673c47f77b5efec4719d5e140da744c2..c0ea20dcee8bb293df96bc6ee019e50ad6b383fd 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -132,6 +132,22 @@ public class Connection extends SimpleChannelInboundHandler> {