Search in sources :

Example 26 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class Implosion method onDeath.

@EventHandler
public void onDeath(EliteMobDeathEvent event) {
    if (!event.getEliteEntity().hasPower(this))
        return;
    new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            if (counter < 20)
                for (int i = 0; i < 20; i++) event.getEntity().getLocation().getWorld().spawnParticle(Particle.PORTAL, event.getEntity().getLocation(), 1, 0.1, 0.1, 0.1, 1);
            if (counter > 20 * 3) {
                for (Entity entity : event.getEntity().getWorld().getNearbyEntities(event.getEntity().getLocation(), 10, 10, 10)) if (entity instanceof LivingEntity) {
                    EliteEntity eliteEntity = EntityTracker.getEliteMobEntity(entity);
                    if (eliteEntity instanceof CustomBossEntity) {
                        CustomBossEntity customBossEntity = (CustomBossEntity) eliteEntity;
                        if (customBossEntity.getCustomBossesConfigFields().isFrozen())
                            continue;
                    }
                    if (entity.getType().equals(EntityType.PLAYER) && ((Player) entity).getGameMode().equals(GameMode.SPECTATOR))
                        continue;
                    entity.setVelocity(event.getEliteEntity().getLocation().clone().subtract(entity.getLocation()).toVector().normalize());
                }
                cancel();
            }
            counter++;
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 1, 0);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) LivingEntity(org.bukkit.entity.LivingEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) Player(org.bukkit.entity.Player) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) EventHandler(org.bukkit.event.EventHandler)

Example 27 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class GroundPound method doGroundPound.

public void doGroundPound(EliteEntity eliteEntity) {
    // step 1: make boss go up
    new BukkitRunnable() {

        @Override
        public void run() {
            if (!eliteEntity.isValid()) {
                cancel();
                return;
            }
            eliteEntity.getLivingEntity().setVelocity(new Vector(0, 1.5, 0));
            cloudParticle(eliteEntity.getLivingEntity().getLocation());
        }
    }.runTaskLater(MetadataHandler.PLUGIN, 1);
    // step 2: make boss go down
    new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            if (!eliteEntity.isValid()) {
                cancel();
                return;
            }
            counter++;
            if (!NonSolidBlockTypes.isPassthrough(eliteEntity.getLivingEntity().getLocation().clone().subtract(new Vector(0, 0.2, 0)).getBlock().getType())) {
                eliteEntity.getLivingEntity().setVelocity(new Vector(0, -2, 0));
                cloudParticle(eliteEntity.getLivingEntity().getLocation());
                new BukkitRunnable() {

                    int counter = 0;

                    @Override
                    public void run() {
                        if (counter > 20 * 5 || !eliteEntity.isValid()) {
                            cancel();
                            return;
                        }
                        counter++;
                        if (!eliteEntity.getLivingEntity().isOnGround())
                            return;
                        cancel();
                        landCloudParticle(eliteEntity.getLivingEntity().getLocation());
                        for (Entity entity : eliteEntity.getLivingEntity().getNearbyEntities(10, 10, 10)) {
                            try {
                                entity.setVelocity(entity.getLocation().clone().subtract(eliteEntity.getLivingEntity().getLocation()).toVector().normalize().multiply(2).setY(1.5));
                            } catch (Exception ex) {
                                entity.setVelocity(new Vector(0, 1.5, 0));
                            }
                            if (entity instanceof LivingEntity)
                                ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 3, 2));
                        }
                    }
                }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
                cancel();
                return;
            }
            if (counter > 20 * 5)
                cancel();
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 20, 1);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) LivingEntity(org.bukkit.entity.LivingEntity) PotionEffect(org.bukkit.potion.PotionEffect) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Vector(org.bukkit.util.Vector)

Example 28 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class WorldGuardDungeonFlag method onSpawn.

@EventHandler(ignoreCancelled = true)
public void onSpawn(CreatureSpawnEvent event) {
    if (!EliteMobs.worldGuardIsEnabled)
        return;
    if (event.getEntity().getType().equals(EntityType.ARMOR_STAND) || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CUSTOM))
        return;
    if (WorldGuardFlagChecker.checkFlag(event.getLocation(), WorldGuardCompatibility.getEliteMobsDungeonFlag())) {
        EliteEntity eliteEntity = EntityTracker.getEliteMobEntity(event.getEntity());
        if (eliteEntity instanceof CustomBossEntity)
            return;
        event.setCancelled(true);
        event.getEntity().remove();
    }
}
Also used : EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) EventHandler(org.bukkit.event.EventHandler)

Example 29 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class VisualEffectObfuscator method onTargetPlayer.

@EventHandler
public void onTargetPlayer(EntityTargetLivingEntityEvent event) {
    if (!(event.getTarget() instanceof Player))
        return;
    EliteEntity eliteEntity = EntityTracker.getEliteMobEntity(event.getEntity());
    if (eliteEntity == null)
        return;
    eliteEntity.setVisualEffectObfuscated(false);
}
Also used : Player(org.bukkit.entity.Player) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) EventHandler(org.bukkit.event.EventHandler)

Aggregations

EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)29 Entity (org.bukkit.entity.Entity)16 LivingEntity (org.bukkit.entity.LivingEntity)12 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)10 EventHandler (org.bukkit.event.EventHandler)8 Vector (org.bukkit.util.Vector)8 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)7 Location (org.bukkit.Location)7 Player (org.bukkit.entity.Player)6 ArrayList (java.util.ArrayList)3 Block (org.bukkit.block.Block)3 RegionalBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity)2 ElitePower (com.magmaguy.elitemobs.powers.meta.ElitePower)2 PotionEffect (org.bukkit.potion.PotionEffect)2 ChatColorConverter.convert (com.magmaguy.elitemobs.ChatColorConverter.convert)1 MetadataHandler (com.magmaguy.elitemobs.MetadataHandler)1 EliteExplosionEvent (com.magmaguy.elitemobs.api.EliteExplosionEvent)1 EliteMobDamagedByPlayerEvent (com.magmaguy.elitemobs.api.EliteMobDamagedByPlayerEvent)1 EliteMobExitCombatEvent (com.magmaguy.elitemobs.api.EliteMobExitCombatEvent)1 EliteProjectile (com.magmaguy.elitemobs.combatsystem.EliteProjectile)1