Advertisement
SweetHeart_

Untitled

Jul 28th, 2021
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. public static ItemStack getSkull(String url) {
  2.         ItemStack head = new ItemStack(Material.PLAYER_HEAD);
  3.         if (url.isEmpty()) {
  4.             return head;
  5.         }
  6.  
  7.         SkullMeta headMeta = (SkullMeta) head.getItemMeta();
  8.         GameProfile profile = new GameProfile(UUID.randomUUID(), null);
  9.         profile.getProperties().put("textures", new Property("textures", url));
  10.         Field profileField;
  11.         try {
  12.             profileField = headMeta.getClass().getDeclaredField("profile");
  13.             profileField.setAccessible(true);
  14.             profileField.set(headMeta, profile);
  15.         } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignored) {
  16.            
  17.         }
  18.         head.setItemMeta(headMeta);
  19.         return head;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement