package com.mojang.authlib;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.GameProfileSerializer;

import com.mojang.authlib.properties.Property;

import com.bergerkiller.generated.com.mojang.authlib.properties.PropertyHandle;
import com.bergerkiller.generated.com.mojang.authlib.GameProfileHandle;

import com.bergerkiller.bukkit.common.nbt.CommonTagCompound;

class GameProfile {
    public (GameProfileHandle) GameProfile(UUID uuid, String name);

    public UUID getId();
    public String getName();

    public void clearProperties() {
        instance.getProperties().clear();
    }

    public Set<String> getPropertyKeys() {
        return instance.getProperties().keySet();
    }

    public (Collection<PropertyHandle>) Collection<Property> getProperties(String key) {
        return instance.getProperties().get(key);
    }

    public boolean putProperty(String key, (PropertyHandle) Property property) {
        return instance.getProperties().put(key, property);
    }

    public void setAllProperties((GameProfileHandle) GameProfile profile) {
        instance.getProperties().clear();
        instance.getProperties().putAll(profile.getProperties());
    }

    <code>
    public static GameProfileHandle getForPlayer(org.bukkit.entity.HumanEntity player) {
        Object handle = com.bergerkiller.bukkit.common.conversion.type.HandleConversion.toEntityHandle(player);
        return com.bergerkiller.generated.net.minecraft.world.entity.player.EntityHumanHandle.T.gameProfile.get(handle);
    }
    </code>

    public (CommonTagCompound) NBTTagCompound serialize() {
#if version >= 1.18
        return GameProfileSerializer.writeGameProfile(new NBTTagCompound(), instance);
#else
        return GameProfileSerializer.serialize(new NBTTagCompound(), instance);
#endif
    }

    public static (GameProfileHandle) GameProfile deserialize((CommonTagCompound) NBTTagCompound data) {
#if version >= 1.18
        return GameProfileSerializer.readGameProfile(data);
#else
        return GameProfileSerializer.deserialize(data);
#endif
    }
}
