I have a plugin where I made a custom recipe for mending, everything works great, but I can't use this custom crafted book in the anvil. I think it's because of the ItemMeta, I'm relatively clueless and have already googled, but no result. I ask for help and thanks in advance.
ItemStack mending = new ItemStack(Material.ENCHANTED_BOOK, 1);
EnchantmentStorageMeta esm = (EnchantmentStorageMeta)mending.getItemMeta();
esm.addStoredEnchant(Enchantment.MENDING, 1, false);
mending.setItemMeta(esm);
ShapedRecipe mendingRecipe = new ShapedRecipe(mending);
mendingRecipe.shape(new String[]{"ABA", "CDC", "ABA"});
mendingRecipe.setIngredient('A', Material.BOOK);
mendingRecipe.setIngredient('B', Material.DIAMOND_BLOCK);
mendingRecipe.setIngredient('C', Material.EMERALD_BLOCK);
mendingRecipe.setIngredient('D', Material.NETHER_STAR);
Bukkit.getServer().addRecipe(mendingRecipe);
I've already tried to make an extra Anvil recipe but that didn't work.