use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class SpawnCommand method spawnCustomBossCommand.
public static void spawnCustomBossCommand(CommandSender commandSender, String fileName, String world, Vector coords, int level) {
try {
Location location = new Location(Bukkit.getWorld(world), coords.getX(), coords.getY(), coords.getZ());
CustomBossesConfigFields customBossesConfigFields = CustomBossesConfig.getCustomBoss(fileName);
if (customBossesConfigFields == null) {
commandSender.sendMessage("Filename " + fileName + " is not valid! Make sure you are writing the name of a configuration file in the custombosses folder!");
return;
}
CustomBossEntity customBossEntity = new CustomBossEntity(customBossesConfigFields);
customBossEntity.setSpawnLocation(location);
customBossEntity.setLevel(level);
customBossEntity.spawn(false);
} catch (Exception e) {
commandSender.sendMessage("[EliteMobs] World argument was not valid!");
}
}
use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class CustomSpawn method generateCustomSpawn.
private void generateCustomSpawn() {
int maxTries = 100;
int tries = 0;
while (tries < maxTries && spawnLocation == null) {
if (!keepTrying)
return;
tries++;
allTries++;
this.spawnLocation = generateRandomSpawnLocation();
if (spawnLocation != null)
break;
}
if (spawnLocation == null) {
if (keepTrying) {
new BukkitRunnable() {
@Override
public void run() {
generateCustomSpawn();
if (timedEvent != null)
new DebugMessage("Failed to spawn " + timedEvent.getCustomEventsConfigFields().getFilename() + " after " + allTries + " tries. Will try again in 1 minute.");
}
}.runTaskLaterAsynchronously(MetadataHandler.PLUGIN, 20 * 60);
} else {
customBossEntities.forEach((customBossEntity -> {
if (customBossEntity.summoningEntity != null)
customBossEntity.summoningEntity.removeReinforcement(customBossEntity);
}));
}
} else {
if (isEvent)
new DebugMessage("Spawned bosses for event after " + allTries + " tries");
spawn();
}
}
use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class CustomKillObjective method checkProgress.
@Override
public void checkProgress(EliteMobDeathEvent event, QuestObjectives questObjectives) {
if (!(event.getEliteEntity() instanceof CustomBossEntity))
return;
CustomBossEntity customBossEntity = (CustomBossEntity) event.getEliteEntity();
String filename = customBossEntity.getCustomBossesConfigFields().getFilename();
if (customBossEntity.getPhaseBossEntity() != null)
filename = customBossEntity.getPhaseBossEntity().getPhase1Config().getFilename();
if (!filename.equals(customBossFilename))
return;
progressObjective(questObjectives);
}
use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity 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.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class ZombieParents method onHit.
@EventHandler
public void onHit(EliteMobDamagedByPlayerEvent event) {
ZombieParents zombieParents = (ZombieParents) event.getEliteMobEntity().getPower(this);
if (zombieParents == null)
return;
if (zombieParents.isFiring())
return;
if (ThreadLocalRandom.current().nextDouble() > 0.01)
return;
zombieParents.setFiring(false);
CustomBossEntity reinforcementMom = CustomBossEntity.createCustomBossEntity("zombie_parents_mom.yml");
try {
reinforcementMom.spawn(event.getEntity().getLocation(), event.getEliteMobEntity().getLevel(), false);
} catch (Exception ex) {
new WarningMessage("Failed to spawn Zombie Parents Mom reinforcement!");
return;
}
CustomBossEntity reinforcementDad = CustomBossEntity.createCustomBossEntity("zombie_parents_dad.yml");
try {
reinforcementDad.spawn(event.getEntity().getLocation(), event.getEliteMobEntity().getLevel(), false);
} catch (Exception ex) {
new WarningMessage("Failed to spawn Zombie Parents Dad reinforcement!");
return;
}
startDialog(reinforcementMom, reinforcementDad, event.getEliteMobEntity());
}
Aggregations