package de.fanta.challenge.utils;
import de.fanta.challenge.Challenge;
import de.fanta.challenge.ServerType;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public class Config {
private static final Challenge plugin = Challenge.getPlugin();
public static void setValue(String path, Object value) {
setValue(path, value, true);
}
public static void setValue(String path, Object value, boolean edit) {
plugin.getConfig().set(path, value);
plugin.saveConfig();
Challenge.getPlugin().getLogger().info("Save Config " + path + ": " + value + " (" + edit + ")");
if (edit && plugin.getServerType() == ServerType.CHALLENGE) {
if (!getBoolean("editsettings")) {
setValue("editsettings", true, false);
plugin.getLogger().info("Diese Challenge ist kein SpeedRun mehr " + "(" + path + ": " + value + ")");
if (plugin.getCurrentEditor() != null) {
plugin.getComponentUtil().sendWarningMessage(plugin.getCurrentEditor(), "Diese Challenge wird nicht mehr als Speed Run gezählt, da du etwas in den Einstellungen bearbeitet hast.");
}
}
}
}
public static ConfigurationSection createSection(String path) {
return plugin.getConfig().createSection(path);
}
public static boolean getBoolean(String path) {
return plugin.getConfig().getBoolean(path);
}
public static int getInt(String path) {
return plugin.getConfig().getInt(path);
}
public static String getString(String path) {
return plugin.getConfig().getString(path);
}
public static double getDouble(String path) {
return plugin.getConfig().getDouble(path);
}
public static double getDouble(String path, Double def) {
return plugin.getConfig().getDouble(path, def);
}
public static ItemStack getItemStack(String path) {
return plugin.getConfig().getItemStack(path);
}
public static Location getLocation(String path) {
return plugin.getConfig().getLocation(path);
}
public static ConfigurationSection getConfigurationSection(String path) {
return plugin.getConfig().getConfigurationSection(path);
}
public static List<String> getStringList(String path) {
return plugin.getConfig().getStringList(path);
}
public static boolean contains(String path) {
return plugin.getConfig().contains(path);
}
}