Changed the per-world configuration loader to also put configuration entries in the main configuration.

This commit is contained in:
sk89q 2011-06-27 13:13:31 -07:00
parent a5332c2166
commit 5b300bc5d1

View File

@ -171,66 +171,70 @@ public WorldConfiguration(WorldGuardPlugin plugin, String worldName) {
} }
private boolean getBoolean(String node, boolean def) { private boolean getBoolean(String node, boolean def) {
boolean val = parentConfig.getBoolean(node, def);
if (config.getProperty(node) != null) { if (config.getProperty(node) != null) {
return config.getBoolean(node, def); return config.getBoolean(node, def);
} else { } else {
return parentConfig.getBoolean(node, def); return val;
} }
} }
private String getString(String node, String def) { private String getString(String node, String def) {
String val = parentConfig.getString(node, def);
if (config.getProperty(node) != null) { if (config.getProperty(node) != null) {
return config.getString(node, def); return config.getString(node, def);
} else { } else {
return parentConfig.getString(node, def); return val;
} }
} }
private int getInt(String node, int def) { private int getInt(String node, int def) {
int val = parentConfig.getInt(node, def);
if (config.getProperty(node) != null) { if (config.getProperty(node) != null) {
return config.getInt(node, def); return config.getInt(node, def);
} else { } else {
return parentConfig.getInt(node, def); return val;
} }
} }
private double getDouble(String node, double def) { private double getDouble(String node, double def) {
double val = parentConfig.getDouble(node, def);
if (config.getProperty(node) != null) { if (config.getProperty(node) != null) {
return config.getDouble(node, def); return config.getDouble(node, def);
} else { } else {
return parentConfig.getDouble(node, def); return val;
} }
} }
private List<Integer> getIntList(String node, List<Integer> def) { private List<Integer> getIntList(String node, List<Integer> def) {
List<Integer> res; List<Integer> res = parentConfig.getIntList(node, def);
if (config.getProperty(node) != null) {
res = config.getIntList(node, def);
} else {
res = parentConfig.getIntList(node, def);
}
if (res == null || res.size() == 0) { if (res == null || res.size() == 0) {
parentConfig.setProperty(node, new ArrayList<Integer>()); parentConfig.setProperty(node, new ArrayList<Integer>());
} }
if (config.getProperty(node) != null) {
res = config.getIntList(node, def);
}
return res; return res;
} }
private List<String> getStringList(String node, List<String> def) { private List<String> getStringList(String node, List<String> def) {
List<String> res; List<String> res = parentConfig.getStringList(node, def);
if (config.getProperty(node) != null) {
res = config.getStringList(node, def);
} else {
res = parentConfig.getStringList(node, def);
}
if (res == null || res.size() == 0) { if (res == null || res.size() == 0) {
parentConfig.setProperty(node, new ArrayList<String>()); parentConfig.setProperty(node, new ArrayList<String>());
} }
if (config.getProperty(node) != null) {
res = config.getStringList(node, def);
}
return res; return res;
} }