Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkCleave.java

77 lines
1.8 KiB
Java
Raw Normal View History

2014-03-21 01:59:56 +01:00
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
{
2015-03-20 08:21:56 +01:00
private boolean _axeOnly;
public PerkCleave(double splash, boolean axeOnly)
2014-03-21 01:59:56 +01:00
{
super("Cleave", new String[]
{
C.cGray + "Attacks deal " + (int)(100*splash) + "% damage to nearby enemies",
});
2015-03-20 08:21:56 +01:00
_axeOnly = axeOnly;
2014-03-21 01:59:56 +01:00
}
@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;
2015-03-20 08:21:56 +01:00
if (_axeOnly && !UtilGear.isAxe(damager.getItemInHand()))
return;
if (!UtilGear.isWeapon(damager.getItemInHand()))
2014-03-21 01:59:56 +01:00
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))
2014-03-21 01:59:56 +01:00
continue;
//Damage Event
Manager.GetDamage().NewDamageEvent(other, damager, null,
DamageCause.CUSTOM, event.GetDamageInitial(), true, true, false,
damager.getName(), GetName());
}
}
}