Bukkit-ShapedRecipe已弃用

问题描述 投票:0回答:1

我想用自定义配方制作自定义项目。我用2个方法item和customRecipe创建了类。我的课看起来像这样

public class LifeCrystal implements Listener {

    private ItemStack item = new ItemStack(Material.DIAMOND);
    private ItemMeta meta = item.getItemMeta();

    private Plugin plugin = BelieveMe.getPlugin(BelieveMe.class);

    public void Item(Player player){

        meta.setDisplayName(ChatColor.GOLD + "Life Crystal");
        ArrayList<String> lores = new ArrayList<>();
        lores.add("Increase your life points");
        lores.add("...or revive someone");
        meta.setLore(lores);
        item.setItemMeta(meta);


    }
    public void customRecipe(){

        ShapedRecipe r = new ShapedRecipe(item);

        r.shape(" E ", "LAL", "DGD");
        r.setIngredient('E', Material.EMERALD);
        r.setIngredient('L', Material.LAPIS_LAZULI);
        r.setIngredient('A', Material.GOLDEN_APPLE);
        r.setIngredient('D', Material.DIAMOND);
        r.setIngredient('G', Material.GOLD_INGOT);

        plugin.getServer().addRecipe(r);

    }
}

“ new ShapedRecipe(item)”已越过,我的错误消息是“ ShapedRecipe已弃用”。我进行了搜索,找到了有关NamespacedKey的信息。我真的不知道该怎么办

java plugins minecraft bukkit bukkit-vault
1个回答
0
投票

似乎您只需要更改ShapedRecipe对象构造函数(根据JavaDocs)。将其更改为类似:

NamespacedKey nsKey = new NamespacedKey(plugin, "unique_key_here");
ShapedRecipe r = new ShapedRecipe(nsKey, item);

应该使用最新版本(撰写本文时为1.14.4-R0.1-快照)。在链接为here的官方Spigot Wiki上也有一个指南。

快速说明:从研究来看,关键的HAS似乎是按照1.11要求唯一的,因此请确保您所用的东西与任何香草食谱都没有冲突。

© www.soinside.com 2019 - 2024. All rights reserved.