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);
byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
Field profileField = null;
try {
profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
e1.printStackTrace();
}
head.setItemMeta(headMeta);
return head;
}
RHead.java 文件源码
java
阅读 17
收藏 0
点赞 0
评论 0
项目:ZentrelaCore
作者:
评论列表
文章目录