ItemStackUtils.java 文件源码

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

项目:Pokecraft 作者:
public static ItemStack getSkullFromURL(String url, String name)
        throws Exception {
    ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
    SkullMeta sm = (SkullMeta) skull.getItemMeta();
    sm.setOwner("NacOJerk");
    skull.setItemMeta(sm);
    url = Base64Coder.encodeString("{textures:{SKIN:{url:\"" + url
            + "\"}}}");
    GameProfile gp = new GameProfile(UUID.randomUUID(), name);
    gp.getProperties().put("textures", new Property("textures", url));
    Object isskull = asNMSCopy(skull);
    Object nbt = getNMS("NBTTagCompound").getConstructor().newInstance();
    Method serialize = getNMS("GameProfileSerializer").getMethod(
            "serialize", getNMS("NBTTagCompound"), GameProfile.class);
    serialize.invoke(null, nbt, gp);
    Object nbtr = isskull.getClass().getMethod("getTag").invoke(isskull);
    nbtr.getClass().getMethod("set", String.class, getNMS("NBTBase"))
            .invoke(nbtr, "SkullOwner", nbt);
    isskull.getClass().getMethod("setTag", getNMS("NBTTagCompound"))
            .invoke(isskull, nbtr);
    skull = asBukkitCopy(isskull);
    return skull;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号