Skip to content
LegameMc edited this page Oct 29, 2021 · 1 revision

Event

PlayerEnchantItemEvent will be called after player enchanting item from the gui

You can simply listen to the event by doing

@EventHandler
public void onPlayerEnchant(PlayerEnchantItemEvent event){
    // The player who enchant the item
    Player player = event.getPlayer();
    ItemStack item = event.getItem();
    // The enchantment that player enchanted into the item
    Enchantment enchantment = event.getEnchantment();
    // The enchantment level player enchanted into the item
    int level = event.getLevel();
    // The cost player paid
    Cost cost = event.getCost();

    double moneyCost = cost.getMoney();
    int levelCost = cost.getLevel();
    int lapisCost = cost.getLapis();
    
    // Your code here..
}