Hold player for ServerSwitchEvent - see #539

This commit is contained in:
md_5 2013-08-04 21:25:04 +10:00
parent f07cfe0cf7
commit c4d60a8fa9

View File

@ -104,6 +104,17 @@ public class ServerConnector extends PacketHandler
{ {
Preconditions.checkState( thisState == State.LOGIN, "Not exepcting LOGIN" ); Preconditions.checkState( thisState == State.LOGIN, "Not exepcting LOGIN" );
synchronized ( user.getSwitchMutex() )
{
if ( user.getServer() != null )
{
user.sendDimensionSwitch();
// Remove from old servers
user.getServer().setObsolete( true );
user.getServer().disconnect( "Quitting" );
}
}
final ServerConnection server = new ServerConnection( ch, target ); final ServerConnection server = new ServerConnection( ch, target );
Callback<ServerConnectedEvent> callback = new Callback<ServerConnectedEvent>() Callback<ServerConnectedEvent> callback = new Callback<ServerConnectedEvent>()
{ {
@ -177,14 +188,8 @@ public class ServerConnector extends PacketHandler
} }
serverScoreboard.clear(); serverScoreboard.clear();
user.sendDimensionSwitch();
user.setServerEntityId( login.getEntityId() ); user.setServerEntityId( login.getEntityId() );
user.unsafe().sendPacket( new Packet9Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), (short) 256, login.getLevelType() ) ); user.unsafe().sendPacket( new Packet9Respawn( login.getDimension(), login.getDifficulty(), login.getGameMode(), (short) 256, login.getLevelType() ) );
// Remove from old servers
user.getServer().setObsolete( true );
user.getServer().disconnect( "Quitting" );
} }
// TODO: Fix this? // TODO: Fix this?