Search in sources :

Example 11 with CustomBossEntity

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

the class TreasureChest method doMimic.

private void doMimic() {
    HashMap<String, Double> weighedValues = new HashMap<>();
    for (String string : this.customTreasureChestConfigFields.getMimicCustomBossesList()) {
        String filename = string.split(":")[0];
        double weight = 1;
        try {
            weight = Double.valueOf(string.split(":")[1]);
        } catch (Exception ex) {
            weight = 1;
        }
        weighedValues.put(filename, weight);
    }
    CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity(WeightedProbability.pickWeighedProbability(weighedValues));
    customBossEntity.spawn(location, randomizeTier(), false);
}
Also used : HashMap(java.util.HashMap) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)

Example 12 with CustomBossEntity

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

the class TimedEvent method queueEvent.

/**
 * Queues an event to start when the start conditions are met
 */
public void queueEvent() {
    this.primaryEliteMobs = customSpawn.getCustomBossEntities();
    setEventStartLocation(customSpawn.getSpawnLocation());
    for (CustomBossEntity customBossEntity : primaryEliteMobs) if (!customBossEntity.exists()) {
        if (!silentRetry) {
            new InfoMessage("Boss " + customBossEntity.getCustomBossesConfigFields().getFilename() + " for event " + getCustomEventsConfigFields().getFilename() + " wasn't considered to be valid. Trying spawn again .");
            new InfoMessage("Note: further failures will be silent. EliteMobs can only predict WorldGuard protections," + " so it will keep trying to spawn things until plugins preventing spawning allow it to do so. This might take a while.");
            silentRetry = true;
        }
        Bukkit.getScheduler().runTaskLater(MetadataHandler.PLUGIN, () -> {
            customSpawn.setSpawnLocation(null);
            customSpawn.queueSpawn();
        }, 1);
        return;
    }
    primaryEliteMobs.forEach(CustomBossEntity::announceSpawn);
    start();
}
Also used : InfoMessage(com.magmaguy.elitemobs.utils.InfoMessage) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)

Example 13 with CustomBossEntity

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

the class BossTrackingPage method bossTrackingPage.

protected static TextComponent[] bossTrackingPage(Player player) {
    TextComponent configTextComponent = new TextComponent();
    for (int i = 0; i < 3; i++) {
        TextComponent line = new TextComponent(PlayerStatusMenuConfig.getBossTrackerTextLines()[i] + "\n");
        if (!PlayerStatusMenuConfig.getBossTrackerHoverLines()[i].isEmpty())
            PlayerStatusScreen.setHoverText(line, PlayerStatusMenuConfig.getBossTrackerHoverLines()[i]);
        if (!PlayerStatusMenuConfig.getBossTrackerCommandLines()[i].isEmpty())
            line.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, PlayerStatusMenuConfig.getBossTrackerCommandLines()[i]));
        configTextComponent.addExtra(line);
    }
    ArrayList<TextComponent> textComponents = new ArrayList<>();
    int counter = 0;
    for (CustomBossEntity customBossEntity : CustomBossEntity.getTrackableCustomBosses()) {
        try {
            textComponents.add(SpigotMessage.commandHoverMessage(customBossEntity.getCustomBossBossBar().bossBarMessage(player, customBossEntity.getCustomBossesConfigFields().getLocationMessage()) + "\n", PlayerStatusMenuConfig.getOnBossTrackHover(), "/elitemobs trackcustomboss " + customBossEntity.getEliteUUID()));
            counter++;
        } catch (Exception ex) {
            new WarningMessage("Failed to correctly get elements for boss tracking page!");
            ex.printStackTrace();
        }
    }
    TextComponent[] textComponent;
    if (counter == 0) {
        textComponent = new TextComponent[1];
        textComponent[0] = configTextComponent;
    } else {
        textComponent = new TextComponent[(int) Math.floor(counter / 6D) + 1];
        int internalCounter = 0;
        textComponent[0] = configTextComponent;
        for (TextComponent text : textComponents) {
            int currentPage = (int) Math.floor(internalCounter / 6D);
            if (textComponent[currentPage] == null)
                textComponent[currentPage] = new TextComponent();
            textComponent[currentPage].addExtra(text);
            internalCounter++;
        }
    }
    return textComponent;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) ArrayList(java.util.ArrayList) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)

Example 14 with CustomBossEntity

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

the class SpiritWalk method spiritWalkRegionalBossAnimation.

public static void spiritWalkRegionalBossAnimation(EliteEntity eliteEntity, Location entityLocation, Location finalLocation) {
    eliteEntity.getLivingEntity().setAI(false);
    eliteEntity.getLivingEntity().setInvulnerable(true);
    Vector toDestination = finalLocation.clone().subtract(entityLocation.clone()).toVector().normalize().divide(new Vector(2, 2, 2));
    Entity vehicle = null;
    if (eliteEntity.getLivingEntity().isInsideVehicle()) {
        vehicle = eliteEntity.getLivingEntity().getVehicle();
        if (vehicle instanceof LivingEntity)
            ((LivingEntity) vehicle).setAI(false);
        vehicle.setInvulnerable(true);
        if (((CustomBossEntity) eliteEntity).getPhaseBossEntity() != null)
            vehicle.remove();
    }
    new BukkitRunnable() {

        final Entity vehicle = eliteEntity.getLivingEntity().getVehicle();

        int counter = 0;

        @Override
        public void run() {
            if (!eliteEntity.isValid()) {
                cancel();
                return;
            }
            if (eliteEntity.getLivingEntity().isInsideVehicle())
                eliteEntity.getLivingEntity().leaveVehicle();
            if (eliteEntity.getLivingEntity().getLocation().clone().distance(finalLocation) < 2 || counter > 20 * 10) {
                eliteEntity.getLivingEntity().setAI(true);
                eliteEntity.getLivingEntity().setInvulnerable(false);
                if (vehicle != null && !vehicle.isDead())
                    vehicle.teleport(finalLocation);
                eliteEntity.getLivingEntity().teleport(finalLocation);
                if (vehicle != null && !vehicle.isDead()) {
                    if (vehicle instanceof LivingEntity) {
                        ((LivingEntity) vehicle).setAI(true);
                        EliteEntity vehicleBoss = EntityTracker.getEliteMobEntity(vehicle);
                        if (vehicleBoss != null)
                            Bukkit.getServer().getPluginManager().callEvent(new EliteMobExitCombatEvent(vehicleBoss, EliteMobExitCombatEvent.EliteMobExitCombatReason.SPIRIT_WALK));
                    }
                    vehicle.setInvulnerable(false);
                    new BukkitRunnable() {

                        @Override
                        public void run() {
                            PreventMountExploit.bypass = true;
                            vehicle.addPassenger(eliteEntity.getLivingEntity());
                        }
                    }.runTaskLater(MetadataHandler.PLUGIN, 1);
                }
                cancel();
                Bukkit.getServer().getPluginManager().callEvent(new EliteMobExitCombatEvent(eliteEntity, EliteMobExitCombatEvent.EliteMobExitCombatReason.SPIRIT_WALK));
                if (eliteEntity.getLivingEntity() instanceof Mob)
                    if (((Mob) eliteEntity.getLivingEntity()).getTarget() == null)
                        eliteEntity.getLivingEntity().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 2));
            }
            if (vehicle != null && !vehicle.isDead()) {
                vehicle.teleport(eliteEntity.getLivingEntity().getLocation().clone().add(toDestination.clone()));
            }
            eliteEntity.getLivingEntity().teleport(eliteEntity.getLivingEntity().getLocation().clone().add(toDestination.clone()));
            counter++;
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
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) Mob(org.bukkit.entity.Mob) PotionEffect(org.bukkit.potion.PotionEffect) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Vector(org.bukkit.util.Vector) EliteMobExitCombatEvent(com.magmaguy.elitemobs.api.EliteMobExitCombatEvent)

Example 15 with CustomBossEntity

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

the class SpawnCommand method spawnCustomBossCommand.

public static void spawnCustomBossCommand(Player player, String fileName, int level) {
    CustomBossesConfigFields customBossesConfigFields = CustomBossesConfig.getCustomBoss(fileName);
    if (customBossesConfigFields == null) {
        player.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(getLocation(player));
    customBossEntity.setLevel(level);
    customBossEntity.spawn(false);
}
Also used : CustomBossesConfigFields(com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)

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