Search in sources :

Example 76 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.

the class CustomSummonPower method summonReinforcement.

private void summonReinforcement(EliteEntity eliteEntity, CustomBossReinforcement customBossReinforcement) {
    if (customBossReinforcement.summonChance != null && ThreadLocalRandom.current().nextDouble() > customBossReinforcement.summonChance)
        return;
    for (int i = 0; i < customBossReinforcement.amount; i++) {
        Location spawnLocation = eliteEntity.getLocation();
        if (customBossReinforcement.spawnLocationOffset != null)
            spawnLocation = getFinalSpawnLocation(eliteEntity, customBossReinforcement.spawnLocationOffset);
        if (customBossReinforcement.spawnNearby)
            for (int loc = 0; loc < 30; loc++) {
                Location randomLocation = spawnLocation.clone().add(new Vector(ThreadLocalRandom.current().nextInt(-15, 15), 0, ThreadLocalRandom.current().nextInt(-15, 15)));
                randomLocation.setY(CustomSpawn.getHighestValidBlock(randomLocation, 256));
                if (randomLocation.getY() == -100)
                    continue;
                spawnLocation = randomLocation;
                break;
            }
        if (CustomBossesConfig.getCustomBoss(customBossReinforcement.bossFileName).isRegionalBoss()) {
            RegionalBossEntity regionalBossEntity = RegionalBossEntity.createTemporaryRegionalBossEntity(customBossReinforcement.bossFileName, spawnLocation);
            if (regionalBossEntity == null) {
                new WarningMessage("Failed to spawn reinforcement for " + eliteEntity.getName() + " because boss " + customBossReinforcement.bossFileName + " was invalid! Does the file exist? Is it configured correctly?");
                return;
            }
            if (customBossReinforcement.inheritLevel)
                regionalBossEntity.setLevel(eliteEntity.getLevel());
            if (!customBossReinforcement.summonType.equals(SummonType.ON_DEATH))
                eliteEntity.addReinforcement(regionalBossEntity);
            customBossReinforcement.isSummoned = true;
            regionalBossEntity.setSummoningEntity(eliteEntity);
            regionalBossEntity.initialize();
        } else {
            CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity(customBossReinforcement.bossFileName);
            if (customBossEntity == null) {
                new WarningMessage("Failed to spawn reinforcement for " + eliteEntity.getName() + " because boss " + customBossReinforcement.bossFileName + " was invalid! Does the file exist? Is it configured correctly?");
                return;
            }
            customBossEntity.setSpawnLocation(spawnLocation);
            customBossEntity.setBypassesProtections(eliteEntity.getBypassesProtections());
            if (customBossReinforcement.inheritLevel)
                customBossEntity.setLevel(eliteEntity.getLevel());
            customBossEntity.spawn(false);
            if (customBossEntity.getLivingEntity() != null)
                customBossEntity.getLivingEntity().setVelocity(new Vector(ThreadLocalRandom.current().nextDouble(0.2), 0.2, ThreadLocalRandom.current().nextDouble(0.2)));
            if (!customBossReinforcement.summonType.equals(SummonType.ON_DEATH))
                eliteEntity.addReinforcement(customBossEntity);
            customBossReinforcement.isSummoned = true;
            customBossEntity.setSummoningEntity(eliteEntity);
        }
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) Vector(org.bukkit.util.Vector) RegionalBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity) Location(org.bukkit.Location)

Aggregations

WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)76 InfoMessage (com.magmaguy.elitemobs.utils.InfoMessage)11 Vector (org.bukkit.util.Vector)11 Item (org.bukkit.entity.Item)10 File (java.io.File)9 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)8 FlagConflictException (com.sk89q.worldguard.protection.flags.registry.FlagConflictException)7 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)6 RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)6 ArrayList (java.util.ArrayList)6 ZipFile (com.magmaguy.elitemobs.utils.ZipFile)5 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)5 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)5 Location (org.bukkit.Location)5 ItemStack (org.bukkit.inventory.ItemStack)5 CustomBossesConfigFields (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields)3 Minidungeon (com.magmaguy.elitemobs.dungeons.Minidungeon)3 IOException (java.io.IOException)3 Material (org.bukkit.Material)3 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3