Search in sources :

Example 91 with BukkitRunnable

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

the class ChickenHandler method dropEggs.

// Egg drop chance is based on the underlying timer
public void dropEggs() {
    ItemStack eggStack = new ItemStack(Material.EGG, 1);
    ItemMeta eggMeta = eggStack.getItemMeta();
    eggMeta.setLore(lore);
    eggStack.setItemMeta(eggMeta);
    Iterator<LivingEntity> superChickenIterator = EntityTracker.getSuperMobs().iterator();
    while (superChickenIterator.hasNext()) {
        LivingEntity chicken = superChickenIterator.next();
        if (!(chicken instanceof Chicken))
            continue;
        if (chicken == null || !chicken.isValid()) {
            superChickenIterator.remove();
        } else {
            Item droppedItem = chicken.getWorld().dropItem(chicken.getLocation(), eggStack);
            droppedItem.setVelocity(ItemDropVelocity.ItemDropVelocity());
            new BukkitRunnable() {

                @Override
                public void run() {
                    if (droppedItem.isValid()) {
                        droppedItem.remove();
                    }
                }
            }.runTaskLater(MetadataHandler.PLUGIN, 20 * 60);
        }
    }
}
Also used : BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 92 with BukkitRunnable

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

the class PopupDisplay method weakArmorStandCreator.

private void weakArmorStandCreator(EliteEntity eliteEntity, Player player, Material material) {
    if (!eliteEntity.isValid() || !player.isValid() || !eliteEntity.getLocation().getWorld().equals(player.getWorld()))
        return;
    ArmorStand[] armorStands = new ArmorStand[2];
    armorStands[0] = generateWeakArmorStand(player, eliteEntity, material, -1);
    armorStands[1] = generateWeakArmorStand(player, eliteEntity, material, 1);
    new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            if (counter > 10 || !eliteEntity.isValid() || !player.isValid() || !eliteEntity.getLocation().getWorld().equals(player.getWorld())) {
                EntityTracker.unregister(armorStands[0], RemovalReason.EFFECT_TIMEOUT);
                EntityTracker.unregister(armorStands[1], RemovalReason.EFFECT_TIMEOUT);
                cancel();
                return;
            }
            for (ArmorStand armorStand : armorStands) armorStand.teleport(armorStand.getLocation().add(eliteEntity.getLocation().add(new Vector(0, 0, 0)).subtract(armorStand.getLocation()).toVector().normalize().multiply(.4)));
            counter++;
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 1, 1);
}
Also used : DialogArmorStand(com.magmaguy.elitemobs.utils.DialogArmorStand) VisualArmorStand(com.magmaguy.elitemobs.utils.VisualArmorStand) ArmorStand(org.bukkit.entity.ArmorStand) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Vector(org.bukkit.util.Vector)

Example 93 with BukkitRunnable

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

the class EnderDragonTornado method doPower.

private void doPower(EliteEntity eliteEntity) {
    doCooldown(eliteEntity);
    tornadoEye = eliteEntity.getLivingEntity().getLocation().clone().add(new Vector(6, -6, 0)).toVector().rotateAroundY(ThreadLocalRandom.current().nextDouble(0, 2 * Math.PI)).toLocation(eliteEntity.getLivingEntity().getWorld());
    tornadoSpeed = tornadoEye.clone().subtract(eliteEntity.getLivingEntity().getLocation()).toVector().setY(0).normalize().multiply(0.2);
    new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            if (!eliteEntity.isValid()) {
                cancel();
                return;
            }
            if (eliteEntity.getLivingEntity().getType().equals(EntityType.ENDER_DRAGON))
                ((EnderDragon) eliteEntity.getLivingEntity()).setPhase(EnderDragon.Phase.SEARCH_FOR_BREATH_ATTACK_TARGET);
            if (doExit(eliteEntity) || eliteEntity.getLivingEntity().getType().equals(EntityType.ENDER_DRAGON) && !EnderDragonPhaseSimplifier.isLanded(((EnderDragon) eliteEntity.getLivingEntity()).getPhase())) {
                cancel();
                return;
            }
            tornadoEye.add(tornadoSpeed);
            if (counter % 2 == 0) {
                doTornadoParticles();
                doTerrainDestruction(eliteEntity);
                doEntityDisplacement(eliteEntity.getLivingEntity());
            }
            if (counter > 20 * 6) {
                cancel();
            }
            counter++;
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
Also used : EnderDragon(org.bukkit.entity.EnderDragon) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Vector(org.bukkit.util.Vector)

Example 94 with BukkitRunnable

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

the class SkeletonPillar method playPillarSong.

private void playPillarSong(Location location) {
    soundLocation = location;
    new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            counter++;
            switch(counter) {
                case 1:
                    playSound(d());
                    break;
                case 2:
                    playSound(d());
                    break;
                case 4:
                    playSound(eHigher());
                    break;
                case 7:
                    playSound(aHigher());
                    break;
                case 10:
                    playSound(aSharpHigher());
                    break;
                case 12:
                    playSound(gHigher());
                    break;
                case 14:
                    playSound(f());
                    break;
                case 16:
                    playSound(f());
                    break;
                case 17:
                    playSound(d());
                    break;
                case 18:
                    playSound(f());
                    break;
                case 19:
                    playSound(gHigher());
                    break;
                case 21:
                    playSound(c());
                    break;
                case 22:
                    playSound(c());
                    break;
                case 24:
                    playSound(eHigher());
                    break;
                case 27:
                    playSound(aHigher());
                    break;
                case 30:
                    playSound(aSharpHigher());
                    break;
                case 32:
                    playSound(gHigher());
                    break;
                case 34:
                    playSound(f());
                    break;
                case 36:
                    playSound(f());
                    break;
                case 37:
                    playSound(d());
                    break;
                case 38:
                    playSound(f());
                    break;
                case 39:
                    playSound(gHigher());
                    break;
                case 41:
                    playSound(b());
                    break;
                case 42:
                    playSound(b());
                    break;
                case 44:
                    playSound(eHigher());
                    break;
                case 47:
                    playSound(aHigher());
                    break;
                case 50:
                    playSound(aSharpHigher());
                    break;
                case 52:
                    playSound(gHigher());
                    break;
                case 54:
                    playSound(f());
                    break;
                case 56:
                    playSound(f());
                    break;
                case 57:
                    playSound(d());
                    break;
                case 58:
                    playSound(f());
                    break;
                case 59:
                    playSound(gHigher());
                    break;
                case 61:
                    playSound(aSharp());
                    break;
                case 62:
                    playSound(aSharp());
                    break;
                case 64:
                    playSound(eHigher());
                    break;
                case 67:
                    playSound(aHigher());
                    break;
                case 70:
                    playSound(aSharpHigher());
                    break;
                case 72:
                    playSound(gHigher());
                    break;
                case 74:
                    playSound(f());
                    break;
                case 76:
                    playSound(f());
                    break;
                case 77:
                    playSound(d());
                    break;
                case 78:
                    playSound(f());
                    break;
                case 79:
                    playSound(gHigher());
                    break;
                case 80:
                    cancel();
                    break;
                default:
                    break;
            }
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 1, 2);
}
Also used : BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Example 95 with BukkitRunnable

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

the class SkeletonPillar method onHit.

@EventHandler
public void onHit(EliteMobDamagedByPlayerEvent event) {
    SkeletonPillar skeletonPillar = (SkeletonPillar) event.getEliteMobEntity().getPower(this);
    if (skeletonPillar == null)
        return;
    if (skeletonPillar.isInGlobalCooldown())
        return;
    /*
        Run random check to see if the power should activate
         */
    if (ThreadLocalRandom.current().nextDouble() > 0.20)
        return;
    skeletonPillar.doGlobalCooldown(20 * 27);
    event.getEliteMobEntity().getLivingEntity().setAI(false);
    playPillarSong(event.getEntity().getLocation());
    Location location1 = event.getEliteMobEntity().getLivingEntity().getLocation().clone().add(locationMover(event.getEliteMobEntity().getLivingEntity().getLocation().clone(), 20, 7));
    Location location2 = event.getEliteMobEntity().getLivingEntity().getLocation().clone().add(locationMover(event.getEliteMobEntity().getLivingEntity().getLocation().clone(), 20, -7));
    new BukkitRunnable() {

        int timer = 1;

        @Override
        public void run() {
            if (timer > 20 * 7 || !event.getEliteMobEntity().isValid()) {
                if (event.getEliteMobEntity().getLivingEntity() != null)
                    event.getEliteMobEntity().getLivingEntity().setAI(true);
                cancel();
            } else if (timer > 20 * 1 && timer < 20 * 7) {
                pillarEffect(event.getEliteMobEntity().getLivingEntity().getLocation().clone(), timer, 7);
                pillarEffect(event.getEliteMobEntity().getLivingEntity().getLocation().clone(), timer, -7);
            } else {
                pillarWarningEffect(location1);
                pillarWarningEffect(location2);
            }
            timer++;
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
Also used : BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

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