Remove enchants from enchanting table?

Discussion in 'Plugin Development' started by KarimAKL, Jul 4, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    KarimAKL

    Is it possible to remove enchants from enchanting table? For now i have this:
    Code:Java
    1.  
    2. @EventHandler
    3. public void onEnchant(EnchantItemEvent e) {
    4. if ((e.getEnchantsToAdd().containsKey(Enchantment.DAMAGE_UNDEAD))) {
    5. e.getEnchantsToAdd().remove(Enchantment.DAMAGE_UNDEAD);
    6. } else if ((e.getEnchantsToAdd().containsKey(Enchantment.DAMAGE_ARTHROPODS))) {
    7. e.getEnchantsToAdd().remove(Enchantment.DAMAGE_ARTHROPODS);
    8. } else if ((e.getEnchantsToAdd().containsKey(Enchantment.PROTECTION_EXPLOSIONS))) {
    9. e.getEnchantsToAdd().remove(Enchantment.PROTECTION_EXPLOSIONS);
    10. }
    11. if (e.getEnchantsToAdd().isEmpty()) {
    12. e.getEnchantsToAdd().put(Enchantment.DURABILITY, 1);
    13. }
    14. }
    15.  

    And it does remove the enchant and add unbreaking if it doesn't have any other enchants but is it possible to remove the display of getting it? If you don't know what i mean then here is a picture of what i mean:
    2018-07-04_19.02.24.png
    I want to make it say the "Unbreaking I...?" instead of "Smite I...?" because you'll get unbreaking instead. Is this possible? Maybe with packets?
     
Thread Status:
Not open for further replies.

Share This Page