CardboardBox.java 文件源码

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

项目:StarQuestCode 作者:
public ItemStack unbox() {

        @SuppressWarnings("deprecation")
        ItemStack item = new ItemStack(type, amount, damage);

        // These metas below will never be null because of the if/else during
        // the packing

        ItemFactory factory = Bukkit.getServer().getItemFactory();
        ItemMeta itemMeta = factory.getItemMeta(Material.getMaterial(item.getTypeId()));

        // Should only have one specific item meta at a time
        if ((this.meta != null)) {
            itemMeta = this.meta.unbox();
        }
        if (this.name != null) {
            itemMeta.setDisplayName(this.name);
        }
        if (this.lore != null) {
            itemMeta.setLore(this.lore);
        }
        // Apply item meta
        item.setItemMeta(itemMeta);

        HashMap<Enchantment, Integer> map = new HashMap<Enchantment, Integer>();

        for (CardboardEnchantment cEnchantment : enchants.keySet()) {
            map.put(cEnchantment.unbox(), enchants.get(cEnchantment));
        }

        item.addUnsafeEnchantments(map);

        return item;
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号