Player heads

Discussion in 'Plugin Development' started by iProDev, Apr 5, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    iProDev

    Please go to minecraft and run this command
    Code (Text):
    Code:
    /give @p skull 1 3 {display:{Name:"Candy Cane"},SkullOwner:{Id:"201bdf0f-79ec-444f-a5ec-1a855fcddaf7",Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGNjM2Y3ODFjOTIzYTI4ODdmMTRjMWVlYTExMDUwMTY2OTY2ZjI2MDI1Nzg0MDFmMTQ1MWU2MDk3Yjk3OWRmIn19fQ=="}]}}}
    in a command block, It will give you a head
    I want to get this head in bukkit

    This is my itemstack, I can get from it a head of Notch or any other player, but I cant get the head that the command gives.
    Code (Text):
    Code:
        public ItemStack Head(){
            ItemStack IS = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
            SkullMeta IM = (SkullMeta) IS.getItemMeta();
            IM.setDisplayName("Head");
            IM.setOwner("Head");
            IS.setItemMeta(IM);
            return IS;
        }
    I know I should use NBT Tags
    for know I have tried this but its not working
    Code:
        public ItemStack head(){
            ItemStack is = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
            SkullMeta im = (SkullMeta) is.getItemMeta();
        
            net.minecraft.server.v1_9_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(is);
            NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound();
            NBTTagList modifiers = new NBTTagList();
            NBTTagCompound compound2 = new NBTTagCompound();
            compound2.set("Id", new NBTTagString("201bdf0f-79ec-444f-a5ec-1a855fcddaf7"));
            compound2.set("textures", new NBTTagString("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGNjM2Y3ODFjOTIzYTI4ODdmMTRjMWVlYTExMDUwMTY2OTY2ZjI2MDI1Nzg0MDFmMTQ1MWU2MDk3Yjk3OWRmIn19fQ=="));
            modifiers.add(compound2);
            compound.set("AttributeModifiers", modifiers);
            nmsStack.setTag(compound);
            ItemStack is2 = CraftItemStack.asBukkitCopy(nmsStack);
        
            im.setDisplayName("skull");
            im.setOwner("name");
            is.setItemMeta(im);
            return is2;
        }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Apr 5, 2016
  2. Offline

    0verFull

    @iProDev in the method SkullMeta#setOwner(String arg0); arg0 needs to be the name of the player:

    Exemple:
    IM.setOwner("Notch"); to get the Notch head
     
  3. Offline

    iProDev

    I know that, I dont have the player name, I want to get the same head that the command gives
     
  4. Offline

    mine-care

    @iProDev Please follow Java Naming Conventions
     
  5. Offline

    0verFull

    @iProDev have you tried putting the id as string arguments ?
     
  6. Offline

    mcdorli

    Dispatch that command, place the head somewhere, then save it to a config file
     
    WolfMage1 likes this.
Thread Status:
Not open for further replies.

Share This Page