Resource HeadLib

Discussion in 'BungeeCord Plugin Development' started by Sataniel, Jul 27, 2018.

  1. d81e151275beb86199b2a61d1f896b55a2d6ee99.gif

    HeadLib is a slim public domain util that can contains a few custom player heads. It uses Base64 encoded strings like common custom head web sites like, which cannot be done through the Bukkit API.

    It currently supports 1.8-1.16.1.

    The library currently contains about 300 heads, mainly for inventory GUI purposes (so no Pokémon and shit). A list of them can be found here or in the code. If you'd like to contribute further heads (not necessarily GUI stuff), feel free to make a PR.

    Code (Text):
    // Creating a custom head item stack
    HeadLib.WOODEN_EXCLAMATION_MARK.toItemStack(3, ChatColor.DARK_RED + "Item Display Name", "var", "args", "for", "lore");
    HeadLib.WOODEN_EXCLAMATION_MARK.toItemStack(ChatColor.DARK_RED + "Item Display Name", "var", "args", "for", "lore");

    // Giving an item to a player
    HeadLib.WOODEN_EXCLAMATION_MARK.give(player, 3);
    HeadLib.WOODEN_EXCLAMATION_MARK.give(player, 3, ChatColor.DARK_RED + "Item Display Name", "var", "args", "for", "lore");
    HeadLib.WOODEN_EXCLAMATION_MARK.give(player, ChatColor.DARK_RED + "Item Display Name", "var", "args", "for", "lore");

    // Using a Base64 encoded String to create a head
    String texture = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMmM2NDVhNDI1OTg3ZjNiN2MyZmFjMDIwNmNlOThiYTVlMjNiOWM0ODUyZmVhNWIxOTc4Zjc0NjdlOGQzMTMifX19";
    ItemStack texturedSkull = HeadLib.setSkullOwner(head, player.getUniqueId(), textureValue);
    String textureFromSkull = HeadLib.getTextureValue(head);
    Maven Repository
    Code (Text):
    ~ Regards
    #1 Sataniel, Jul 27, 2018
    Last edited: Jun 30, 2020
    • Like Like x 3
    • Winner Winner x 1
    • Useful Useful x 1
  2. Oh you are an awesome BOI.
    • Friendly Friendly x 1
  3. Update
    • Fixed the tag not being set when using a method without displayName (sorry for that ^^")
    • Added support for color codes in display name & lore lines
    • Added Javadoc comments
  4. What about head search? Gotta implement.
  5. "search"?
  6. Yep, afaik you're using players' UUIDs, so why can't we use mojang api to search for them?

    Also, your NMS in pom.xml is invalid, IDEA says that maven can't resolve its dependency,
  7. It uses texture values.
    Run BuildTools with --rev=1.13.
  8. Ahem, your pom... does not contain a spigot's repo? Seriously?
  9. There's no problem in obtaining them in a runtime.
  10. Dude, it will install NMS locally
  11. There is no repository for Spigot. This depdends on the server jar, not the Spigot API, so you need to run BuildTools.
    That's what it's supposed to do...
    Yeah, and? I'm sorry but I don't really understand what you are getting at.
  12. clip


    Damn bro you really spent the time to create an enum for mapping base64 but u have a lot of work to do as there are thousands and thousands of heads.
  13. It kind of grew over the time ¯\_(ツ)_/¯ It's of course not supposed to be all-embracing... I have personally never used custom heads anywhere but in inventory GUIs. But if at least a few people feel like contributing a dozen or two, it might have the potential to grow really big ^^ I'm curious to see the resonance.
  14. So, you know, there's a Mojang REST API. It has a method of obtaining a texture for the player. Is it that what are heads using?

    AFAIK, the value in enum (1-st argument) is the texture value, but not decoded.
  15. Whether that API is what Minecraft does internally? Probably. The first value is just a UUID. The second one is a Base64 encoded link to the URL of the skin.

    Code (Text):
    is an encoded version of this
    Code (Text):
    And this is where the texture is fetched from. It doesn't match the skin of any player (that's why Bukkit's setOwner() method doesn't help).

    What HeadLib does is nothing more than setting this NBT compound to an ItemStack, the rest is handled by Minecraft internally.
  16. Updated to 1.13.1.
    • Like Like x 1
  17. Updated the resource with multi version support and utility methods to create own custom heads.
  18. Updated to 1.14.
  19. You're awesome. This is going to save me a lot of trouble.
    • Friendly Friendly x 1
  20. This code is bukkit, but the thread is posted inside bungeecord and in 1 year no one saw it? :unsure: