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);
}
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);
}
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));
}
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);
}
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);
}
Aggregations