mirror of https://github.com/hnhx/xenon.git
61 lines
1.2 KiB
Java
61 lines
1.2 KiB
Java
package xenon.misc;
|
|
|
|
import org.bukkit.configuration.InvalidConfigurationException;
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
|
|
public class Config {
|
|
|
|
private final File file;
|
|
private final YamlConfiguration config;
|
|
|
|
public Config() {
|
|
File dir = new File("./plugins/Xenon");
|
|
|
|
if (!dir.exists()) {
|
|
dir.mkdirs();
|
|
}
|
|
|
|
this.file = new File(dir, "config.yml");
|
|
|
|
if (!file.exists()) {
|
|
try {
|
|
file.createNewFile();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
this.config = YamlConfiguration.loadConfiguration(file);
|
|
}
|
|
|
|
public File getFile() {
|
|
return file;
|
|
}
|
|
|
|
public YamlConfiguration getConfig() {
|
|
return config;
|
|
}
|
|
|
|
public void save() {
|
|
try {
|
|
config.save(file);
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void reload(){
|
|
try {
|
|
config.load(file);
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
} catch (InvalidConfigurationException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
}
|
|
}
|