Solved Getting the value of a custom head

Discussion in 'Spigot Plugin Development' started by Hello1231, Mar 23, 2020.

  1. So I'm trying to check if two custom heads have the texture, but I can't figure out how to get the value/id of their texture.
    eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNjI4NWRhYmQ3ZTkwNjlmZDBhYWMxYmY2NzU3MGJiMDFiZWJmYWI0ZTRjM2Y3ZmU2YWQwNjNjYWM4M2RlNDllMCJ9fX0=
     
  2. Just like setting the texture but in reverse. (You should find a lot of threads about that)
     
    • Useful Useful x 1
  3. Thanks, that worked. Here's the code if anybody else is looking for it:
    Code (Java):
    public static String getSkullValue(ItemStack head)
        {
            if (head.getType() != Material.PLAYER_HEAD) return null;
            SkullMeta headMeta = (SkullMeta) head.getItemMeta();
            String url = null;
             try
                {
                    Field profileField = headMeta.getClass().getDeclaredField("profile");
                    profileField.setAccessible(true);
                    GameProfile profile = (GameProfile) profileField.get(headMeta);
                    Collection<Property> properties = profile.getProperties().get("textures");
                    for(Property property : properties) {
                        url = property.getValue();
                    }
                }
                catch (IllegalArgumentException|NoSuchFieldException|SecurityException | IllegalAccessException error)
                {
                    error.printStackTrace();
                }
                return url;
            }
     
    • Like Like x 1
    • Friendly Friendly x 1