From 3e1007527c40a255a35a6809cd9f88c5f38e817c Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 4 Feb 2024 11:47:30 +1100 Subject: [PATCH] #3612: Error when disconnecting player on PostLoginEvent --- .../java/net/md_5/bungee/ServerConnector.java | 18 +++++++++--------- .../md_5/bungee/connection/InitialHandler.java | 7 +++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index 193a20578..695d99a7d 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -10,6 +10,7 @@ import java.util.Locale; import java.util.Queue; import java.util.Set; import java.util.UUID; +import java.util.logging.Level; import lombok.Getter; import lombok.RequiredArgsConstructor; import net.md_5.bungee.api.ChatColor; @@ -339,6 +340,14 @@ public class ServerConnector extends PacketHandler private void cutThrough(ServerConnection server) { + // TODO: Fix this? + if ( !user.isActive() ) + { + server.disconnect( "Quitting" ); + bungee.getLogger().log( Level.WARNING, "[{0}] No client connected for pending server!", user ); + return; + } + if ( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_20_2 ) { if ( user.getServer() != null ) @@ -360,15 +369,6 @@ public class ServerConnector extends PacketHandler user.getServer().disconnect( "Quitting" ); } - // TODO: Fix this? - if ( !user.isActive() ) - { - server.disconnect( "Quitting" ); - // Silly server admins see stack trace and die - bungee.getLogger().warning( "No client connected for pending server!" ); - return; - } - // Add to new server // TODO: Move this to the connected() method of DownstreamBridge target.addPlayer( user ); 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 b51500be9..d9247fb2f 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 @@ -653,6 +653,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) ); bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) ); + + // #3612: Don't progress further if disconnected during event + if ( ch.isClosed() ) + { + return; + } + ServerInfo server; if ( bungee.getReconnectHandler() != null ) {