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

85 lines
2.0 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.core.common.util.UtilTime;
2014-03-21 01:59:56 +01:00
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;
//Dont allow usage in early game
if (UtilTime.elapsed(Manager.GetGame().GetStateTime(), 30000))
return;
2014-03-21 01:59:56 +01:00
//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(), 3))
2014-03-21 01:59:56 +01:00
{
if (other.equals(damagee))
continue;
2015-03-20 08:43:44 +01:00
if (other.equals(damager))
continue;
2014-03-21 01:59:56 +01:00
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());
}
}
}