Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class LoginTasksQueue {
private static final MethodHandle INITIAL_CONNECT_SESSION_HANDLER_CONSTRUCTOR;
private static final BiConsumer<Object, MinecraftConnection> MC_CONNECTION_SETTER;
private static final MethodHandle CONNECT_TO_INITIAL_SERVER_METHOD;
private static final MethodHandle SERVER_ID_HASH_GETTER;
private static final MethodHandle SET_CLIENT_BRAND;
public static final BiConsumer<ClientConfigSessionHandler, String> BRAND_CHANNEL_SETTER;

Expand Down Expand Up @@ -211,7 +212,8 @@ private void initialize(MinecraftConnection connection) throws Throwable {
}

Logger logger = LimboAPI.getLogger();
this.server.getEventManager().fire(new LoginEvent(this.player)).thenAcceptAsync(event -> {
String serverIdHash = (String) SERVER_ID_HASH_GETTER.invokeExact((AuthSessionHandler) this.handler);
this.server.getEventManager().fire(new LoginEvent(this.player, serverIdHash)).thenAcceptAsync(event -> {
if (connection.isClosed()) {
// The player was disconnected.
this.server.getEventManager().fireAndForget(new DisconnectEvent(this.player, DisconnectEvent.LoginStatus.CANCELLED_BY_USER_BEFORE_COMPLETE));
Expand Down Expand Up @@ -306,6 +308,9 @@ private void connectToServer(Logger logger, ConnectedPlayer player, MinecraftCon
CONNECT_TO_INITIAL_SERVER_METHOD = MethodHandles.privateLookupIn(AuthSessionHandler.class, MethodHandles.lookup())
.findVirtual(AuthSessionHandler.class, "connectToInitialServer", MethodType.methodType(CompletableFuture.class, ConnectedPlayer.class));

SERVER_ID_HASH_GETTER = MethodHandles.privateLookupIn(AuthSessionHandler.class, MethodHandles.lookup())
.findGetter(AuthSessionHandler.class, "serverIdHash", String.class);

Field mcConnectionField = AuthSessionHandler.class.getDeclaredField("mcConnection");
mcConnectionField.setAccessible(true);
MC_CONNECTION_SETTER = LambdaUtil.setterOf(mcConnectionField);
Expand Down
Loading