Solved Needing help with giving a player their own head

Discussion in 'Spigot Plugin Help' started by PartyMC, Feb 17, 2020.

  1. I am currently developing a plugin for my server, and I want to give a player certain items when they join. One of them is the player's head. But I can't figure out how to give it to them. This is what I got working so far:

    Code (Text):
            ItemStack ProfileItem = new ItemStack(Material.PLAYER_HEAD, 1);
            ItemMeta ProfileMeta = ProfileItem.getItemMeta();
            ProfileMeta.setDisplayName(Color.color("&e" + p.getName() + " &8>> &7Right click"));
            ProfileItem.setItemMeta(ProfileMeta);
            p.getInventory().setItem(3, ProfileItem);
    I really tried my best and searched alot on the internet, but I can't find how to do it. Could any of you help me?
     
  2. Use skull meta
    ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
    SkullMeta meta = (SkullMeta) skull.getItemMeta();
    meta.setOwningPlayer(player);
    skull.setItemMeta(meta);
    Then just p.getInventory().additem(skull)
     
  3. Thanks alot! It now works!
     
    • Like Like x 1