Refactored config versions

This commit is contained in:
Auxilor 2020-09-14 20:45:00 +01:00
parent b423389496
commit 5d774e62cb
5 changed files with 11 additions and 13 deletions

View File

@ -12,16 +12,6 @@ import java.util.HashMap;
public class EcoEnchantsPlugin extends JavaPlugin {
private static EcoEnchantsPlugin instance;
/**
* Config versions for config.yml and lang.yml
*/
public static final HashMap<String, Double> configVersions = new HashMap<String, Double>() {{
put("config", 5.0);
put("lang", 5.0);
put("target", 1.0);
put("rarity", 1.0);
}};
/**
* Is the plugin outdated
*/

View File

@ -2,10 +2,18 @@ package com.willfp.ecoenchants.config;
import com.willfp.ecoenchants.config.configs.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
public class ConfigManager {
public static final HashMap<String, Double> configVersions = new HashMap<String, Double>() {{
put("config", 5.0);
put("lang", 5.0);
put("target", 1.0);
put("rarity", 1.0);
}};
private static final Lang LANG = new Lang();
private static final Config CONFIG = new Config();
private static final Target TARGET = new Target();

View File

@ -52,7 +52,7 @@ public abstract class YamlConfig {
}
private void checkVersion() {
double latestVersion = EcoEnchantsPlugin.configVersions.get(this.name);
double latestVersion = ConfigManager.configVersions.get(this.name);
if (latestVersion != config.getDouble("config-version")) {
Bukkit.getLogger().warning("EcoEnchants detected an older or invalid " + name + ".yml. Replacing it with the default config...");
Bukkit.getLogger().warning("If you've edited the config, copy over your changes!");

View File

@ -204,7 +204,7 @@ public class EnchantDisplay {
name = enchantment.getName();
description = EcoEnchants.getFromEnchantment(enchantment).getDescription();
EnchantmentRarity rarity = EcoEnchants.getFromEnchantment(enchantment).getRarity();
if(rarity.hasCustomColor()) {
if(rarity.hasCustomColor() && type != EcoEnchant.EnchantmentType.CURSE) {
color = rarity.getCustomColor();
}
description.replaceAll(line -> prefix + descriptionColor + line);

View File

@ -285,7 +285,7 @@ public class Loader {
} else {
Bukkit.getLogger().info(EnchantmentRarity.getAll().size() + " Rarities Loaded:");
EnchantmentRarity.getAll().forEach((rarity -> {
Bukkit.getLogger().info("- " + rarity.getName() + ": Table Probability=" + rarity.getProbability() + ", Minimum Level=" + rarity.getMinimumLevel() + ", Villager Probability=" + rarity.getVillagerProbability() + ", Loot Probability=" + rarity.getLootProbability());
Bukkit.getLogger().info("- " + rarity.getName() + ": Table Probability=" + rarity.getProbability() + ", Minimum Level=" + rarity.getMinimumLevel() + ", Villager Probability=" + rarity.getVillagerProbability() + ", Loot Probability=" + rarity.getLootProbability() + ", Has Custom Color=" + rarity.hasCustomColor());
}));
Bukkit.getLogger().info("");