From 25cf8d682b6bc0ad9a44331d325170c38b926ad4 Mon Sep 17 00:00:00 2001 From: Outfluencer <48880402+Outfluencer@users.noreply.github.com> Date: Sat, 13 Apr 2024 17:22:31 +1000 Subject: [PATCH] #3617: Don't go further if connection is disconnected during handshake event Also replace all isClosed with isClosing as it is more accurate for disconnect calls in events. --- .../net/md_5/bungee/connection/InitialHandler.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 4ccd71e3..9965cf36 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -218,7 +218,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection @Override public void done(ProxyPingEvent result, Throwable error) { - if ( ch.isClosed() ) + if ( ch.isClosing() ) { return; } @@ -361,6 +361,12 @@ public class InitialHandler extends PacketHandler implements PendingConnection bungee.getPluginManager().callEvent( new PlayerHandshakeEvent( InitialHandler.this, handshake ) ); + // return if the connection was closed during the event + if ( ch.isClosing() ) + { + return; + } + switch ( handshake.getRequestedProtocol() ) { case 1: @@ -468,7 +474,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection disconnect( ( reason != null ) ? reason : TextComponent.fromLegacy( bungee.getTranslation( "kick_message" ) ) ); return; } - if ( ch.isClosed() ) + if ( ch.isClosing() ) { return; } @@ -612,7 +618,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection disconnect( ( reason != null ) ? reason : TextComponent.fromLegacy( bungee.getTranslation( "kick_message" ) ) ); return; } - if ( ch.isClosed() ) + if ( ch.isClosing() ) { return; } @@ -672,7 +678,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection public void done(PostLoginEvent result, Throwable error) { // #3612: Don't progress further if disconnected during event - if ( ch.isClosed() ) + if ( ch.isClosing() ) { return; }