TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/config/YamlConfig.java

64 lines
1.2 KiB
Java
Raw Normal View History

2020-07-01 01:51:06 +00:00
package me.totalfreedom.totalfreedommod.config;
import java.io.File;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import org.bukkit.configuration.file.YamlConfiguration;
public class YamlConfig extends YamlConfiguration
{
private final File file;
public YamlConfig(TotalFreedomMod plugin, String name, boolean copyDefaults)
{
this.file = new File(plugin.getDataFolder(), name);
if (copyDefaults)
{
options().copyDefaults(true);
}
if (!file.exists())
{
plugin.saveResource(name, false);
}
load();
}
public YamlConfig(TotalFreedomMod plugin, String name)
{
this(plugin, name, true);
}
public void load()
{
try
{
super.load(file);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void save()
{
try
{
super.save(file);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void clear()
{
for (String key : super.getKeys(false))
{
super.set(key, null);
}
}
}