Search in sources :

Example 66 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.

the class CustomConfigFields method processEnumList.

protected <T extends Enum<T>> List<T> processEnumList(String path, List<T> value, List<T> pluginDefault, Class<T> enumClass, boolean forceWriteDefault) {
    if (!configHas(path)) {
        if (forceWriteDefault || value != pluginDefault)
            processStringList(path, enumListToStringListConverter(value), enumListToStringListConverter(pluginDefault), forceWriteDefault);
        return value;
    }
    try {
        List<T> newList = new ArrayList<>();
        List<String> stringList = processStringList(path, enumListToStringListConverter(value), enumListToStringListConverter(pluginDefault), forceWriteDefault);
        stringList.forEach(string -> {
            try {
                newList.add(Enum.valueOf(enumClass, string.toUpperCase()));
            } catch (Exception ex) {
                new WarningMessage(filename + " : " + "Value " + string + " is not a valid for " + path + " ! This may be due to your server version, or due to an invalid value!");
            }
        });
        return newList;
    } catch (Exception ex) {
        ex.printStackTrace();
        new WarningMessage("File " + filename + " has an incorrect entry for " + path);
        new WarningMessage("Entry: " + value);
    }
    return value;
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage)

Example 67 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.

the class CustomBossesConfigFields method processDamageModifiers.

private HashMap<Material, Double> processDamageModifiers(String path, HashMap<Material, Double> pluginDefaults) {
    HashMap<Material, Double> hashMap = new HashMap<>();
    if (!fileConfiguration.contains(path))
        return pluginDefaults;
    for (String rawDamageModifier : fileConfiguration.getStringList(path)) {
        String[] parsedStrings;
        Material material = null;
        Double multiplier = null;
        if (rawDamageModifier.contains(",")) {
            parsedStrings = rawDamageModifier.split(",");
            for (String parsedDamageModifier : parsedStrings) {
                if (parsedDamageModifier.contains("material:"))
                    try {
                        material = Material.getMaterial(parsedDamageModifier.replace("material:", ""));
                    } catch (Exception ex) {
                        new WarningMessage("Boss " + getFilename() + " has invalid entry " + parsedDamageModifier + " !");
                    }
                else if (parsedDamageModifier.contains("multiplier:"))
                    try {
                        multiplier = Double.parseDouble(parsedDamageModifier.replace("multiplier:", ""));
                    } catch (Exception ex) {
                        new WarningMessage("Boss " + getFilename() + " has invalid entry " + parsedDamageModifier + " !");
                    }
                else
                    new WarningMessage("Entry " + parsedDamageModifier + " is invalid for boss file " + getFilename() + " !");
            }
        } else {
            parsedStrings = rawDamageModifier.split(":");
            for (String parsedDamageModifier : parsedStrings) {
                if (parsedDamageModifier.contains("material="))
                    try {
                        material = Material.getMaterial(parsedDamageModifier.replace("material=", ""));
                    } catch (Exception ex) {
                        new WarningMessage("Boss " + getFilename() + " has invalid entry " + parsedDamageModifier + " !");
                    }
                else if (parsedDamageModifier.contains("multiplier="))
                    try {
                        multiplier = Double.parseDouble(parsedDamageModifier.replace("multiplier=", ""));
                    } catch (Exception ex) {
                        new WarningMessage("Boss " + getFilename() + " has invalid entry " + parsedDamageModifier + " !");
                    }
                else
                    new WarningMessage("Entry " + parsedDamageModifier + " is invalid for boss file " + getFilename() + " !");
            }
        }
        if (material != null && multiplier != null)
            hashMap.put(material, multiplier);
    }
    if (!hashMap.isEmpty())
        fileConfiguration.addDefault(path, deserializeDamageModifiers(hashMap));
    return hashMap;
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) Material(org.bukkit.Material)

Example 68 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.

the class CustomBossesConfigFields method setOnSpawnBlockStates.

public void setOnSpawnBlockStates(List<String> onSpawnBlockStates) {
    this.onSpawnBlockStates = onSpawnBlockStates;
    fileConfiguration.set("onSpawnBlockStates", onSpawnBlockStates);
    try {
        fileConfiguration.save(file);
    } catch (Exception ex) {
        new WarningMessage("Failed to save on spawn block states!", true);
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage)

Example 69 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.

the class DefaultConfig method initializeConfig.

public static void initializeConfig() {
    file = ConfigurationEngine.fileCreator("config.yml");
    fileConfiguration = ConfigurationEngine.fileConfigurationCreator(file);
    alwaysShowNametags = ConfigurationEngine.setBoolean(fileConfiguration, "alwaysShowEliteMobNameTags", false);
    superMobStackAmount = Math.max(ConfigurationEngine.setInt(fileConfiguration, "superMobStackAmount", 50), 1);
    preventCreeperDamageToPassiveMobs = ConfigurationEngine.setBoolean(fileConfiguration, "preventEliteCreeperDamageToPassiveMobs", true);
    doPermissionTitles = ConfigurationEngine.setBoolean(fileConfiguration, "useTitlesForMissingPermissionMessages", true);
    preventEliteMobConversionOfNamedMobs = ConfigurationEngine.setBoolean(fileConfiguration, "preventEliteMobConversionOfNamedMobs", true);
    doStrictSpawningRules = ConfigurationEngine.setBoolean(fileConfiguration, "enableHighCompatibilityMode", false);
    nightmareWorldSpawnBonus = ConfigurationEngine.setDouble(fileConfiguration, "nightmareWorldSpawnBonus", 0.5);
    emLeadsToStatusMenu = ConfigurationEngine.setBoolean(fileConfiguration, "emLeadsToStatusMenu", true);
    otherCommandsLeadToEMStatusMenu = ConfigurationEngine.setBoolean(fileConfiguration, "otherCommandsLeadToEMStatusMenu", true);
    setupDone = ConfigurationEngine.setBoolean(fileConfiguration, "setupDoneV3", false);
    preventVanillaReinforcementsForEliteEntities = ConfigurationEngine.setBoolean(fileConfiguration, "preventVanillaReinforcementsForEliteEntities", true);
    try {
        defaultSpawnLocation = ConfigurationLocation.serialize(ConfigurationEngine.setString(fileConfiguration, "defaultSpawnLocation", ConfigurationLocation.deserialize(Bukkit.getWorlds().get(0).getSpawnLocation())));
    } catch (Exception ex) {
        new WarningMessage("There is an issue with your defaultSpawnLocation in the config.yml configuration file! Fix it!");
    }
    doExplosionRegen = ConfigurationEngine.setBoolean(fileConfiguration, "doExplosionRegen", true);
    doRegenerateContainers = ConfigurationEngine.setBoolean(fileConfiguration, "doRegenerateContainers", true);
    defaultTransitiveBlockLimiter = ConfigurationEngine.setInt(fileConfiguration, "defaultTransitiveBlockLimiter", 200);
    ConfigurationEngine.fileSaverOnlyDefaults(fileConfiguration, file);
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage)

Example 70 with WarningMessage

use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.

the class CustomItem method initializeCustomItems.

/**
 * Initializes all config items on startup. Needs to run after the config initialization as it relies on those values.
 */
public static void initializeCustomItems() {
    for (CustomItemsConfigFields configFields : CustomItemsConfig.getCustomItems().values()) try {
        new CustomItem(configFields);
    } catch (Exception ex) {
        new WarningMessage("Failed to generate custom item in file " + configFields.getFilename() + " !");
        ex.printStackTrace();
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) CustomItemsConfigFields(com.magmaguy.elitemobs.config.customitems.CustomItemsConfigFields)

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