2025-08-24 15:21:45 +02:00

53 lines
1.6 KiB
Java

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")
;
@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<String, Double> getEnchantConfigTable() {
Map<String, Double> enchantConfig = new HashMap<>();
Set<String> 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;
}
}