|
4 | 4 | import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
5 | 5 | import com.mojang.authlib.GameProfile; |
6 | 6 | import com.mojang.authlib.minecraft.MinecraftSessionService; |
| 7 | +import com.mojang.authlib.yggdrasil.ProfileResult; |
7 | 8 | import dev.optimistic.serverauth.ducks.IdOverrideHolder; |
8 | 9 | import dev.optimistic.serverauth.keys.PublicKeyHolder; |
9 | 10 | import dev.optimistic.serverauth.mixin.accessor.ServerboundKeyPacketAccessor; |
|
24 | 25 | import java.nio.ByteBuffer; |
25 | 26 | import java.security.PrivateKey; |
26 | 27 | import java.security.PublicKey; |
| 28 | +import java.util.Set; |
27 | 29 | import java.util.UUID; |
28 | 30 |
|
29 | 31 | @Mixin(ServerLoginPacketListenerImpl.class) |
@@ -78,11 +80,21 @@ public abstract static class AuthenticationThreadMixin { |
78 | 80 | @Final |
79 | 81 | ServerLoginPacketListenerImpl field_14176; |
80 | 82 |
|
81 | | - @WrapOperation(method = "run", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;hasJoinedServer(Lcom/mojang/authlib/GameProfile;Ljava/lang/String;Ljava/net/InetAddress;)Lcom/mojang/authlib/GameProfile;", remap = false)) |
82 | | - private GameProfile run$hasJoinedServer(MinecraftSessionService instance, GameProfile gameProfile, String data, InetAddress inetAddress, Operation<GameProfile> original) { |
| 83 | + @WrapOperation(method = "run", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/minecraft/MinecraftSessionService;hasJoinedServer(Ljava/lang/String;Ljava/lang/String;Ljava/net/InetAddress;)Lcom/mojang/authlib/yggdrasil/ProfileResult;", remap = false)) |
| 84 | + private ProfileResult run$hasJoinedServer(MinecraftSessionService instance, String profileName, String serverId, InetAddress inetAddress, Operation<ProfileResult> original) { |
83 | 85 | UUID id = ((IdOverrideHolder) field_14176).serverauth$getIdOverride(); |
84 | | - if (id == null) return original.call(instance, gameProfile, data, inetAddress); |
85 | | - return new GameProfile(id, gameProfile.getName()); |
| 86 | + if (id == null) return original.call(instance, profileName, serverId, inetAddress); |
| 87 | + |
| 88 | + final GameProfile newProfile = new GameProfile(id, profileName); |
| 89 | + |
| 90 | + // hasJoined request returns signed data, we should too |
| 91 | + final ProfileResult fetchedProfile = instance.fetchProfile(id, true); |
| 92 | + if (fetchedProfile != null) { |
| 93 | + // mojang after not exposing properties in constructor |
| 94 | + newProfile.getProperties().putAll(fetchedProfile.profile().getProperties()); |
| 95 | + } |
| 96 | + |
| 97 | + return new ProfileResult(newProfile, Set.of()); |
86 | 98 | } |
87 | 99 | } |
88 | 100 | } |
0 commit comments