Search in sources :

Example 41 with LivingEntity

use of org.bukkit.entity.LivingEntity in project MagicPlugin by elBukkit.

the class CureAction method perform.

@Override
public SpellResult perform(CastContext context) {
    Entity entity = context.getTargetEntity();
    if (entity == null || !(entity instanceof LivingEntity)) {
        return SpellResult.NO_TARGET;
    }
    LivingEntity targetEntity = (LivingEntity) entity;
    Collection<PotionEffect> currentEffects = targetEntity.getActivePotionEffects();
    for (PotionEffect effect : currentEffects) {
        if (negativeEffects.contains(effect.getType())) {
            context.registerPotionEffects(targetEntity);
            targetEntity.removePotionEffect(effect.getType());
        }
    }
    return SpellResult.CAST;
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) PotionEffect(org.bukkit.potion.PotionEffect)

Example 42 with LivingEntity

use of org.bukkit.entity.LivingEntity in project MagicPlugin by elBukkit.

the class CaptureAction method perform.

@Override
public SpellResult perform(CastContext context) {
    Entity targetEntity = context.getTargetEntity();
    if (targetEntity instanceof Player) {
        return SpellResult.NO_TARGET;
    }
    if (minHealth >= 0) {
        if (!(targetEntity instanceof LivingEntity)) {
            return SpellResult.NO_TARGET;
        }
        LivingEntity li = (LivingEntity) targetEntity;
        if (li.getHealth() > minHealth) {
            return SpellResult.NO_TARGET;
        }
    }
    String entityTypeString = CompatibilityUtils.getEntityType(targetEntity);
    if (entityTypeString == null) {
        return SpellResult.FAIL;
    }
    Object savedEntity = CompatibilityUtils.getEntityData(targetEntity);
    if (savedEntity == null) {
        return SpellResult.FAIL;
    }
    if (targetEntity instanceof LivingEntity) {
        LivingEntity li = (LivingEntity) targetEntity;
        li.setHealth(li.getMaxHealth());
    }
    targetEntity.remove();
    ItemStack spawnEgg = new ItemStack(Material.MONSTER_EGG);
    String entityName = targetEntity.getCustomName();
    if (entityName != null && !entityName.isEmpty()) {
        ItemMeta meta = spawnEgg.getItemMeta();
        meta.setDisplayName("Spawn " + entityName);
        spawnEgg.setItemMeta(meta);
    }
    spawnEgg = InventoryUtils.makeReal(spawnEgg);
    // Add entity type attribute
    CompatibilityUtils.setMeta(savedEntity, "id", entityTypeString);
    // Remove instance-specific attributes
    CompatibilityUtils.removeMeta(savedEntity, "Pos");
    CompatibilityUtils.removeMeta(savedEntity, "Motion");
    CompatibilityUtils.removeMeta(savedEntity, "Rotation");
    CompatibilityUtils.removeMeta(savedEntity, "FallDistance");
    CompatibilityUtils.removeMeta(savedEntity, "Dimension");
    CompatibilityUtils.removeMeta(savedEntity, "UUID");
    CompatibilityUtils.removeMeta(savedEntity, "PortalCooldown");
    if (!CompatibilityUtils.setMetaNode(spawnEgg, "EntityTag", savedEntity)) {
        return SpellResult.FAIL;
    }
    targetEntity.getWorld().dropItemNaturally(targetEntity.getLocation(), spawnEgg);
    return SpellResult.CAST;
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 43 with LivingEntity

use of org.bukkit.entity.LivingEntity in project Spirits by xNuminousx.

the class Infest method infestEntities.

public void infestEntities(Entity entity) {
    if (new Random().nextInt(effectInt) == 0) {
        if (entity instanceof Player) {
            Player ePlayer = (Player) entity;
            BendingPlayer bEntity = BendingPlayer.getBendingPlayer(ePlayer);
            if (bEntity.hasElement(Element.getElement("DarkSpirit")) && healDarkSpirits) {
                LivingEntity le = (LivingEntity) entity;
                le.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 120, 1));
                ParticleEffect.HEART.display(entity.getLocation().add(0, 2, 0), 0, 0, 0, 0, 1);
            }
        } else if (entity instanceof Monster) {
            LivingEntity le = (LivingEntity) entity;
            le.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 120, 1));
            ParticleEffect.ANGRY_VILLAGER.display(entity.getLocation().add(0, 1, 0), 0, 0, 0, 0, 1);
        } else if (entity instanceof LivingEntity && damageEntities) {
            DamageHandler.damageEntity(entity, damage, this);
            ParticleEffect.PORTAL.display(entity.getLocation().add(0, 1, 0), 0, 0, 0, 1.5F, 5);
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) BendingPlayer(com.projectkorra.projectkorra.BendingPlayer) BendingPlayer(com.projectkorra.projectkorra.BendingPlayer) Player(org.bukkit.entity.Player) Random(java.util.Random) PotionEffect(org.bukkit.potion.PotionEffect) Monster(org.bukkit.entity.Monster)

Example 44 with LivingEntity

use of org.bukkit.entity.LivingEntity in project Spirits by xNuminousx.

the class Shelter method shieldSelf.

public void shieldSelf() {
    if (System.currentTimeMillis() > time + duration) {
        bPlayer.addCooldown(this, selfCooldown);
        remove();
        return;
    } else {
        rotateShield(player.getLocation(), 96, selfShield);
        for (Entity target : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), selfShield)) {
            if (target instanceof LivingEntity && !target.getUniqueId().equals(player.getUniqueId())) {
                Vector vec = target.getLocation().getDirection().normalize().multiply(-selfKnockDis);
                vec.setY(1);
                target.setVelocity(vec);
            }
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Vector(org.bukkit.util.Vector)

Example 45 with LivingEntity

use of org.bukkit.entity.LivingEntity in project Spirits by xNuminousx.

the class Shelter method shieldOther.

public void shieldOther() {
    if (progress) {
        location.add(direction.multiply(1));
        progressBlast(location, 100, 0.04F);
    }
    for (Entity target : GeneralMethods.getEntitiesAroundPoint(location, 2)) {
        if (target instanceof LivingEntity && !target.getUniqueId().equals(player.getUniqueId())) {
            bPlayer.addCooldown(this, othersCooldown);
            if (System.currentTimeMillis() > time + duration) {
                remove();
                return;
            } else {
                this.progress = false;
                location = target.getLocation();
                if (isDamaged) {
                    remove();
                    return;
                }
                for (Entity target2 : GeneralMethods.getEntitiesAroundPoint(location, shieldSize)) {
                    if (target2 instanceof LivingEntity && !target2.getUniqueId().equals(target.getUniqueId()) && !target2.getUniqueId().equals(player.getUniqueId())) {
                        Vector vec = target2.getLocation().getDirection().normalize().multiply(-knockDis);
                        vec.setY(1);
                        target2.setVelocity(vec);
                    }
                }
                rotateShield(location, 100, shieldSize);
            }
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Vector(org.bukkit.util.Vector)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)324 Entity (org.bukkit.entity.Entity)170 Player (org.bukkit.entity.Player)123 Location (org.bukkit.Location)72 EventHandler (org.bukkit.event.EventHandler)64 Vector (org.bukkit.util.Vector)60 ItemStack (org.bukkit.inventory.ItemStack)47 ArrayList (java.util.ArrayList)41 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)37 PotionEffect (org.bukkit.potion.PotionEffect)34 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)30 Block (org.bukkit.block.Block)24 Mage (com.elmakers.mine.bukkit.api.magic.Mage)22 Projectile (org.bukkit.entity.Projectile)20 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)18 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)17 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)16 Target (com.elmakers.mine.bukkit.utility.Target)15 World (org.bukkit.World)14 Creature (org.bukkit.entity.Creature)14