[SPIGOT-2918] EnchantItemEvent not called when use custom Offer list? Created: 13/Dec/16  Updated: 15/Dec/16  Resolved: 14/Dec/16

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Porama6400 Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: 1.11


 Description   

EnchantItemEvent is not called when manually add Offers to normally unenchantable item in PrepareItemEnchantEvent



 Comments   
Comment by md_5 [ 15/Dec/16 ]

There is no old api to set offers.

Comment by Porama6400 [ 15/Dec/16 ]

Forget to tell that it's work before with old api

Comment by md_5 [ 14/Dec/16 ]

Honestly this new API is terribly designed and any more bugs and I will remove it.
That being said I have adapted the EnchantItemEvent to always be called and you will have to actually add the enchants yourself then

Comment by Porama6400 [ 14/Dec/16 ]

This is code for prepairing enchant table

@EventHandler
    public void onPrepairItemEnchant(PrepareItemEnchantEvent e) {
        if (isCreeperEgg(e.getItem()) && e.isCancelled() && e.getItem().getEnchantments().size() == 0) {
            e.setCancelled(false);
            e.getOffers()[0] = new EnchantmentOffer(Enchantment.values()[random.nextInt(Enchantment.values().length)], random.nextInt(3) + 1, 30);
            e.getOffers()[1] = new EnchantmentOffer(Enchantment.values()[random.nextInt(Enchantment.values().length)], random.nextInt(3) + 1, 30);
            e.getOffers()[2] = new EnchantmentOffer(Enchantment.values()[random.nextInt(Enchantment.values().length)], random.nextInt(3) + 1, 30);
        }
    }

isCreeperEgg(e.getItem()) : It's just check if item to enchant is creeper spawn egg

Offers are display correctly on enchantment table
but EnchantItemEvent is not called when click on offer

Comment by md_5 [ 14/Dec/16 ]

Is this using the new API or the old one?
Post sample code to reproduce

Comment by Porama6400 [ 14/Dec/16 ]

(I think) Yes

It's working 4 days ago

Comment by md_5 [ 13/Dec/16 ]

Is this a new bug?

Generated at Fri Apr 11 15:30:01 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.