2015-06-22 22:20:20 +02:00
|
|
|
package mineplex.game.clans.items.attributes;
|
2015-05-16 18:58:58 +02:00
|
|
|
|
2015-06-03 02:01:42 +02:00
|
|
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
2015-05-05 21:33:42 +02:00
|
|
|
|
|
|
|
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;
|
2015-05-25 20:22:06 +02:00
|
|
|
public int getAttackLimit() { return _attackLimit; }
|
|
|
|
|
2015-05-05 21:33:42 +02:00
|
|
|
private int _attackCount;
|
|
|
|
|
|
|
|
public AttackAttribute(int attackLimit)
|
|
|
|
{
|
|
|
|
_attackLimit = attackLimit;
|
|
|
|
_attackCount = 0;
|
|
|
|
}
|
|
|
|
|
2015-06-03 02:01:42 +02:00
|
|
|
@Override
|
|
|
|
public void onAttack(CustomDamageEvent event)
|
2015-05-05 21:33:42 +02:00
|
|
|
{
|
|
|
|
_attackCount++;
|
2015-06-03 02:01:42 +02:00
|
|
|
System.out.println("Attack count " + _attackCount + " - " + _attackLimit);
|
2015-05-05 21:33:42 +02:00
|
|
|
if (_attackCount >= _attackLimit)
|
|
|
|
{
|
|
|
|
_attackCount = 0;
|
2015-06-03 02:01:42 +02:00
|
|
|
triggerAttack(event.GetDamagerEntity(true), event.GetDamageeEntity());
|
2015-05-05 21:33:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract void triggerAttack(Entity attacker, Entity defender);
|
|
|
|
}
|