Configuration should be fixed for real. Finally.

This commit is contained in:
zml2008 2012-01-27 21:54:53 -08:00 committed by TomyLobo
parent e665f966e6
commit 5c92762ba9
2 changed files with 23 additions and 11 deletions

View File

@ -75,6 +75,11 @@ public class ConfigurationManager {
*/
private Map<String, WorldConfiguration> worlds;
/**
* The global configuration for use when loading worlds
*/
private YAMLProcessor config;
/**
* List of people with god mode.
*/
@ -112,10 +117,13 @@ public void load() {
plugin.createDefaultConfiguration(
new File(plugin.getDataFolder(), "config.yml"), "config.yml");
YAMLProcessor config = new YAMLProcessor(new File(plugin.getDataFolder(), "config.yml"), true, YAMLFormat.EXTENDED);
config = new YAMLProcessor(new File(plugin.getDataFolder(), "config.yml"), true, YAMLFormat.EXTENDED);
try {
config.load();
} catch (IOException ignore) {}
} catch (IOException e) {
WorldGuardPlugin.logger.severe("Error reading configuration for global config: ");
e.printStackTrace();
}
suppressTickSyncWarnings = config.getBoolean(
"suppress-tick-sync-warnings", false);
@ -125,8 +133,6 @@ public void load() {
"auto-invincible", config.getBoolean("auto-invincible-permission", true));
usePlayerMove = config.getBoolean(
"use-player-move-event", true);
config.setWriteDefaults(false);
// Load configurations for each world
for (World world : plugin.getServer().getWorlds()) {
@ -138,7 +144,9 @@ public void load() {
} catch (Throwable t) {
}
config.save();
if (!config.save()) {
WorldGuardPlugin.logger.severe("Error saving configuration!");
}
}
/**
@ -159,7 +167,7 @@ public WorldConfiguration get(World world) {
WorldConfiguration config = worlds.get(worldName);
if (config == null) {
config = new WorldConfiguration(plugin, worldName);
config = new WorldConfiguration(plugin, worldName, this.config);
worlds.put(worldName, config);
}

View File

@ -158,17 +158,18 @@ public class WorldConfiguration {
/**
* Construct the object.
*
* @param plugin
* @param worldName
* @param plugin The WorldGuardPlugin instance
* @param worldName The world name that this WorldConfiguration is for.
* @param parentConfig The parent configuration to read defaults from
*/
public WorldConfiguration(WorldGuardPlugin plugin, String worldName) {
public WorldConfiguration(WorldGuardPlugin plugin, String worldName, YAMLProcessor parentConfig) {
File baseFolder = new File(plugin.getDataFolder(), "worlds/" + worldName);
configFile = new File(baseFolder, "config.yml");
blacklistFile = new File(baseFolder, "blacklist.txt");
this.plugin = plugin;
this.worldName = worldName;
this.parentConfig = new YAMLProcessor(new File(plugin.getDataFolder(), "config.yml"), true, YAMLFormat.EXTENDED);
this.parentConfig = parentConfig;
plugin.createDefaultConfiguration(configFile, "config_world.yml");
plugin.createDefaultConfiguration(blacklistFile, "blacklist.txt");
@ -277,7 +278,10 @@ private Object getProperty(String node) {
private void loadConfiguration() {
try {
config.load();
} catch (IOException ignore) {}
} catch (IOException e) {
WorldGuardPlugin.logger.severe("Error reading configuration for world " + worldName + ": ");
e.printStackTrace();
}
opPermissions = getBoolean("op-permissions", true);