3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-24 15:20:35 +01:00

Avoid duplicate logins.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-08-05 01:30:40 -04:00
Ursprung 22d1398f73
Commit 4e64b04464
2 geänderte Dateien mit 15 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -118,9 +118,15 @@ public class VelocityServer implements ProxyServer {
return httpClient;
}
public void registerConnection(ConnectedPlayer connection) {
connectionsByName.put(connection.getUsername(), connection);
connectionsByUuid.put(connection.getUniqueId(), connection);
public boolean registerConnection(ConnectedPlayer connection) {
if (connectionsByName.putIfAbsent(connection.getUsername(), connection) != null) {
return false;
}
if (connectionsByUuid.putIfAbsent(connection.getUniqueId(), connection) != null) {
connectionsByName.remove(connection.getUsername(), connection);
return false;
}
return true;
}
public void unregisterConnection(ConnectedPlayer connection) {

Datei anzeigen

@ -136,11 +136,15 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
success.setUuid(profile.idAsUuid());
inbound.write(success);
logger.info("{} has connected", player);
inbound.setAssociation(player);
inbound.setState(StateRegistry.PLAY);
if (!VelocityServer.getServer().registerConnection(player)) {
inbound.closeWith(Disconnect.create(TextComponent.of("You are already on this proxy!", TextColor.RED)));
}
logger.info("{} has connected", player);
inbound.setSessionHandler(new InitialConnectSessionHandler(player));
VelocityServer.getServer().registerConnection(player);
player.createConnectionRequest(toTry.get()).fireAndForget();
}
}