Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onArmourEquip(ArmorEquipEvent event) {
- Player player = event.getPlayer();
- ItemStack newItem = event.getNewArmorPiece();
- ItemStack oldItem = event.getOldArmorPiece();
- if (ce.hasEnchantments(oldItem)) {
- for (CEnchantments cEnchantments : ce.getEnchantmentPotions().keySet()) {
- if (ce.hasEnchantment(oldItem, cEnchantments)) {
- if (cEnchantments.isEnabled()) {
- HashMap<PotionEffectType, Integer> effects = ce.getUpdatedEffects(player, new ItemStack(Material.AIR), oldItem, cEnchantments);
- for (PotionEffectType type : effects.keySet()) {
- if (effects.get(type) < 0) {
- player.removePotionEffect(type);
- } else {
- player.removePotionEffect(type);
- player.addPotionEffect(new PotionEffect(type, Integer.MAX_VALUE, effects.get(type)));
- }
- }
- }
- }
- }
- }
- if (ce.hasEnchantments(newItem)) {
- for (CEnchantments cEnchantments : ce.getEnchantmentPotions().keySet()) {
- if (ce.hasEnchantment(newItem, cEnchantments)) {
- if (cEnchantments.isEnabled()) {
- EnchantmentUseEvent enchantmentUseEvent = new EnchantmentUseEvent(player, cEnchantments, newItem);
- Bukkit.getPluginManager().callEvent(enchantmentUseEvent);
- if (!enchantmentUseEvent.isCancelled()) {
- HashMap<PotionEffectType, Integer> effects = ce.getUpdatedEffects(player, newItem, oldItem, cEnchantments);
- for (PotionEffectType type : effects.keySet()) {
- if (effects.get(type) < 0) {
- player.removePotionEffect(type);
- } else {
- player.removePotionEffect(type);
- player.addPotionEffect(new PotionEffect(type, Integer.MAX_VALUE, effects.get(type)));
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement