Don't send/construct redundant kick messages
This commit is contained in:
parent
e9ba95b9dc
commit
1dee049007
@ -118,6 +118,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHED;
|
HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canSendKickMessage()
|
||||||
|
{
|
||||||
|
return thisState == State.USERNAME || thisState == State.ENCRYPT || thisState == State.FINISHED;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connected(ChannelWrapper channel) throws Exception
|
public void connected(ChannelWrapper channel) throws Exception
|
||||||
{
|
{
|
||||||
@ -126,8 +131,14 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exception(Throwable t) throws Exception
|
public void exception(Throwable t) throws Exception
|
||||||
|
{
|
||||||
|
if ( canSendKickMessage() )
|
||||||
{
|
{
|
||||||
disconnect( ChatColor.RED + Util.exception( t ) );
|
disconnect( ChatColor.RED + Util.exception( t ) );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
ch.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -557,14 +568,20 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect(String reason)
|
public void disconnect(String reason)
|
||||||
|
{
|
||||||
|
if ( canSendKickMessage() )
|
||||||
{
|
{
|
||||||
disconnect( TextComponent.fromLegacyText( reason ) );
|
disconnect( TextComponent.fromLegacyText( reason ) );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
ch.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect(final BaseComponent... reason)
|
public void disconnect(final BaseComponent... reason)
|
||||||
{
|
{
|
||||||
if ( thisState != State.STATUS && thisState != State.PING && thisState != State.HANDSHAKE )
|
if ( canSendKickMessage() )
|
||||||
{
|
{
|
||||||
ch.delayedClose( new Kick( ComponentSerializer.toString( reason ) ) );
|
ch.delayedClose( new Kick( ComponentSerializer.toString( reason ) ) );
|
||||||
} else
|
} else
|
||||||
|
Loading…
Reference in New Issue
Block a user