#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.
This commit is contained in:
Outfluencer 2024-04-13 17:22:31 +10:00 committed by md_5
parent 17e23d5c3f
commit 25cf8d682b
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -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;
}