Skip to content

Commit

Permalink
#3695, #3696: Connect player to fallback if backend disconnects silently
Browse files Browse the repository at this point in the history
  • Loading branch information
Outfluencer authored Jun 22, 2024
1 parent df413f6 commit cda4537
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void exception(Throwable t) throws Exception
{
server.setObsolete( true );
con.connectNow( def, ServerConnectEvent.Reason.SERVER_DOWN_REDIRECT );
con.sendMessage( bungee.getTranslation( "server_went_down" ) );
con.sendMessage( bungee.getTranslation( "server_went_down", def.getName() ) );
} else
{
con.disconnect( Util.exception( t ) );
Expand All @@ -120,13 +120,25 @@ public void disconnected(ChannelWrapper channel) throws Exception
bungee.getReconnectHandler().setServer( con );
}

if ( !server.isObsolete() )
ServerDisconnectEvent serverDisconnectEvent = new ServerDisconnectEvent( con, server.getInfo() );
bungee.getPluginManager().callEvent( serverDisconnectEvent );

if ( server.isObsolete() )
{
con.disconnect( bungee.getTranslation( "lost_connection" ) );
// do not perform any actions if the user has already moved
return;
}

ServerDisconnectEvent serverDisconnectEvent = new ServerDisconnectEvent( con, server.getInfo() );
bungee.getPluginManager().callEvent( serverDisconnectEvent );
ServerInfo def = con.updateAndGetNextServer( server.getInfo() );
if ( def != null )
{
server.setObsolete( true );
con.connectNow( def, ServerConnectEvent.Reason.SERVER_DOWN_REDIRECT );
con.sendMessage( bungee.getTranslation( "server_went_down", def.getName() ) );
} else
{
con.disconnect( bungee.getTranslation( "lost_connection" ) );
}
}

@Override
Expand Down

0 comments on commit cda4537

Please sign in to comment.