From 38028e8e903f273f8e89b7c69ff2e254937944e8 Mon Sep 17 00:00:00 2001 From: Janmm14 Date: Sat, 20 May 2023 03:27:59 +0200 Subject: [PATCH] #3455: Don't lock connections for offline uuid lookup when given uuid is not offline mode --- .../src/main/java/net/md_5/bungee/BungeeCord.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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 061ff175..10959ad8 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -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();