mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-28 11:37:39 +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) {
|
private Config(mcMMO plugin) {
|
||||||
super(plugin, "config.yml");
|
super(plugin, "config.yml");
|
||||||
config = plugin.getConfig();
|
saveIfNotExist();
|
||||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
public abstract class ConfigLoader {
|
public abstract class ConfigLoader {
|
||||||
|
protected String fileName;
|
||||||
protected File configFile;
|
protected File configFile;
|
||||||
protected File dataFolder;
|
protected File dataFolder;
|
||||||
protected final mcMMO plugin;
|
protected final mcMMO plugin;
|
||||||
@ -17,9 +17,10 @@ public abstract class ConfigLoader {
|
|||||||
|
|
||||||
public ConfigLoader(mcMMO plugin, String fileName){
|
public ConfigLoader(mcMMO plugin, String fileName){
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.fileName = fileName;
|
||||||
dataFolder = plugin.getDataFolder();
|
dataFolder = plugin.getDataFolder();
|
||||||
configFile = new File(dataFolder, File.separator + fileName);
|
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.
|
* Add the defaults to this config file.
|
||||||
*/
|
*/
|
||||||
|
@ -18,6 +18,7 @@ public class SpoutConfig extends ConfigLoader {
|
|||||||
|
|
||||||
public SpoutConfig(mcMMO plugin) {
|
public SpoutConfig(mcMMO plugin) {
|
||||||
super(plugin, "spout.yml");
|
super(plugin, "spout.yml");
|
||||||
|
saveIfNotExist();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
||||||
|
@ -43,6 +43,7 @@ public class TreasuresConfig extends ConfigLoader{
|
|||||||
|
|
||||||
private TreasuresConfig(mcMMO plugin) {
|
private TreasuresConfig(mcMMO plugin) {
|
||||||
super(plugin, "treasures.yml");
|
super(plugin, "treasures.yml");
|
||||||
|
saveIfNotExist();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user