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 ServerboundHelloPacket implements Packet<ServerLoginPacketListener> {
    private GameProfile gameProfile;
    
    public ServerboundHelloPacket() {
    }
    
    public ServerboundHelloPacket(final GameProfile gameProfile) {
        this.gameProfile = gameProfile;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.gameProfile = new GameProfile((UUID)null, kv.readUtf(16));
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeUtf(this.gameProfile.getName());
    }
    
    @Override
    public void handle(final ServerLoginPacketListener rn) {
        rn.handleHello(this);
    }
    
    public GameProfile getGameProfile() {
        return this.gameProfile;
    }
}
