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;
}
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);
}
}
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));
}
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));
}
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!");
}
}
}
Aggregations