Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- player.getInventory().setItemInHand(getSkull("515dcb2da02cf734829e1e273e3025617d8071516f953251b52545da8d3e8db8"));
- public ItemStack getSkull(String url) {
- ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short)3);
- if(url.isEmpty())return head;
- SkullMeta headMeta = (SkullMeta) head.getItemMeta();
- GameProfile profile = new GameProfile(UUID.randomUUID(), null);
- byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", "http://textures.minecraft.net/texture/"+url).getBytes());
- profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
- Field profileField = null;
- try {
- profileField = headMeta.getClass().getDeclaredField("profile");
- profileField.setAccessible(true);
- profileField.set(headMeta, profile);
- } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
- e1.printStackTrace();
- }
- head.setItemMeta(headMeta);
- return head;
- }
- //pour les skins : http://heads.freshcoal.com/maincollectionlist.php
Advertisement
Add Comment
Please, Sign In to add comment