Fix ProxiedPlayer.connect from plugins.

This commit is contained in:
md_5 2013-02-09 14:19:21 +11:00
parent 1bc4316e0a
commit 1df6fdf973
2 changed files with 15 additions and 2 deletions

View File

@ -132,7 +132,7 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo
UserConnection userCon = new UserConnection(socket, this, in, out, handshake); UserConnection userCon = new UserConnection(socket, this, in, out, handshake);
String server = ProxyServer.getInstance().getReconnectHandler().getServer(userCon); String server = ProxyServer.getInstance().getReconnectHandler().getServer(userCon);
ServerInfo s = BungeeCord.getInstance().config.getServers().get(server); ServerInfo s = BungeeCord.getInstance().config.getServers().get(server);
userCon.connect(s); userCon.connect(s, true);
thisState = State.FINISHED; thisState = State.FINISHED;
} }

View File

@ -51,6 +51,8 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
private final Collection<String> groups = new HashSet<>(); private final Collection<String> groups = new HashSet<>();
private final Map<String, Boolean> permissions = new HashMap<>(); private final Map<String, Boolean> permissions = new HashMap<>();
private final Object permMutex = new Object(); 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) public UserConnection(Socket socket, PendingConnection pendingConnection, PacketInputStream in, OutputStream out, Packet2Handshake handshake)
{ {
@ -77,6 +79,11 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
@Override @Override
public void connect(ServerInfo target) public void connect(ServerInfo target)
{
nextServer = target;
}
public void connect(ServerInfo target, boolean force)
{ {
if (server == null) if (server == null)
{ {
@ -415,7 +422,7 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
ServerInfo server = ProxyServer.getInstance().getServerInfo(in.readUTF()); ServerInfo server = ProxyServer.getInstance().getServerInfo(in.readUTF());
if (server != null) if (server != null)
{ {
connect(server); connect(server, true);
break outer; break outer;
} }
} }
@ -501,6 +508,12 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
EntityMap.rewrite(packet, serverEntityId, clientEntityId); EntityMap.rewrite(packet, serverEntityId, clientEntityId);
out.write(packet); out.write(packet);
if (nextServer != null)
{
connect(nextServer, true);
break outer;
}
} }
} catch (Exception ex) } catch (Exception ex)
{ {