mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-06-22 20:55:04 +02:00
Set disconnect BaseComponent on disconnect InitialHandler
also optimze the exception handling of InitialHandler
This commit is contained in:
parent
b711e4033f
commit
8537709045
|
@ -110,6 +110,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||
@Getter
|
||||
private String extraDataInHandshake = "";
|
||||
private UserConnection userCon;
|
||||
@Getter
|
||||
private BaseComponent disconnectMessage;
|
||||
|
||||
@Override
|
||||
public boolean shouldHandle(PacketWrapper packet) throws Exception
|
||||
|
@ -137,13 +139,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||
@Override
|
||||
public void exception(Throwable t) throws Exception
|
||||
{
|
||||
if ( canSendKickMessage() )
|
||||
{
|
||||
disconnect( ChatColor.RED + Util.exception( t ) );
|
||||
} else
|
||||
{
|
||||
ch.close();
|
||||
}
|
||||
// if the connection is a login attempt, directly send a Kick with the Exception to the client
|
||||
// we can't use disconnect() here as the method delays the Kick packet sending by 250ms and the HandlerBoss
|
||||
// will close the channel before the packet is sent
|
||||
// also we don't want to print the exception twice
|
||||
ch.close( canSendKickMessage() ? new Kick( TextComponent.fromLegacy( ChatColor.RED + Util.exception( t ) ) ) : null );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -666,7 +666,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||
{
|
||||
if ( canSendKickMessage() )
|
||||
{
|
||||
ch.delayedClose( new Kick( reason ) );
|
||||
ch.delayedClose( new Kick( this.disconnectMessage = reason ) );
|
||||
} else
|
||||
{
|
||||
ch.close();
|
||||
|
|
Loading…
Reference in New Issue
Block a user