SHOW:
|
|
- or go back to the newest paste.
| 1 | player.getInventory().setItemInHand(getSkull("515dcb2da02cf734829e1e273e3025617d8071516f953251b52545da8d3e8db8"));
| |
| 2 | ||
| 3 | public ItemStack getSkull(String url) {
| |
| 4 | ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short)3); | |
| 5 | if(url.isEmpty())return head; | |
| 6 | ||
| 7 | ||
| 8 | SkullMeta headMeta = (SkullMeta) head.getItemMeta(); | |
| 9 | GameProfile profile = new GameProfile(UUID.randomUUID(), null); | |
| 10 | byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", "http://textures.minecraft.net/texture/"+url).getBytes());
| |
| 11 | profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
| |
| 12 | Field profileField = null; | |
| 13 | try {
| |
| 14 | profileField = headMeta.getClass().getDeclaredField("profile");
| |
| 15 | profileField.setAccessible(true); | |
| 16 | profileField.set(headMeta, profile); | |
| 17 | } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
| |
| 18 | e1.printStackTrace(); | |
| 19 | } | |
| 20 | head.setItemMeta(headMeta); | |
| 21 | return head; | |
| 22 | } | |
| 23 | ||
| 24 | //pour les skins : http://heads.freshcoal.com/maincollectionlist.php |