EnchantmentAPI

EnchantmentAPI

111k Downloads

Adding Enchantment in Code

TimLampen opened this issue ยท 2 comments

commented

I was wondering if there was a way to let the coder to add the custom enchant to an item in the code instead of needing the player to enchant it. What I mean is that the coder can listen to PlayerInteractEvent or something then when he wants to he can do player.getItemInHand().addEnchantment(CustomEnchantment.SOMETHING, 1);

Thanks,
Tim

commented

You could also just add the lore necessary for the plugin to recognize it as a custom enchant
For example:
player.getItemInHand().getItemMeta().getLore().add("\u00A77Lifesteal I");

commented

This isn't possible without doing some hacky modifications to the Bukkit API. You can add custom enchants via CustomEnchantment#addToItem(item, enchantmentLevel).