mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-23 18:55:22 +01:00
#3438: Fix possible race condition in duplicate player check
This commit is contained in:
parent
df20effacc
commit
f5157f12a4
@ -753,7 +753,7 @@ public class BungeeCord extends ProxyServer
|
||||
}
|
||||
}
|
||||
|
||||
public void addConnection(UserConnection con)
|
||||
public boolean addConnection(UserConnection con)
|
||||
{
|
||||
UUID offlineId = con.getPendingConnection().getOfflineId();
|
||||
if ( offlineId != null && offlineId.version() != 3 )
|
||||
@ -763,6 +763,10 @@ public class BungeeCord extends ProxyServer
|
||||
connectionLock.writeLock().lock();
|
||||
try
|
||||
{
|
||||
if ( connections.containsKey( con.getName() ) || connectionsByUUID.containsKey( con.getUniqueId() ) || connectionsByOfflineUUID.containsKey( offlineId ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
connections.put( con.getName(), con );
|
||||
connectionsByUUID.put( con.getUniqueId(), con );
|
||||
connectionsByOfflineUUID.put( offlineId, con );
|
||||
@ -770,6 +774,7 @@ public class BungeeCord extends ProxyServer
|
||||
{
|
||||
connectionLock.writeLock().unlock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void removeConnection(UserConnection con)
|
||||
|
@ -153,7 +153,7 @@ public final class UserConnection implements ProxiedPlayer
|
||||
}
|
||||
};
|
||||
|
||||
public void init()
|
||||
public boolean init()
|
||||
{
|
||||
this.entityRewrite = EntityMap.getEntityMap( getPendingConnection().getVersion() );
|
||||
|
||||
@ -172,6 +172,8 @@ public final class UserConnection implements ProxiedPlayer
|
||||
|
||||
// Set whether the connection has a 1.8 FML marker in the handshake.
|
||||
forgeClientHandler.setFmlTokenInHandshake( this.getPendingConnection().getExtraDataInHandshake().contains( ForgeConstants.FML_HANDSHAKE_TOKEN ) );
|
||||
|
||||
return BungeeCord.getInstance().addConnection( this );
|
||||
}
|
||||
|
||||
public void sendPacket(PacketWrapper packet)
|
||||
|
@ -613,7 +613,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
||||
|
||||
private void finish2()
|
||||
{
|
||||
userCon.init();
|
||||
if ( !userCon.init() )
|
||||
{
|
||||
disconnect( bungee.getTranslation( "already_connected_proxy" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
||||
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
|
||||
|
@ -54,7 +54,6 @@ public class UpstreamBridge extends PacketHandler
|
||||
this.bungee = bungee;
|
||||
this.con = con;
|
||||
|
||||
BungeeCord.getInstance().addConnection( con );
|
||||
con.getTabListHandler().onConnect();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user