geforkt von Mirrors/Velocity
Avoid duplicate logins.
Dieser Commit ist enthalten in:
Ursprung
22d1398f73
Commit
4e64b04464
@ -118,9 +118,15 @@ public class VelocityServer implements ProxyServer {
|
|||||||
return httpClient;
|
return httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerConnection(ConnectedPlayer connection) {
|
public boolean registerConnection(ConnectedPlayer connection) {
|
||||||
connectionsByName.put(connection.getUsername(), connection);
|
if (connectionsByName.putIfAbsent(connection.getUsername(), connection) != null) {
|
||||||
connectionsByUuid.put(connection.getUniqueId(), connection);
|
return false;
|
||||||
|
}
|
||||||
|
if (connectionsByUuid.putIfAbsent(connection.getUniqueId(), connection) != null) {
|
||||||
|
connectionsByName.remove(connection.getUsername(), connection);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterConnection(ConnectedPlayer connection) {
|
public void unregisterConnection(ConnectedPlayer connection) {
|
||||||
|
@ -136,11 +136,15 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
success.setUuid(profile.idAsUuid());
|
success.setUuid(profile.idAsUuid());
|
||||||
inbound.write(success);
|
inbound.write(success);
|
||||||
|
|
||||||
logger.info("{} has connected", player);
|
|
||||||
inbound.setAssociation(player);
|
inbound.setAssociation(player);
|
||||||
inbound.setState(StateRegistry.PLAY);
|
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));
|
inbound.setSessionHandler(new InitialConnectSessionHandler(player));
|
||||||
VelocityServer.getServer().registerConnection(player);
|
|
||||||
player.createConnectionRequest(toTry.get()).fireAndForget();
|
player.createConnectionRequest(toTry.get()).fireAndForget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren