我想用自定义配方制作自定义物品。我用 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 的信息。我真的不知道现在该怎么办