mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-27 12:46:05 +01:00
Index UUIDs to speed up player queries (#2121)
This commit is contained in:
parent
53cc3242e1
commit
bfab8a1d9c
@ -125,6 +125,7 @@ public class BungeeCord extends ProxyServer
|
||||
private final Map<String, UserConnection> connections = new CaseInsensitiveMap<>();
|
||||
// Used to help with packet rewriting
|
||||
private final Map<UUID, UserConnection> connectionsByOfflineUUID = new HashMap<>();
|
||||
private final Map<UUID, UserConnection> 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
|
||||
|
Loading…
Reference in New Issue
Block a user