mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-17 06:27:42 +01:00
Add server-id hash to LoginEvent (#1027)
This commit is contained in:
@@ -69,14 +69,16 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
|
||||
private @MonotonicNonNull ConnectedPlayer connectedPlayer;
|
||||
private final boolean onlineMode;
|
||||
private State loginState = State.START; // 1.20.2+
|
||||
private final String serverIdHash;
|
||||
|
||||
AuthSessionHandler(VelocityServer server, LoginInboundConnection inbound,
|
||||
GameProfile profile, boolean onlineMode) {
|
||||
GameProfile profile, boolean onlineMode, String serverIdHash) {
|
||||
this.server = Preconditions.checkNotNull(server, "server");
|
||||
this.inbound = Preconditions.checkNotNull(inbound, "inbound");
|
||||
this.profile = Preconditions.checkNotNull(profile, "profile");
|
||||
this.onlineMode = onlineMode;
|
||||
this.mcConnection = inbound.delegatedConnection();
|
||||
this.serverIdHash = serverIdHash;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,7 +215,7 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
|
||||
private void completeLoginProtocolPhaseAndInitialize(ConnectedPlayer player) {
|
||||
mcConnection.setAssociation(player);
|
||||
|
||||
server.getEventManager().fire(new LoginEvent(player)).thenAcceptAsync(event -> {
|
||||
server.getEventManager().fire(new LoginEvent(player, serverIdHash)).thenAcceptAsync(event -> {
|
||||
if (mcConnection.isClosed()) {
|
||||
// The player was disconnected
|
||||
server.getEventManager().fireAndForget(new DisconnectEvent(player,
|
||||
|
||||
@@ -152,7 +152,7 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
|
||||
} else {
|
||||
mcConnection.setActiveSessionHandler(StateRegistry.LOGIN,
|
||||
new AuthSessionHandler(server, inbound,
|
||||
GameProfile.forOfflinePlayer(login.getUsername()), false));
|
||||
GameProfile.forOfflinePlayer(login.getUsername()), false, null));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -255,7 +255,7 @@ public class InitialLoginSessionHandler implements MinecraftSessionHandler {
|
||||
}
|
||||
// All went well, initialize the session.
|
||||
mcConnection.setActiveSessionHandler(StateRegistry.LOGIN,
|
||||
new AuthSessionHandler(server, inbound, profile, true));
|
||||
new AuthSessionHandler(server, inbound, profile, true, serverId));
|
||||
} else if (response.statusCode() == 204) {
|
||||
// Apparently an offline-mode user logged onto this online-mode proxy.
|
||||
inbound.disconnect(
|
||||
|
||||
Reference in New Issue
Block a user