diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 9fdb4c76b..f31faa995 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -125,6 +125,7 @@ public class BungeeCord extends ProxyServer private final Map connections = new CaseInsensitiveMap<>(); // Used to help with packet rewriting private final Map connectionsByOfflineUUID = new HashMap<>(); + private final Map connectionsByUUID = new HashMap<>(); private final ReadWriteLock connectionLock = new ReentrantReadWriteLock(); /** * Plugin manager. @@ -542,15 +543,7 @@ public class BungeeCord extends ProxyServer connectionLock.readLock().lock(); try { - for ( ProxiedPlayer proxiedPlayer : connections.values() ) - { - if ( proxiedPlayer.getUniqueId().equals( uuid ) ) - { - return proxiedPlayer; - } - } - - return null; + return connectionsByUUID.get( uuid ); } finally { connectionLock.readLock().unlock(); @@ -645,6 +638,7 @@ public class BungeeCord extends ProxyServer try { connections.put( con.getName(), con ); + connectionsByUUID.put( con.getUniqueId(), con ); connectionsByOfflineUUID.put( con.getPendingConnection().getOfflineId(), con ); } finally { @@ -661,6 +655,7 @@ public class BungeeCord extends ProxyServer if ( connections.get( con.getName() ) == con ) { connections.remove( con.getName() ); + connectionsByUUID.remove( con.getUniqueId() ); connectionsByOfflineUUID.remove( con.getPendingConnection().getOfflineId() ); } } finally