Search in sources :

Example 6 with RegionalBossEntity

use of com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity in project EliteMobs by MagmaGuy.

the class Minidungeon method unloadWorld.

private void unloadWorld(Player player) {
    try {
        for (Player iteratedPlayer : Bukkit.getOnlinePlayers()) if (iteratedPlayer.getWorld().getName().equals(dungeonPackagerConfigFields.getWorldName())) {
            player.sendMessage("[EliteMobs] Failed to unload Minidungeon because at least one player is in the world " + dungeonPackagerConfigFields.getWorldName());
            return;
        }
        for (RegionalBossEntity regionalBossEntity : RegionalBossEntity.getRegionalBossEntitySet()) if (regionalBossEntity.getSpawnLocation().getWorld() == world)
            regionalBossEntity.worldUnload();
        MinidungeonWorldLoader.unloadWorld(this);
        player.sendMessage("Minidugeon " + dungeonPackagerConfigFields.getWorldName() + " has been unloaded! The world is now unloaded. The world is now unloaded and the regional bosses are down.");
        isInstalled = false;
        if (wormholeWorld != null)
            Bukkit.unloadWorld(wormholeWorld, true);
    } catch (Exception exception) {
        player.sendMessage("Warning: Failed to unload the " + dungeonPackagerConfigFields.getWorldName() + " world!");
    }
    regionalBossCount = 0;
}
Also used : Player(org.bukkit.entity.Player) RegionalBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity)

Example 7 with RegionalBossEntity

use of com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity in project EliteMobs by MagmaGuy.

the class DebugScreen method generateEntry.

private static TextComponent generateEntry(CustomBossEntity customBossEntity, String argument, Player player) {
    if (!customBossEntity.getCustomBossesConfigFields().getFilename().contains(argument) && !customBossEntity.getCustomBossesConfigFields().getName().toLowerCase().contains(argument.toLowerCase()))
        return null;
    TextComponent page = new TextComponent();
    page.addExtra(customBossEntity.getCustomBossesConfigFields().getFilename() + "\n");
    page.addExtra("Name: " + ChatColorConverter.convert(customBossEntity.getCustomBossesConfigFields().getName()) + ChatColor.BLACK + "\n");
    page.addExtra("Level: " + customBossEntity.getCustomBossesConfigFields().getLevel() + "\n");
    if (customBossEntity.getLivingEntity() != null) {
        page.addExtra("Is Alive (MC): " + !customBossEntity.getLivingEntity().isDead() + "\n");
        page.addExtra(SpigotMessage.commandHoverMessage(ChatColor.BLUE + "XYZ: " + "\n", customBossEntity.getLocation().getBlockX() + ", " + customBossEntity.getLocation().getBlockY() + ", " + customBossEntity.getLocation().getBlockZ() + "\n" + ChatColor.BLUE + "Click to teleport! (if alive)", "/em debugtp " + customBossEntity.getEliteUUID().toString()));
        page.addExtra("Has AI: " + !customBossEntity.getLivingEntity().hasAI() + "\n");
    } else
        page.addExtra("Is Alive (MC): false\n");
    if (customBossEntity.getLocation() != null && player.getWorld().equals(customBossEntity.getLocation().getWorld()))
        page.addExtra(SpigotMessage.hoverMessage(ChatColor.BLUE + "Spawn distance", "Spawn distance: X=" + (int) (player.getLocation().getX() - customBossEntity.getSpawnLocation().getX()) + " | Y=" + (int) (player.getLocation().getY() - customBossEntity.getSpawnLocation().getY()) + " | Z=" + (int) (player.getLocation().getZ() - customBossEntity.getSpawnLocation().getZ()) + "\n"));
    page.addExtra("Is Persistent: " + customBossEntity.getCustomBossesConfigFields().isPersistent() + "\n");
    if (customBossEntity instanceof RegionalBossEntity) {
        page.addExtra("Is Respawning: " + ((RegionalBossEntity) customBossEntity).isRespawning() + "\n");
    }
    page.addExtra(SpigotMessage.commandHoverMessage(ChatColor.BLUE + "Boss trace!", "Remember, it requires debug mode to be on! This is used for advanced debugging, ask on discord if you want to know more about it.", "/elitemobs trace " + customBossEntity.getEliteUUID().toString()));
    return page;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) RegionalBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity)

Example 8 with RegionalBossEntity

use of com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity 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

RegionalBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity)8 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)4 TextComponent (net.md_5.bungee.api.chat.TextComponent)3 Location (org.bukkit.Location)3 Player (org.bukkit.entity.Player)3 CustomBossesConfigFields (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields)2 EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)2 WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)2 World (org.bukkit.World)2 Vector (org.bukkit.util.Vector)2 ChatColorConverter (com.magmaguy.elitemobs.ChatColorConverter)1 MetadataHandler (com.magmaguy.elitemobs.MetadataHandler)1 NewMinidungeonRelativeBossLocationEvent (com.magmaguy.elitemobs.api.internal.NewMinidungeonRelativeBossLocationEvent)1 RemovalReason (com.magmaguy.elitemobs.api.internal.RemovalReason)1 CustomBossesConfig (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfig)1 CustomTreasureChestConfigFields (com.magmaguy.elitemobs.config.customtreasurechests.CustomTreasureChestConfigFields)1 CustomTreasureChestsConfig (com.magmaguy.elitemobs.config.customtreasurechests.CustomTreasureChestsConfig)1 DungeonPackagerConfigFields (com.magmaguy.elitemobs.config.dungeonpackager.DungeonPackagerConfigFields)1 MinidungeonWorldLoader (com.magmaguy.elitemobs.dungeons.worlds.MinidungeonWorldLoader)1 EntityTracker (com.magmaguy.elitemobs.entitytracker.EntityTracker)1