package in.twizmwaz.cardinal.module.modules.rage;

import in.twizmwaz.cardinal.module.Module;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;

public class Rage implements Module{

    @Override
    public void unload() {
        HandlerList.unregisterAll(this);
    }

    @EventHandler
    public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
        if (event.getDamager() instanceof Player) {
            ItemStack item = ((Player) event.getDamager()).getItemInHand();
            if (item != null) {
                if (item.containsEnchantment(Enchantment.DAMAGE_ALL) && item.getEnchantmentLevel(Enchantment.DAMAGE_ALL) > 1) {
                    event.setDamage(1000);
                }
            }
        } else if (event.getDamager() instanceof Arrow) {
            if (((Arrow) event.getDamager()).getShooter() instanceof Player) {
                Player shooter = (Player) ((Arrow) event.getDamager()).getShooter();
                for (ItemStack item : shooter.getInventory()) {
                    if (item != null) {
                        if (item.getType().equals(Material.BOW) && item.containsEnchantment(Enchantment.ARROW_DAMAGE) && item.getEnchantmentLevel(Enchantment.ARROW_DAMAGE) > 1) {
                            event.setDamage(1000);
                        }
                    }
                }
            }
        }
    }
}

@@ -44,16 +44,57 @@
 .rage;%0A%0A
+import in.twizmwaz.cardinal.GameHandler;%0A
 import i
@@ -299,24 +299,63 @@
 entHandler;%0A
+import org.bukkit.event.EventPriority;%0A
 import org.b
@@ -459,27 +459,126 @@
 kit.
-inventory.ItemStack
+event.entity.EntityShootBowEvent;%0Aimport org.bukkit.inventory.ItemStack;%0Aimport org.bukkit.metadata.FixedMetadataValue
 ;%0A%0Ap
@@ -1232,25 +1232,16 @@
     if (
-((Arrow) 
 event.ge
@@ -1254,110 +1254,63 @@
 er()
-).getShooter() instanceof Player) %7B%0A                Player shooter = (Player) ((Arrow)
+.hasMetadata(%22rage%22)) %7B%0A               
  event.
-g
+s
 etDamage
 r())
@@ -1309,24 +1309,13 @@
 mage
-r()).getShooter(
+(1000
 );%0A 
@@ -1321,24 +1321,30 @@
         
+    %7D%0A
         
 for (Ite
@@ -1339,167 +1339,183 @@
     
-for (ItemStack item : shooter.getInventory()) %7B%0A                    if (item != null) %7B%0A                        if (item.getType().equals(Material.BOW) && item
+%7D%0A    %7D%0A%0A    @EventHandler(priority = EventPriority.MONITOR)%0A    public void onEntityBowShoot(EntityShootBowEvent event) %7B%0A        if (event.getBow() != null && event.getBow()
 .con
@@ -1556,28 +1556,38 @@
 _DAMAGE) && 
-item
+event.getBow()
 .getEnchantm
@@ -1644,126 +1644,122 @@
     
-                event.setDamage(1000);%0A                        %7D%0A                    %7D%0A                %7D%0A            %7D
+event.getProjectile().setMetadata(%22rage%22, new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), true));
 %0A   

Use metadata to track "rage arrows", fixes #517