Search in sources :

Example 1 with MageTrigger

use of com.elmakers.mine.bukkit.magic.MageTrigger in project MagicPlugin by elBukkit.

the class EntityMageData method tick.

public void tick(Mage mage) {
    List<MageTrigger> intervalTriggers = getTriggers(MageTriggerType.INTERVAL);
    if (intervalTriggers == null)
        return;
    Entity entity = mage.getLivingEntity();
    Creature creature = (entity instanceof Creature) ? (Creature) entity : null;
    if (requiresTarget && (creature == null || creature.getTarget() == null))
        return;
    if (requiresWand != null && entity instanceof LivingEntity) {
        LivingEntity li = (LivingEntity) entity;
        ItemStack itemInHand = li.getEquipment().getItemInMainHand();
        if (itemInHand == null || itemInHand.getType() != requiresWand.getType())
            return;
    }
    for (MageTrigger trigger : intervalTriggers) {
        trigger.execute(mage);
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Creature(org.bukkit.entity.Creature) ItemStack(org.bukkit.inventory.ItemStack) MageTrigger(com.elmakers.mine.bukkit.magic.MageTrigger)

Aggregations

MageTrigger (com.elmakers.mine.bukkit.magic.MageTrigger)1 Creature (org.bukkit.entity.Creature)1 Entity (org.bukkit.entity.Entity)1 LivingEntity (org.bukkit.entity.LivingEntity)1 ItemStack (org.bukkit.inventory.ItemStack)1