Properly remove UserConnection from server's list

Previous version did not properly remove a UserConnection from the server's list when they change servers.

This version also prevent duplicates from being placed in a server's list.
This commit is contained in:
KaneFreeman 2013-01-09 23:23:24 -05:00 committed by md_5
parent 90e1bc6dd8
commit addf81f92a

View File

@ -115,6 +115,14 @@ public class UserConnection extends GenericConnection implements CommandSender
} }
reconnecting = false; reconnecting = false;
downBridge = new DownstreamBridge(); downBridge = new DownstreamBridge();
if (server != null)
{
List<UserConnection> conns = BungeeCord.instance.connectionsByServer.get(server.name);
if (conns != null)
{
conns.remove(this);
}
}
server = newServer; server = newServer;
List<UserConnection> conns = BungeeCord.instance.connectionsByServer.get(server.name); List<UserConnection> conns = BungeeCord.instance.connectionsByServer.get(server.name);
if (conns == null) if (conns == null)
@ -122,7 +130,10 @@ public class UserConnection extends GenericConnection implements CommandSender
conns = new ArrayList<>(); conns = new ArrayList<>();
BungeeCord.instance.connectionsByServer.put(server.name, conns); BungeeCord.instance.connectionsByServer.put(server.name, conns);
} }
if (!conns.contains(this))
{
conns.add(this); conns.add(this);
}
downBridge.start(); downBridge.start();
} catch (KickException ex) } catch (KickException ex)
{ {