SkullItemBuilder.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:AlphaLibary 作者:
public static ItemStack getCustomSkull(String url) {
    GameProfile profile = SkinChangeUtil.changeSkin(url);

    ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    ItemMeta headMeta = head.getItemMeta();
    Class<?> headMetaClass = headMeta.getClass();

    try {
        Field f = headMetaClass.getDeclaredField("profile");
        f.setAccessible(true);

        f.set(headMeta, profile);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }

    head.setItemMeta(headMeta);
    return head;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号