Search in sources :

Example 1 with ElitePower

use of com.magmaguy.elitemobs.powers.meta.ElitePower in project EliteMobs by MagmaGuy.

the class ElitePowerParser method parsePowers.

public static HashSet<ElitePower> parsePowers(List<String> powers) {
    HashSet<ElitePower> elitePowers = new HashSet<>();
    CustomSummonPower customSummonPower = null;
    for (String powerName : powers) {
        if (powerName.split(":")[0].equalsIgnoreCase("summon") || powerName.split(":")[0].equalsIgnoreCase("summonable"))
            if (customSummonPower == null) {
                customSummonPower = new CustomSummonPower(powerName);
                elitePowers.add(customSummonPower);
            } else
                customSummonPower.addEntry(powerName);
        else {
            String[] parsedPowerName = powerName.split(":");
            if (ElitePower.getElitePower(parsedPowerName[0]) != null) {
                ElitePower elitePower = ElitePower.getElitePower(parsedPowerName[0]);
                elitePowers.add(elitePower);
                if (elitePower instanceof BonusCoins)
                    if (parsedPowerName.length > 1)
                        try {
                            ((BonusCoins) elitePower).setCoinMultiplier(Double.parseDouble(parsedPowerName[1]));
                        } catch (Exception ex) {
                            new WarningMessage("Multiplier " + parsedPowerName[1] + " for Bonus Coins power is not a valid multiplier!");
                        }
            } else
                new WarningMessage("Warning: power name " + powerName + " is not registered! Skipping it for custom mob construction...");
        }
    }
    return elitePowers;
}
Also used : CustomSummonPower(com.magmaguy.elitemobs.powers.meta.CustomSummonPower) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) BonusCoins(com.magmaguy.elitemobs.powers.bosspowers.BonusCoins) ElitePower(com.magmaguy.elitemobs.powers.meta.ElitePower) HashSet(java.util.HashSet)

Example 2 with ElitePower

use of com.magmaguy.elitemobs.powers.meta.ElitePower in project EliteMobs by MagmaGuy.

the class CustomBossMegaConsumer method applyBossFeatures.

public void applyBossFeatures(LivingEntity livingEntity) {
    for (ElitePower elitePower : powers) elitePower.applyPowers(livingEntity);
    setEquipment(livingEntity);
    setBaby(livingEntity);
    setFrozen(livingEntity);
    setDisguise(livingEntity);
    setCustomModel(livingEntity);
    setName(livingEntity);
    setFollowRange(livingEntity);
    if (livingEntity.getType().equals(EntityType.ENDER_DRAGON)) {
        ((EnderDragon) livingEntity).setPhase(EnderDragon.Phase.CIRCLING);
        ((EnderDragon) livingEntity).getDragonBattle().generateEndPortal(false);
    }
}
Also used : ElitePower(com.magmaguy.elitemobs.powers.meta.ElitePower)

Example 3 with ElitePower

use of com.magmaguy.elitemobs.powers.meta.ElitePower in project EliteMobs by MagmaGuy.

the class SpawnCommand method spawnEliteEntityTypeCommand.

public static void spawnEliteEntityTypeCommand(CommandSender commandSender, Location location, EntityType entityType, Integer level, Optional<String[]> powers) {
    if (!EliteMobProperties.getValidMobTypes().contains(entityType)) {
        commandSender.sendMessage(ChatColorConverter.convert("&8[EliteMobs] &4Entity type " + entityType.toString() + " can't be an Elite!"));
        return;
    }
    LivingEntity livingEntity = (LivingEntity) location.getWorld().spawnEntity(location, entityType);
    HashSet<ElitePower> mobPowers = new HashSet<>();
    if (powers.isPresent())
        mobPowers = getPowers(powers.get(), commandSender);
    EliteEntity eliteEntity = new EliteEntity();
    eliteEntity.setLevel(level);
    eliteEntity.setLivingEntity(livingEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
    if (!mobPowers.isEmpty())
        eliteEntity.applyPowers(mobPowers);
    else
        eliteEntity.randomizePowers(EliteMobProperties.getPluginData(livingEntity));
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) ElitePower(com.magmaguy.elitemobs.powers.meta.ElitePower) HashSet(java.util.HashSet)

Example 4 with ElitePower

use of com.magmaguy.elitemobs.powers.meta.ElitePower in project EliteMobs by MagmaGuy.

the class SpawnCommand method spawnEliteEntityTypeCommand.

public static void spawnEliteEntityTypeCommand(Player player, EntityType entityType, Integer level, String[] powers) {
    LivingEntity livingEntity = (LivingEntity) player.getLocation().getWorld().spawnEntity(getLocation(player), entityType);
    HashSet<ElitePower> mobPowers = getPowers(powers, player);
    EliteEntity eliteEntity = new EliteEntity();
    eliteEntity.setLevel(level);
    eliteEntity.setLivingEntity(livingEntity, CreatureSpawnEvent.SpawnReason.CUSTOM);
    if (!mobPowers.isEmpty())
        eliteEntity.applyPowers(mobPowers);
    else
        eliteEntity.randomizePowers(EliteMobProperties.getPluginData(livingEntity));
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) ElitePower(com.magmaguy.elitemobs.powers.meta.ElitePower)

Example 5 with ElitePower

use of com.magmaguy.elitemobs.powers.meta.ElitePower in project EliteMobs by MagmaGuy.

the class EliteEntity method applyPowers.

public void applyPowers(HashSet<ElitePower> elitePowers, int availablePowerAmount) {
    elitePowers.removeIf(elitePower -> !PowersConfig.getPower(elitePower.getFileName()).isEnabled());
    if (availablePowerAmount < 1)
        return;
    ArrayList<ElitePower> localPowers = new ArrayList<>(elitePowers);
    for (ElitePower mobPower : this.elitePowers) localPowers.remove(mobPower);
    for (int i = 0; i < availablePowerAmount; i++) if (localPowers.size() < 1)
        break;
    else {
        ElitePower selectedPower = localPowers.get(ThreadLocalRandom.current().nextInt(localPowers.size()));
        try {
            this.elitePowers.add(selectedPower.getClass().newInstance());
            selectedPower.applyPowers(this.livingEntity);
            localPowers.remove(selectedPower);
            if (selectedPower instanceof MajorPower)
                this.majorPowerCount++;
            if (selectedPower instanceof MinorPower)
                this.minorPowerCount++;
        } catch (Exception ex) {
            new WarningMessage("Failed to instance new power!");
        }
    }
}
Also used : MinorPower(com.magmaguy.elitemobs.powers.meta.MinorPower) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) MajorPower(com.magmaguy.elitemobs.powers.meta.MajorPower) ElitePower(com.magmaguy.elitemobs.powers.meta.ElitePower)

Aggregations

ElitePower (com.magmaguy.elitemobs.powers.meta.ElitePower)5 EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)2 WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)2 HashSet (java.util.HashSet)2 LivingEntity (org.bukkit.entity.LivingEntity)2 BonusCoins (com.magmaguy.elitemobs.powers.bosspowers.BonusCoins)1 CustomSummonPower (com.magmaguy.elitemobs.powers.meta.CustomSummonPower)1 MajorPower (com.magmaguy.elitemobs.powers.meta.MajorPower)1 MinorPower (com.magmaguy.elitemobs.powers.meta.MinorPower)1