1.15.2 Player head itemstack help.

Discussion in 'Spigot Plugin Development' started by gillzs, Jun 19, 2020.

  1. So i was trying to make a chestgui for the punishment part of my plugin and i ran into a problem. I was trying to get the head of the person that is going to be affected by that menu. This is my code:
    Code (Text):
    ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
            ItemMeta playerHeadMeta = playerHead.getItemMeta();
            assert playerHead != null;
            playerHeadMeta.setOwner(accused.getName());
    but since
    Code (Text):
    .setOwner()
    is not a thing anymore i don't really know how to get the texture.
    Any help is welcome.
     
  2. .SetOwningPlayer also does not work. Note that i am using PLAYER_HEAD and not SKULL because SKULL seems to be deprecated. These are the only options i get: https://prnt.sc/t2zttt
     
  3. You need to get SkullMeta instead ItemMeta.

    Code (Java):
    SkullMeta playerHeadMeta = (SkullMeta) playerHead.getItemMeta();
     
    • Agree Agree x 3
  4. Try using a SkullMeta instead of ItemMeta.
    You can try to set the skin for the head using a OfflinePlayer or a base64 skin.
    I'll make you the methode with offline player.

    Code (Text):
            ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
            SkullMeta skMeta = (SkullMeta) playerHead.getItemMeta();
            OfflinePlayer offPl = Bukkit.getOfflinePlayer("someName");
            skMeta.setOwningPlayer(offPl);
            playerHead.setItemMeta(skMeta);
     
    • Agree Agree x 1