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

47 lines
1.0 KiB
Java
Raw Normal View History

2013-08-27 17:14:08 +02:00
package nautilus.game.arcade.kit.perks;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.C;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkIronSkin extends Perk
{
2013-11-22 08:40:38 +01:00
private double _reduction;
2013-08-27 17:14:08 +02:00
2013-11-22 08:40:38 +01:00
public PerkIronSkin(double d)
2013-08-27 17:14:08 +02:00
{
super("Iron Skin", new String[]
{
2013-11-22 08:40:38 +01:00
C.cGray + "You take " + d + " less damage from attacks",
2013-08-27 17:14:08 +02:00
});
2013-11-22 08:40:38 +01:00
_reduction = d;
2013-08-27 17:14:08 +02:00
}
@EventHandler(priority = EventPriority.HIGH)
public void DamageDecrease(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetCause() == DamageCause.FIRE_TICK)
return;
2013-11-22 08:40:38 +01:00
if (event.GetDamage() <= 1)
return;
2013-08-27 17:14:08 +02:00
Player damagee = event.GetDamageePlayer();
if (damagee == null) return;
if (!Kit.HasKit(damagee))
return;
event.AddMod(damagee.getName(), GetName(), -_reduction, false);
}
}