Search in sources :

Example 86 with BukkitRunnable

use of org.bukkit.scheduler.BukkitRunnable in project EliteMobs by MagmaGuy.

the class GoldExplosion method doGoldExplosion.

private void doGoldExplosion(EliteEntity eliteEntity) {
    eliteEntity.getLivingEntity().setAI(false);
    new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            if (!eliteEntity.isValid()) {
                cancel();
                return;
            }
            counter++;
            if (MobCombatSettingsConfig.isEnableWarningVisualEffects())
                eliteEntity.getLivingEntity().getWorld().spawnParticle(Particle.SMOKE_NORMAL, eliteEntity.getLivingEntity().getLocation(), counter, 1, 1, 1, 0);
            if (counter < 20 * 1.5)
                return;
            cancel();
            eliteEntity.getLivingEntity().setAI(true);
            List<Item> goldNuggets = generateVisualItems(eliteEntity);
            ProjectileDamage.doGoldNuggetDamage(goldNuggets, eliteEntity);
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
Also used : BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ArrayList(java.util.ArrayList) List(java.util.List)

Example 87 with BukkitRunnable

use of org.bukkit.scheduler.BukkitRunnable in project EliteMobs by MagmaGuy.

the class LightningBolts method setLightiningPaths.

private static void setLightiningPaths(EliteEntity eliteEntity) {
    if (eliteEntity.getLivingEntity() == null)
        return;
    eliteEntity.getLivingEntity().setAI(false);
    for (Entity entity : eliteEntity.getLivingEntity().getNearbyEntities(20, 20, 20)) {
        if (entity.getType().equals(EntityType.PLAYER)) {
            Location playerLocationClone = entity.getLocation().clone();
            Location powerLocation = eliteEntity.getLivingEntity().getLocation().clone();
            Vector powerDirection = playerLocationClone.clone().subtract(powerLocation).toVector().normalize();
            int counter = 0;
            while (playerLocationClone.distance(powerLocation) > 0.55) {
                counter++;
                powerLocation.add(powerDirection);
                lightningTask(powerLocation.clone(), counter);
            }
        }
    }
    new BukkitRunnable() {

        @Override
        public void run() {
            if (eliteEntity != null && eliteEntity.getLivingEntity() != null)
                eliteEntity.getLivingEntity().setAI(true);
        }
    }.runTaskLater(MetadataHandler.PLUGIN, 4L * 20);
}
Also used : Entity(org.bukkit.entity.Entity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 88 with BukkitRunnable

use of org.bukkit.scheduler.BukkitRunnable in project EliteMobs by MagmaGuy.

the class CustomBossTrail method doParticleTrail.

private void doParticleTrail(Particle particle) {
    if (!VersionChecker.serverVersionOlderThan(18, 0) && particle.equals(Particle.BLOCK_MARKER))
        return;
    bukkitTasks.add(new BukkitRunnable() {

        @Override
        public void run() {
            // In case of boss death or chunk unload, stop the effect
            if (!livingEntity.isValid()) {
                cancel();
                return;
            }
            // All conditions cleared, do the boss flair effect
            Location entityCenter = livingEntity.getLocation().clone().add(0, livingEntity.getHeight() / 2, 0);
            livingEntity.getWorld().spawnParticle(particle, entityCenter, 1, 0.1, 0.1, 0.1, 0.05);
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1));
}
Also used : BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Location(org.bukkit.Location)

Example 89 with BukkitRunnable

use of org.bukkit.scheduler.BukkitRunnable in project EliteMobs by MagmaGuy.

the class ChannelHealing method channelHealing.

private void channelHealing(EliteEntity healer, EliteEntity damagedEntity) {
    super.setInCooldown(healer, true);
    healer.getLivingEntity().setAI(false);
    new BukkitRunnable() {

        int timer = 0;

        @Override
        public void run() {
            if (!healer.isValid() || !damagedEntity.isValid() || damagedEntity.getHealth() / damagedEntity.getMaxHealth() > .8 || healer.getLocation().distance(damagedEntity.getLocation()) > 25) {
                cancel();
                setInCooldown(healer, false);
                doCooldown(healer);
                if (healer.isValid())
                    healer.getLivingEntity().setAI(true);
                return;
            }
            if (timer % 10 == 0) {
                double healAmount = healer.getLevel() / 2d;
                damagedEntity.heal(healAmount);
                damagedEntity.getLocation().getWorld().spawnParticle(Particle.TOTEM, damagedEntity.getLocation().add(new Vector(0, 1, 0)), 20, 0.1, 0.1, 0.1);
            }
            Vector toDamaged = damagedEntity.getLocation().add(new Vector(0, 1, 0)).subtract(healer.getLocation().add(new Vector(0, 1, 0))).toVector().normalize().multiply(.5);
            Location rayLocation = healer.getLocation().add(new Vector(0, 1, 0)).add(toDamaged);
            for (int i = 0; i < 55; i++) {
                rayLocation.getWorld().spawnParticle(Particle.TOTEM, rayLocation, 1, toDamaged.getX(), toDamaged.getY(), toDamaged.getZ(), .2D);
                rayLocation.add(toDamaged);
                if (rayLocation.distance(damagedEntity.getLocation()) < 2)
                    break;
            }
            timer++;
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0L, 2L);
}
Also used : BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 90 with BukkitRunnable

use of org.bukkit.scheduler.BukkitRunnable in project EliteMobs by MagmaGuy.

the class FrostCone method startFrostCone.

public static void startFrostCone(EliteEntity eliteEntity, Location damager) {
    if (eliteEntity == null || eliteEntity.getLivingEntity() == null || !eliteEntity.getLivingEntity().isValid())
        return;
    eliteEntity.getLivingEntity().setAI(false);
    new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            counter++;
            // ending phase
            if (counter > 20 * 6 || !isPowerStillValid(eliteEntity, damager)) {
                cancel();
                if (eliteEntity.getLivingEntity() != null && !eliteEntity.getLivingEntity().isDead())
                    eliteEntity.getLivingEntity().setAI(true);
                return;
            }
            // warning phase
            if (counter < 20 * 3) {
                doSmokeEffect(eliteEntity, damager);
                return;
            }
            // firing phase
            for (int i = 0; i < 10; i++) createSnowball(eliteEntity, damager);
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
Also used : BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Aggregations

BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)316 Player (org.bukkit.entity.Player)85 EventHandler (org.bukkit.event.EventHandler)52 Location (org.bukkit.Location)46 Vector (org.bukkit.util.Vector)45 Entity (org.bukkit.entity.Entity)29 ItemStack (org.bukkit.inventory.ItemStack)26 List (java.util.List)25 UUID (java.util.UUID)25 ArrayList (java.util.ArrayList)20 Block (org.bukkit.block.Block)18 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)17 LivingEntity (org.bukkit.entity.LivingEntity)16 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)15 HashMap (java.util.HashMap)12 MyPetFeedEvent (de.Keyle.MyPet.api.event.MyPetFeedEvent)11 Material (org.bukkit.Material)11 EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)10 File (java.io.File)10 PotionEffect (org.bukkit.potion.PotionEffect)10