mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-15 20:14:42 +02:00
Updates to configs.
This commit is contained in:
55
src/main/java/com/gmail/nossr50/config/ConfigLoader.java
Normal file
55
src/main/java/com/gmail/nossr50/config/ConfigLoader.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public abstract class ConfigLoader {
|
||||
|
||||
protected static File configFile;
|
||||
protected static File dataFolder;
|
||||
protected final mcMMO plugin;
|
||||
protected static FileConfiguration config;
|
||||
|
||||
public ConfigLoader(mcMMO plugin, String fileName){
|
||||
this.plugin = plugin;
|
||||
dataFolder = plugin.getDataFolder();
|
||||
configFile = new File(dataFolder, File.separator + fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load this config file.
|
||||
*/
|
||||
protected abstract void load();
|
||||
|
||||
/**
|
||||
* Save this config file.
|
||||
*/
|
||||
private static void saveConfig() {
|
||||
try {
|
||||
config.save(configFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the defaults to this config file.
|
||||
*/
|
||||
protected void addDefaults() {
|
||||
|
||||
// Load from included config.yml
|
||||
config.options().copyDefaults(true);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the keys from this config file.
|
||||
*/
|
||||
protected abstract void loadKeys();
|
||||
|
||||
}
|
Reference in New Issue
Block a user