Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkDamageSet.java
2013-08-29 16:13:05 +10:00

49 lines
1.1 KiB
Java

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.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.core.common.util.C;
import nautilus.game.arcade.kit.Perk;
public class PerkDamageSet extends Perk
{
private double _power;
public PerkDamageSet(double power)
{
super("Damage", new String[]
{
C.cGray + "Melee attacks deal " + (int)power + " Damage.",
});
_power = power;
}
@EventHandler(priority = EventPriority.HIGH)
public void Knockback(CustomDamageEvent event)
{
if (event.GetCause() != DamageCause.ENTITY_ATTACK)
return;
Player damager = event.GetDamagerPlayer(false);
if (damager == null) return;
if (!Kit.HasKit(damager))
return;
if (!Manager.IsAlive(damager))
return;
double mod = _power - event.GetDamageInitial();
if (mod == 0)
return;
event.AddMod(damager.getName(), "Attack", mod, true);
}
}