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:
Ursprung
22d1398f73
Commit
4e64b04464
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren