Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Leymooo committed Jun 29, 2024
1 parent 34a098b commit 4819615
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
14 changes: 3 additions & 11 deletions proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -662,23 +662,15 @@ private void finish()
this.userCon = userCon;
userCon.setCompressionThreshold( BungeeCord.getInstance().config.getCompressionThreshold() );

boolean isLoginSuccessSent = false;
boolean needCheck = bungee.getBotFilter().needCheck( this );
//Force send login success, if set in PlayerSetUUIDEvent
if (uuidEvent.getUniqueId() != null || needCheck) {
//TODO: sending login success should be a little different for 1.20.2+ clients. Need to check it
sendLoginSuccess();
isLoginSuccessSent = true;
}


if ( bungee.getBotFilter().needCheck( this ) )
if ( needCheck )
{
bungee.getBotFilter().connectToBotFilter( userCon );
} else
{
bungee.getBotFilter().saveUser( userCon.getName().toLowerCase(), IPUtils.getAddress( userCon ), false ); //update timestamp
finishLoginWithLoginEvent( isLoginSuccessSent ); //if true, dont send again login success
finishLoginWithLoginEvent( false ); //if true, dont send again login success
}

//BotFilter: LoginEvent posting moved to finishLoginWithLoginEvent method
Expand Down Expand Up @@ -773,7 +765,7 @@ public void done(PostLoginEvent result, Throwable error)
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon, initialServer, complete ) );
}

private void sendLoginSuccess()
public void sendLoginSuccess()
{
unsafe.sendPacket( new LoginSuccess( getRewriteId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
}
Expand Down
9 changes: 7 additions & 2 deletions proxy/src/main/java/ru/leymooo/botfilter/BotFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ public void removeUser(String userName)

public void connectToBotFilter(UserConnection userConnection)
{
userConnection.getCh().setEncodeProtocol( Protocol.GAME );
userConnection.getCh().setDecodeProtocol( userConnection.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_20_2 ? Protocol.LOGIN : Protocol.BOTFILTER );

Connector connector = new Connector( userConnection, this );

if ( !addConnection( connector ) )
Expand All @@ -183,6 +182,12 @@ public void connectToBotFilter(UserConnection userConnection)
packetDecompressor.checking = true;
}
userConnection.getCh().getHandle().pipeline().get( HandlerBoss.class ).setHandler( connector );

userConnection.getPendingConnection().sendLoginSuccess();

userConnection.getCh().setEncodeProtocol( Protocol.GAME );
userConnection.getCh().setDecodeProtocol( userConnection.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_20_2 ? Protocol.LOGIN : Protocol.BOTFILTER );

//1.20.2 + will spawn after LoginAcknowledged packet
if (userConnection.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_20_2)
{
Expand Down

0 comments on commit 4819615

Please sign in to comment.