Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
voruti committed Dec 1, 2023
1 parent 8423586 commit 20dae3a
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerLoginNetworkHandler;
import one.oktw.interfaces.BungeeClientConnection;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ServerLoginNetworkHandler.class)
public abstract class ServerLoginNetworkHandlerMixin {
Expand All @@ -26,18 +23,19 @@ public abstract class ServerLoginNetworkHandlerMixin {
private GameProfile profile;


@Inject(method = "onHello", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD,
target = "Lnet/minecraft/server/network/ServerLoginNetworkHandler;profile:Lcom/mojang/authlib/GameProfile;",
shift = At.Shift.AFTER))
private void initUuid(CallbackInfo ci) {
@Redirect(method = "onHello", at = @At(value = "INVOKE",
target = "Lnet/minecraft/server/MinecraftServer;getHostProfile()Lcom/mojang/authlib/GameProfile;"))
private GameProfile initUuid(MinecraftServer minecraftServer) {
// override game profile with saved information:
this.profile = new GameProfile(((BungeeClientConnection) connection).getSpoofedUUID(), this.profile.getName());
final GameProfile gameProfile = new GameProfile(((BungeeClientConnection) connection).getSpoofedUUID(), this.profile.getName());

if (((BungeeClientConnection) connection).getSpoofedProfile() != null) {
for (Property property : ((BungeeClientConnection) connection).getSpoofedProfile()) {
this.profile.getProperties().put(property.name(), property);
}
}

return gameProfile;
}

@Redirect(method = "onHello", at = @At(value = "INVOKE",
Expand Down

0 comments on commit 20dae3a

Please sign in to comment.