Skip to content

Commit

Permalink
#3742: Add more checks to InitialHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Outfluencer authored Sep 20, 2024
1 parent 9437ced commit acb85e3
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,15 @@ public void handle(PluginMessage pluginMessage) throws Exception
@Override
public void handle(LegacyHandshake legacyHandshake) throws Exception
{
Preconditions.checkState( !this.legacy, "Not expecting LegacyHandshake" );
this.legacy = true;
ch.close( bungee.getTranslation( "outdated_client", bungee.getGameVersion() ) );
}

@Override
public void handle(LegacyPing ping) throws Exception
{
Preconditions.checkState( !this.legacy, "Not expecting LegacyPing" );
this.legacy = true;
final boolean v1_5 = ping.isV1_5();

Expand Down Expand Up @@ -342,7 +344,7 @@ public void handle(PingPacket ping) throws Exception
@Override
public void handle(Handshake handshake) throws Exception
{
Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" );
Preconditions.checkState( thisState == State.HANDSHAKE && !this.legacy, "Not expecting HANDSHAKE" );
this.handshake = handshake;
ch.setVersion( handshake.getProtocolVersion() );
ch.getHandle().pipeline().remove( PipelineUtils.LEGACY_KICKER );
Expand Down Expand Up @@ -420,7 +422,7 @@ public void handle(Handshake handshake) throws Exception
@Override
public void handle(LoginRequest loginRequest) throws Exception
{
Preconditions.checkState( thisState == State.USERNAME, "Not expecting USERNAME" );
Preconditions.checkState( thisState == State.USERNAME && this.loginRequest == null, "Not expecting USERNAME" );

if ( !AllowedCharacters.isValidName( loginRequest.getData(), onlineMode ) )
{
Expand Down

0 comments on commit acb85e3

Please sign in to comment.