Search in sources :

Example 6 with net.minecraft.server.v1_11_R1

use of net.minecraft.server.v1_11_R1 in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelper_v1_11_R1 method setSkullSkin.

@Override
public ItemStack setSkullSkin(ItemStack itemStack, PlayerProfile playerProfile) {
    GameProfile gameProfile = new GameProfile(playerProfile.getUniqueId(), playerProfile.getName());
    if (playerProfile.hasTexture()) {
        gameProfile.getProperties().get("textures").clear();
        if (playerProfile.getTextureSignature() != null) {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture(), playerProfile.getTextureSignature()));
        } else {
            gameProfile.getProperties().put("textures", new Property("textures", playerProfile.getTexture()));
        }
    }
    net.minecraft.server.v1_11_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tag = nmsItemStack.hasTag() ? nmsItemStack.getTag() : new NBTTagCompound();
    tag.set("SkullOwner", GameProfileSerializer.serialize(new NBTTagCompound(), gameProfile));
    nmsItemStack.setTag(tag);
    return CraftItemStack.asBukkitCopy(nmsItemStack);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) CompoundTag_v1_11_R1(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1) NBTTagCompound(net.minecraft.server.v1_11_R1.NBTTagCompound) Property(com.mojang.authlib.properties.Property)

Aggregations

CompoundTag_v1_11_R1 (net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1)6 net.minecraft.server.v1_11_R1 (net.minecraft.server.v1_11_R1)4 CraftEntity (org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity)4 UUID (java.util.UUID)3 HashSet (java.util.HashSet)2 Set (java.util.Set)2 NBTTagCompound (net.minecraft.server.v1_11_R1.NBTTagCompound)2 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)2 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)2 GameProfile (com.mojang.authlib.GameProfile)1 Property (com.mojang.authlib.properties.Property)1 Location (org.bukkit.Location)1