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