Skip to content

Commit

Permalink
Don't sent delayed packet after botfilter in wrong state
Browse files Browse the repository at this point in the history
  • Loading branch information
Leymooo committed Oct 3, 2024
1 parent 3f94dfd commit 6520fd3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion proxy/src/main/java/net/md_5/bungee/ServerConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,14 @@ private void cutThrough(ServerConnection server)

ServerInfo from = ( user.getServer() == null ) ? null : user.getServer().getInfo();
user.setServer( server );
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new DownstreamBridge( bungee, user, server ) );

//BotFilter start
DownstreamBridge downstreamBridge = new DownstreamBridge( bungee, user, server );
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( downstreamBridge );
if (user.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_20_2 ) {
downstreamBridge.flushDelayedMessages();
}
//BotFilter end

bungee.getPluginManager().callEvent( new ServerSwitchEvent( user, from ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ public DownstreamBridge(ProxyServer bungee, UserConnection con, ServerConnection
this.bungee = bungee;
this.con = con;
this.server = server;
}

public void flushDelayedMessages()
{
if ( !con.getDelayedPluginMessages().isEmpty() )
{
for ( PluginMessage msg : con.getDelayedPluginMessages() )
{
server.getCh().write( msg );
server.unsafe().sendPacket( msg );
}
con.getDelayedPluginMessages().clear();
}
Expand Down Expand Up @@ -812,7 +815,7 @@ public void handle(Login login) throws Exception

receivedLogin = true;
ServerConnector.handleLogin( bungee, server.getCh(), con, server.getInfo(), null, server, login );

flushDelayedMessages(); //BotFilter
throw CancelSendSignal.INSTANCE;
}

Expand Down

0 comments on commit 6520fd3

Please sign in to comment.