Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ItemStack getItem(String url, String name, String... lore) {
- ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
- 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) {
- }
- if (name != null) {
- headMeta.setDisplayName(name);
- }
- if (lore != null) {
- headMeta.setLore(Arrays.asList(lore));
- }
- head.setItemMeta(headMeta);
- return head;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement