package fr.molzonas.painfulloss.utils; import fr.molzonas.painfulloss.PainfulLoss; import lombok.Getter; import java.util.HashMap; import java.util.Map; import java.util.Set; public enum PropertiesEnum { LOCALE("locale", PainfulLoss.DEFAULT_LOCALE_TAG), DEBUG("debug", "false"), PRICE_PROVIDER("priceProvider"), ENCHANT_ENABLED("estimation.enchant.enabled"), ENCHANT_DEFAULT_PER_LEVEL("estimation.enchant.default_per_level"), ECONOMY_PROVIDER("economyProvider", "Vault"), RECIPE_COST_IF_NO_PRICE_FOUND("recipeCostIfNoPriceFound", "false") ; @Getter private final String path; @Getter private String fallback = null; PropertiesEnum(String path) { this.path = path; } PropertiesEnum(String path, String fallback) { this.path = path; this.fallback = fallback; } public String getString() { String value = PainfulLoss.getInstance().getConfig().getString(this.getPath()); return value == null ? fallback : value; } public boolean getBoolean() { return PainfulLoss.getInstance().getConfig().getBoolean(this.getPath()); } public Double getDouble() { return PainfulLoss.getInstance().getConfig().getDouble(this.getPath()); } public static Map getEnchantConfigTable() { Map enchantConfig = new HashMap<>(); Set keys = PainfulLoss.getInstance().getConfig().getConfigurationSection("estimation.enchant.table").getKeys(false); for (String key : keys) { enchantConfig.put(key, PainfulLoss.getInstance().getConfig().getDouble("estimation.enchant.table." + key, 0d)); } return enchantConfig; } }