[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. |
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 |
Comment by md_5 [ 14/Dec/16 ] |
Is this using the new API or the old one? |
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? |