mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-27 02:58:03 +01:00
Because loading a config we hadn't made yet makes sense
This commit is contained in:
parent
450e938092
commit
83a3488d0d
@ -380,7 +380,7 @@ public class Config extends ConfigLoader {
|
||||
|
||||
private Config(mcMMO plugin) {
|
||||
super(plugin, "config.yml");
|
||||
config = plugin.getConfig();
|
||||
saveIfNotExist();
|
||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public abstract class ConfigLoader {
|
||||
|
||||
protected String fileName;
|
||||
protected File configFile;
|
||||
protected File dataFolder;
|
||||
protected final mcMMO plugin;
|
||||
@ -17,9 +17,10 @@ public abstract class ConfigLoader {
|
||||
|
||||
public ConfigLoader(mcMMO plugin, String fileName){
|
||||
this.plugin = plugin;
|
||||
this.fileName = fileName;
|
||||
dataFolder = plugin.getDataFolder();
|
||||
configFile = new File(dataFolder, File.separator + fileName);
|
||||
config = YamlConfiguration.loadConfiguration(this.configFile);
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,6 +48,19 @@ public abstract class ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveIfNotExist() {
|
||||
if (!configFile.exists()) {
|
||||
if (plugin.getResource(fileName) != null) {
|
||||
plugin.saveResource(fileName, false);
|
||||
}
|
||||
}
|
||||
rereadFromDisk();
|
||||
}
|
||||
|
||||
protected void rereadFromDisk() {
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the defaults to this config file.
|
||||
*/
|
||||
|
@ -18,6 +18,7 @@ public class SpoutConfig extends ConfigLoader {
|
||||
|
||||
public SpoutConfig(mcMMO plugin) {
|
||||
super(plugin, "spout.yml");
|
||||
saveIfNotExist();
|
||||
}
|
||||
|
||||
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
||||
|
@ -43,6 +43,7 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
|
||||
private TreasuresConfig(mcMMO plugin) {
|
||||
super(plugin, "treasures.yml");
|
||||
saveIfNotExist();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user