Search in sources :

Example 16 with CustomBossEntity

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!");
    }
}
Also used : CustomBossesConfigFields(com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) Location(org.bukkit.Location)

Example 17 with CustomBossEntity

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();
    }
}
Also used : GuildRank(com.magmaguy.elitemobs.adventurersguild.GuildRank) Setter(lombok.Setter) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) Getter(lombok.Getter) CustomBossesConfig(com.magmaguy.elitemobs.config.custombosses.CustomBossesConfig) EliteMobs(com.magmaguy.elitemobs.EliteMobs) CustomBossesConfigFields(com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields) DebugMessage(com.magmaguy.elitemobs.utils.DebugMessage) Player(org.bukkit.entity.Player) org.bukkit(org.bukkit) ArrayList(java.util.ArrayList) VersionChecker(com.magmaguy.elitemobs.utils.VersionChecker) PlayerData(com.magmaguy.elitemobs.playerdata.database.PlayerData) Block(org.bukkit.block.Block) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) MetadataHandler(com.magmaguy.elitemobs.MetadataHandler) TimedEvent(com.magmaguy.elitemobs.events.TimedEvent) WorldGuardFlagChecker(com.magmaguy.elitemobs.thirdparty.worldguard.WorldGuardFlagChecker) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CustomSpawnConfig(com.magmaguy.elitemobs.config.customspawns.CustomSpawnConfig) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) Vector(org.bukkit.util.Vector) Objects(java.util.Objects) MoonPhaseDetector(com.magmaguy.elitemobs.events.MoonPhaseDetector) List(java.util.List) CustomSpawnConfigFields(com.magmaguy.elitemobs.config.customspawns.CustomSpawnConfigFields) ValidWorldsConfig(com.magmaguy.elitemobs.config.ValidWorldsConfig) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) DebugMessage(com.magmaguy.elitemobs.utils.DebugMessage)

Example 18 with CustomBossEntity

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);
}
Also used : CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)

Example 19 with CustomBossEntity

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);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.bukkit.entity.Entity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) LivingEntity(org.bukkit.entity.LivingEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) Player(org.bukkit.entity.Player) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) EventHandler(org.bukkit.event.EventHandler)

Example 20 with CustomBossEntity

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());
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) EventHandler(org.bukkit.event.EventHandler)

Aggregations

CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)22 WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)9 CustomBossesConfigFields (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields)5 EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)5 Location (org.bukkit.Location)5 EventHandler (org.bukkit.event.EventHandler)5 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)5 Vector (org.bukkit.util.Vector)5 RegionalBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity)3 ArrayList (java.util.ArrayList)3 Entity (org.bukkit.entity.Entity)3 LivingEntity (org.bukkit.entity.LivingEntity)3 MetadataHandler (com.magmaguy.elitemobs.MetadataHandler)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 TextComponent (net.md_5.bungee.api.chat.TextComponent)2 Player (org.bukkit.entity.Player)2 Wolf (org.bukkit.entity.Wolf)2 PotionEffect (org.bukkit.potion.PotionEffect)2