Question How to use Custom head with GUI

stefvanschie

Moderator
Staff member
Dec 17, 2021
38
2
6
8
You can do this by creating a skull item like normal and then using the SkullMeta to change the skin of the skull. You can get the SkullMeta by calling ItemStack#getItemMeta() and casting the result to SkullMeta. From there you can use SkullMeta#setPlayerProfile(PlayerProfile) to change the skin displayed on the skull.

To get the right PlayerProfile, you first need to create a PlayerProfile via Bukkit#createProfile or Bukkit#createProfileExact. Then you can change the textures of this PlayerProfile with PlayerProfile#setTextures(PlayerTextures). These PlayerTextures can be retrieved via PlayerProfile#getTextures(). You can then change the skin with PlayerTextures#setSkin(String) where the string is the URL that points to the skin image you want to apply. You can find this URL on the website you mentioned by clicking on the skull you want, scrolling to the bottom, and then copying the link next to "Minecraft-URL".
 
  • Like
Reactions: syuhei

syuhei

New member
Mar 15, 2023
3
0
1
public static ItemStack createHead(URL url){ UUID uuid = UUID.randomUUID(); PlayerProfile profile = Bukkit.createProfile(uuid); profile.setTextures(); ItemStack head = new ItemStack(Material.PLAYER_HEAD); SkullMeta skullMeta = (SkullMeta) head.getItemMeta(); skullMeta.setPlayerProfile(profile); return head; }
I don't know what to put in profile.setTextures();.
Could you please tell me?
 

stefvanschie

Moderator
Staff member
Dec 17, 2021
38
2
6
8
You need to take the result of PlayerProfile#getTextures(). Then modify the skin via PlayerTextures#setSkin(String) and use the PlayerTextures for PlayerProfile#setTextures(PlayerTextures) again.
 
  • Like
Reactions: syuhei