From 1df6fdf97398a889b0bce4f21bfa51e4ef5f7bdc Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 9 Feb 2013 14:19:21 +1100 Subject: [PATCH] Fix ProxiedPlayer.connect from plugins. --- .../main/java/net/md_5/bungee/InitialHandler.java | 2 +- .../main/java/net/md_5/bungee/UserConnection.java | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/InitialHandler.java index 6dc0d02f..dd030343 100644 --- a/proxy/src/main/java/net/md_5/bungee/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/InitialHandler.java @@ -132,7 +132,7 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo UserConnection userCon = new UserConnection(socket, this, in, out, handshake); String server = ProxyServer.getInstance().getReconnectHandler().getServer(userCon); ServerInfo s = BungeeCord.getInstance().config.getServers().get(server); - userCon.connect(s); + userCon.connect(s, true); thisState = State.FINISHED; } diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index 6a8b4dd7..fe354479 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -51,6 +51,8 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer private final Collection groups = new HashSet<>(); private final Map permissions = new HashMap<>(); private final Object permMutex = new Object(); + // Hack for connect timings + private ServerInfo nextServer; public UserConnection(Socket socket, PendingConnection pendingConnection, PacketInputStream in, OutputStream out, Packet2Handshake handshake) { @@ -77,6 +79,11 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer @Override public void connect(ServerInfo target) + { + nextServer = target; + } + + public void connect(ServerInfo target, boolean force) { if (server == null) { @@ -415,7 +422,7 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer ServerInfo server = ProxyServer.getInstance().getServerInfo(in.readUTF()); if (server != null) { - connect(server); + connect(server, true); break outer; } } @@ -501,6 +508,12 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer EntityMap.rewrite(packet, serverEntityId, clientEntityId); out.write(packet); + + if (nextServer != null) + { + connect(nextServer, true); + break outer; + } } } catch (Exception ex) {