37 lines
806 B
Java
37 lines
806 B
Java
package mineplex.game.clans.items.attributes;
|
|
|
|
import org.bukkit.entity.Entity;
|
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
|
|
/**
|
|
* Represents an attribute that triggers a special ability after a specified number
|
|
* of attacks with a weapon possessing the attribute.
|
|
* @author MrTwiggy
|
|
*
|
|
*/
|
|
public abstract class AttackAttribute extends ItemAttribute
|
|
{
|
|
|
|
private int _attackLimit;
|
|
private int _attackCount;
|
|
|
|
public AttackAttribute(int attackLimit)
|
|
{
|
|
_attackLimit = attackLimit;
|
|
_attackCount = 0;
|
|
}
|
|
|
|
public void onAttack(EntityDamageByEntityEvent event)
|
|
{
|
|
_attackCount++;
|
|
|
|
if (_attackCount >= _attackLimit)
|
|
{
|
|
_attackCount = 0;
|
|
triggerAttack(event.getDamager(), event.getEntity());
|
|
}
|
|
}
|
|
|
|
public abstract void triggerAttack(Entity attacker, Entity defender);
|
|
}
|