Advertisement
Rukes

Untitled

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