From 3776feb559f1b79eb47625beef8a29ce75323ed3 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 14 Feb 2015 18:26:27 +1100 Subject: [PATCH] Don't allow duplicate UUIDs on the proxy. --- .../md_5/bungee/connection/InitialHandler.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 12b90b57..e0283ee9 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -325,7 +325,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection } // If offline mode and they are already on, don't allow connect - if ( !isOnlineMode() && bungee.getPlayer( getName() ) != null ) + // We can just check by UUID here as names are based on UUID + if ( !isOnlineMode() && bungee.getPlayer( getUniqueId() ) != null ) { disconnect( bungee.getTranslation( "already_connected" ) ); return; @@ -416,11 +417,19 @@ public class InitialHandler extends PacketHandler implements PendingConnection private void finish() { // Check for multiple connections - ProxiedPlayer old = bungee.getPlayer( getName() ); - if ( old != null ) + // We have to check for the old name first + ProxiedPlayer oldName = bungee.getPlayer( getName() ); + if ( oldName != null ) { // TODO See #1218 - old.disconnect( bungee.getTranslation( "already_connected" ) ); + oldName.disconnect( bungee.getTranslation( "already_connected" ) ); + } + // And then also for their old UUID + ProxiedPlayer oldID = bungee.getPlayer( getUniqueId() ); + if ( oldID != null ) + { + // TODO See #1218 + oldID.disconnect( bungee.getTranslation( "already_connected" ) ); } offlineId = java.util.UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + getName() ).getBytes( Charsets.UTF_8 ) );