Question Playerskull Texture Value

Discussion in 'General Help' started by Ethrian, Dec 11, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Ethrian

    I wanted to make a plugin for a server, which allows you to wear player hats (VIP perks).

    I got the heads from this page.

    Code:
    public static ItemStack createItem(String skinURL, String skullName) {
            ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
            if (skinURL.isEmpty()) return head;
            ItemMeta headMeta = head.getItemMeta();
            headMeta.setDisplayName("§e"+skullName);
            GameProfile profile = new GameProfile(UUID.randomUUID(), null);
            byte[] encodedData = Base64.encodeBase64(String.format("{textures:[{Value:\"%s\"}]}", skinURL).getBytes());
            Bukkit.broadcastMessage(String.format("{textures:[{Value:\"%s\"}]}", skinURL));
            profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
            Field profileField = null;
            try {
                profileField = headMeta.getClass().getDeclaredField("profile");
            } catch (NoSuchFieldException e) {
                e.printStackTrace();
            } catch (SecurityException e) {
                e.printStackTrace();
            }
            profileField.setAccessible(true);
            try {
                profileField.set(headMeta, profile);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            head.setItemMeta(headMeta);
            return head;
        }
    But when I put a texture value, it apears as Alex.

    Can someone help me out with this problem please?
     
  2. Offline

    mcdorli

    1.: Wrong section
    2.: You need to place down the head before you put it in the inventory, then pick the head up
     
Thread Status:
Not open for further replies.

Share This Page