use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class TransitiveBlock method serializeTransitiveBlocks.
public static List<TransitiveBlock> serializeTransitiveBlocks(List<String> deserializedList, String filename) {
List<TransitiveBlock> transitiveBlocks = new ArrayList<>();
for (String deserializedString : deserializedList) {
try {
String[] elements = deserializedString.split("/");
String[] vector = elements[0].split(",");
double x = Double.parseDouble(vector[0]);
double y = Double.parseDouble(vector[1]);
double z = Double.parseDouble(vector[2]);
BlockData blockData = Bukkit.getServer().createBlockData(elements[1]);
transitiveBlocks.add(new TransitiveBlock(blockData, new Vector(x, y, z)));
} catch (Exception ex) {
new WarningMessage("Failed to serialize Transitive Block! Issue with entry " + deserializedString + " in file " + filename);
}
}
return transitiveBlocks;
}
use of com.magmaguy.elitemobs.utils.WarningMessage 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!");
}
}
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class CustomFetchObjective method turnItemsIn.
private void turnItemsIn(Player player) {
int deletedItems = 0;
for (ItemStack itemStack : player.getInventory()) {
if (ItemTagger.hasKey(itemStack, this.key)) {
int existingAmount = itemStack.getAmount();
int missingAmount = targetAmount - deletedItems;
if (existingAmount >= missingAmount) {
existingAmount -= missingAmount;
deletedItems += missingAmount;
} else
existingAmount = 0;
itemStack.setAmount(existingAmount);
if (deletedItems == targetAmount)
return;
}
}
new WarningMessage("Player " + player.getName() + " managed to complete objective " + objectiveName + " without turning in the required amount of items! This isn't good, tell the developer!");
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class CustomObjectivesParser method processObjectiveType.
private static Objective processObjectiveType(String[] rawStrings, ObjectiveType objectiveType, CustomQuest customQuest) {
String filename = null;
String location = null;
String dialog = null;
String name = null;
int amount = 1;
for (String rawString : rawStrings) {
String[] processedStrings = rawString.split("=");
switch(processedStrings[0]) {
case "filename":
filename = processedStrings[1];
break;
case "amount":
try {
amount = Integer.parseInt(processedStrings[1]);
} catch (Exception ex) {
new WarningMessage("Invalid amount " + amount + " in entry " + rawString + " for Custom Quest " + filename + " . Defaulting to 1.");
}
break;
case "location":
location = ChatColorConverter.convert(processedStrings[1]);
break;
case "dialog":
dialog = ChatColorConverter.convert(processedStrings[1]);
break;
case "npcName":
case "itemName":
case "name":
name = ChatColorConverter.convert(processedStrings[1]);
break;
}
}
if (filename == null) {
new WarningMessage("Invalid filename for entry " + rawStrings.toString() + " in Custom Quest " + customQuest.getCustomQuestsConfigFields().getFilename() + " . This objective will not be registered.");
return null;
}
try {
if (objectiveType.equals(ObjectiveType.KILL_CUSTOM))
return new CustomKillObjective(filename, amount, customQuest.getQuestLevel());
else if (objectiveType.equals(ObjectiveType.FETCH_ITEM))
return new CustomFetchObjective(amount, name, filename);
else if (objectiveType.equals(ObjectiveType.DIALOG))
return new DialogObjective(filename, name, location, dialog);
} catch (Exception ex) {
new WarningMessage("Failed to register objective type for quest " + customQuest.getCustomQuestsConfigFields().getFilename() + " ! This quest will be skipped");
}
return null;
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class ZombieParents method onHit.
@EventHandler
public void onHit(EliteMobDamagedByPlayerEvent event) {
ZombieParents zombieParents = (ZombieParents) event.getEliteMobEntity().getPower(this);
if (zombieParents == null)
return;
if (zombieParents.isFiring())
return;
if (ThreadLocalRandom.current().nextDouble() > 0.01)
return;
zombieParents.setFiring(false);
CustomBossEntity reinforcementMom = CustomBossEntity.createCustomBossEntity("zombie_parents_mom.yml");
try {
reinforcementMom.spawn(event.getEntity().getLocation(), event.getEliteMobEntity().getLevel(), false);
} catch (Exception ex) {
new WarningMessage("Failed to spawn Zombie Parents Mom reinforcement!");
return;
}
CustomBossEntity reinforcementDad = CustomBossEntity.createCustomBossEntity("zombie_parents_dad.yml");
try {
reinforcementDad.spawn(event.getEntity().getLocation(), event.getEliteMobEntity().getLevel(), false);
} catch (Exception ex) {
new WarningMessage("Failed to spawn Zombie Parents Dad reinforcement!");
return;
}
startDialog(reinforcementMom, reinforcementDad, event.getEliteMobEntity());
}
Aggregations