From c4d60a8fa9f31fa418fa62ecd2c005015e7e18b3 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 4 Aug 2013 21:25:04 +1000 Subject: [PATCH] Hold player for ServerSwitchEvent - see #539 --- .../java/net/md_5/bungee/ServerConnector.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index dd7a3e4e..652e9c22 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -104,6 +104,17 @@ public class ServerConnector extends PacketHandler { 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 ); Callback callback = new Callback() { @@ -177,14 +188,8 @@ public class ServerConnector extends PacketHandler } serverScoreboard.clear(); - user.sendDimensionSwitch(); - user.setServerEntityId( login.getEntityId() ); 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?