Solved SkullMeta not working

Discussion in 'Spigot Plugin Development' started by Lorenzo0111, Jun 14, 2021.

Thread Status:
Not open for further replies.
  1. I'm quite sure that it is a bug but before reporting it I prefear asking here.
    I can't create a skull with an owning player.
    When I try to create a skull with the classic method and I try to apply a skull owner for the texture it does not give any error but it gives me a steve head.

    Code (Java):

    ItemStack item = new ItemStack(Material.PLAYER_HEAD);
    SkullMeta meta = (SkullMeta) item.getItemMeta();
    meta.setOwningPlayer(Bukkit.getOfflinePlayer("MHF_Chest"));
    item.setItemMeta(meta);
    player.getInventory().addItem(item);
     
    If I use this code in 1.16.x it works fine, but if I use it in 1.17 it does not work.
    If I try to edit it after given it works.
    /version result
     
    • Agree Agree x 1
  2. I think this only works if the player already joined the server at least once
     
  3. And why is it working if I try to edit the head?
     
  4. No idea what you mean by „editing the head“
     
  5. Getting the item in the players’ hand and replacing its meta
     
  6. That‘s strange, try to print the owning player after giving the head to the player
     
  7. When I give it is correct.
    If immediately after giving it I get the meta of the item in hand it is null
     
  8. So the method to add items resets the meta (?)
     
  9. Oh well you already did xD I am just (not) in time.
     
Thread Status:
Not open for further replies.