Solved Skull not working

Discussion in 'Spigot Plugin Development' started by Aspens, Apr 25, 2017.

  1. hey,
    So i have code that makes a skull and no errors come up when its ran, but, although adding it to inventory and updating inventory, it does not add anything to the players inventory.
    I am 100% sure it is the players inventory because I can send messages to said player and get his name.
    Code (Text):
    ItemStack i = new ItemStack(Material.SKULL, 1);
    SkullMeta s = (SkullMeta) i.getItemMeta();
    s.setDisplayName("Head of a " + ChatColor.LIGHT_PURPLE + e.getEntityType().name().toString());
    s.setOwner("Hood"); // idk if capitalizing the first letter is even necessary. probably not but i did it to be safe i guess lmao
    i.setItemMeta(s);
    k.getInventory().addItem(i);
    k.updateInventory();
    If i set ItemStack to Skull = new skull() it just messes up the rest of my code.
    I have the feeling my initial approach is not correct.
    Thanks in advance.
     
    #1 Aspens, Apr 25, 2017
    Last edited: Apr 25, 2017
  2. I think that's because you are not setting the good Material to your ItemStack.

    Code (Text):
    ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
    This should work.
     
    • Like Like x 1
  3. Aha! my code now works =) Thanks
    I have a question though, what is the 3rd arguement in new ItemStack() for? It says damage for me :p
     
  4. The 3rd argument is the data, for Wool, is the color. ;)

    Code (Text):
    ItemStack coloredWool = new ItemStack(Material.WOOL, 1, (short) 14);
     
    • Like Like x 1