package nautilus.game.arcade.kit.perks; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import nautilus.game.arcade.kit.Perk; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public class PerkCleave extends Perk { public PerkCleave(double splash) { super("Cleave", new String[] { C.cGray + "Attacks deal " + (int)(100*splash) + "% damage to nearby enemies", }); } @EventHandler(priority = EventPriority.HIGH) public void Skill(CustomDamageEvent event) { if (event.IsCancelled()) return; if (event.GetCause() != DamageCause.ENTITY_ATTACK) return; if (event.GetReason() != null) return; //Damager Player damager = event.GetDamagerPlayer(false); if (damager == null) return; if (!UtilGear.isAxe(damager.getItemInHand())) return; if (!Kit.HasKit(damager)) return; //Damagee LivingEntity damagee = event.GetDamageeEntity(); if (damagee == null) return; //Damage event.AddMod(damager.getName(), GetName(), 0, false); //Splash for (Player other : UtilPlayer.getNearby(damagee.getLocation(), 2.4)) { if (other.equals(damagee)) continue; if (!Manager.CanHurt(damager, other)) continue; //Damage Event Manager.GetDamage().NewDamageEvent(other, damager, null, DamageCause.CUSTOM, event.GetDamageInitial(), true, true, false, damager.getName(), GetName()); } } }