package net.minecraft.network.protocol.login;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import java.util.UUID;
import net.minecraft.network.FriendlyByteBuf;
import com.mojang.authlib.GameProfile;
import net.minecraft.network.protocol.Packet;

public class ClientboundGameProfilePacket implements Packet<ClientLoginPacketListener> {
    private GameProfile gameProfile;
    
    public ClientboundGameProfilePacket() {
    }
    
    public ClientboundGameProfilePacket(final GameProfile gameProfile) {
        this.gameProfile = gameProfile;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        final String string3 = kv.readUtf(36);
        final String string4 = kv.readUtf(16);
        final UUID uUID5 = UUID.fromString(string3);
        this.gameProfile = new GameProfile(uUID5, string4);
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        final UUID uUID3 = this.gameProfile.getId();
        kv.writeUtf((uUID3 == null) ? "" : uUID3.toString());
        kv.writeUtf(this.gameProfile.getName());
    }
    
    @Override
    public void handle(final ClientLoginPacketListener rh) {
        rh.handleGameProfile(this);
    }
    
    public GameProfile getGameProfile() {
        return this.gameProfile;
    }
}
