#3455: Don't lock connections for offline uuid lookup when given uuid is not offline mode

This commit is contained in:
Janmm14 2023-05-20 03:27:59 +02:00 committed by GitHub
parent 3db27052a1
commit 38028e8e90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -625,12 +625,16 @@ public class BungeeCord extends ProxyServer
}
}
public UserConnection getPlayerByOfflineUUID(UUID name)
public UserConnection getPlayerByOfflineUUID(UUID uuid)
{
if ( uuid.version() != 3 )
{
return null;
}
connectionLock.readLock().lock();
try
{
return connectionsByOfflineUUID.get( name );
return connectionsByOfflineUUID.get( uuid );
} finally
{
connectionLock.readLock().unlock();
@ -751,12 +755,17 @@ public class BungeeCord extends ProxyServer
public void addConnection(UserConnection con)
{
UUID offlineId = con.getPendingConnection().getOfflineId();
if ( offlineId != null && offlineId.version() != 3 )
{
throw new IllegalArgumentException( "Offline UUID must be a name-based UUID" );
}
connectionLock.writeLock().lock();
try
{
connections.put( con.getName(), con );
connectionsByUUID.put( con.getUniqueId(), con );
connectionsByOfflineUUID.put( con.getPendingConnection().getOfflineId(), con );
connectionsByOfflineUUID.put( offlineId, con );
} finally
{
connectionLock.writeLock().unlock();