custom head

Discussion in 'Spigot Plugin Development' started by Karmelek010, Jun 26, 2021.

  1. 1. Dont mark this as a resource if your asking something.
    2. I think your screenshot doesnt load. At least at me I have got no image.
     
  2. As Mxrlin1 said, don't post this as a resource, it is not a developer tool, it is a question. But to answer your question, you need to use the provided base64 encoded string of the skin and apply it to a player skull. I talk about this exact thing in this post. You can find the base64 encoded string for the skin you want under the other section and the value field. For example the base64 encoded string of the skin you want is this:

    eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTZiYzM2NDY3M2MzNGRjMzRhOTU3ODI5MmYzMGFhOWYyZDRiOTQ2ODExNWI4NjEyOWU3Njc4NmNmZjgyOTlkIn19fQ==
     
  3. It's not a screenshot, it is a link to a website with a list of minecraft skins
     
    • Friendly Friendly x 1
  4. i know this shit is considered spoonfeeding but whatever fuck it lol.



    Code (Java):
    public static ItemStack getHead(Player player) {
            int lifePlayer = (int) player.getHealth();
            ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
            SkullMeta skull = (SkullMeta) item.getItemMeta();
            skull.setDisplayName(player.getName());
            ArrayList<String> lore = new ArrayList<String>();
            lore.add("Custom head");
            skull.setLore(lore);
            skull.setOwner(player.getName());
            item.setItemMeta(skull);
            return item;
        }
     
  5. He is asking how to apply a skin to a player skull without a player name. The website he provided does not have player names. So sadly that method would not work.
     
  6. You can use this method
    Code (Text):
    public static ItemStack getSkull(String url) {
           ItemStack item = new ItemStack(Material.PLAYER_HEAD);
            if(url.isEmpty())return item;
     
     
            SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
            GameProfile profile = new GameProfile(UUID.randomUUID(), null);
            byte[] encodedData = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
            profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
            Field profileField = null;
            try
            {
                profileField = itemMeta.getClass().getDeclaredField("profile");
                profileField.setAccessible(true);
                profileField.set(itemMeta, profile);
            }
            catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
            {
                e.printStackTrace();
            }
            item.setItemMeta(itemMeta);
            return item;
        }
     
  7. I already sent a perfectly fine working method in the first reply