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