Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static ItemStack getSkull(String url) {
- ItemStack head = new ItemStack(Material.PLAYER_HEAD);
- if (url.isEmpty()) {
- return head;
- }
- SkullMeta headMeta = (SkullMeta) head.getItemMeta();
- GameProfile profile = new GameProfile(UUID.randomUUID(), null);
- profile.getProperties().put("textures", new Property("textures", url));
- Field profileField;
- try {
- profileField = headMeta.getClass().getDeclaredField("profile");
- profileField.setAccessible(true);
- profileField.set(headMeta, profile);
- } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignored) {
- }
- head.setItemMeta(headMeta);
- return head;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement