public static ItemStack getSkull(String url) {
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
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));
try {
Field profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
} catch (IllegalArgumentException | NoSuchFieldException | SecurityException | IllegalAccessException error) {
error.printStackTrace();
}
head.setItemMeta(headMeta);
return head;
}