Search in sources :

Example 71 with WarningMessage

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;
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) ArrayList(java.util.ArrayList) BlockData(org.bukkit.block.data.BlockData) Vector(org.bukkit.util.Vector)

Example 72 with WarningMessage

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

Example 73 with WarningMessage

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!");
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) ItemStack(org.bukkit.inventory.ItemStack)

Example 74 with WarningMessage

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;
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage)

Example 75 with WarningMessage

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());
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) EventHandler(org.bukkit.event.EventHandler)

Aggregations

WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)76 InfoMessage (com.magmaguy.elitemobs.utils.InfoMessage)11 Vector (org.bukkit.util.Vector)11 Item (org.bukkit.entity.Item)10 File (java.io.File)9 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)8 FlagConflictException (com.sk89q.worldguard.protection.flags.registry.FlagConflictException)7 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)6 RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)6 ArrayList (java.util.ArrayList)6 ZipFile (com.magmaguy.elitemobs.utils.ZipFile)5 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)5 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)5 Location (org.bukkit.Location)5 ItemStack (org.bukkit.inventory.ItemStack)5 CustomBossesConfigFields (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields)3 Minidungeon (com.magmaguy.elitemobs.dungeons.Minidungeon)3 IOException (java.io.IOException)3 Material (org.bukkit.Material)3 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3