summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNathan Adams <dinnerbone@dinnerbone.com>2011-10-11 13:26:41 +0100
committerNathan Adams <dinnerbone@dinnerbone.com>2011-10-11 13:26:41 +0100
commit8deb57b54af75b7c1ba7573f3ed4ab8e0763c400 (patch)
treeff2465c3b5547141e4f51468ec4b2639fb56aa2c /src
parent252fc76816b4f66cb52d2851b52b896cb4788618 (diff)
downloadbukkit-8deb57b54af75b7c1ba7573f3ed4ab8e0763c400.tar
bukkit-8deb57b54af75b7c1ba7573f3ed4ab8e0763c400.tar.gz
bukkit-8deb57b54af75b7c1ba7573f3ed4ab8e0763c400.tar.lz
bukkit-8deb57b54af75b7c1ba7573f3ed4ab8e0763c400.tar.xz
bukkit-8deb57b54af75b7c1ba7573f3ed4ab8e0763c400.zip
Fixed deeply nested configuration sections retrieving values
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/configuration/MemorySection.java23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/main/java/org/bukkit/configuration/MemorySection.java b/src/main/java/org/bukkit/configuration/MemorySection.java
index bf2cfb00..fa330e64 100644
--- a/src/main/java/org/bukkit/configuration/MemorySection.java
+++ b/src/main/java/org/bukkit/configuration/MemorySection.java
@@ -205,29 +205,34 @@ public class MemorySection implements ConfigurationSection {
}
public Object get(String path, Object def) {
- Object result = null;
- String[] split = path.split(Pattern.quote(Character.toString(getRoot().options().pathSeparator())));
- ConfigurationSection section = this;
-
if (path == null) {
throw new IllegalArgumentException("Path cannot be null");
} else if (path.length() == 0) {
return this;
}
- for (int i = 0; (i < split.length - 1) && (section != null); i++) {
- section = getConfigurationSection(split[i]);
+ Object result = null;
+ String[] split = path.split(Pattern.quote(Character.toString(getRoot().options().pathSeparator())));
+ ConfigurationSection section = this;
+
+ for (int i = 0; i < split.length - 1; i++) {
+ section = section.getConfigurationSection(split[i]);
+
+ if (section == null) {
+ return def;
+ }
}
String key = split[split.length - 1];
if (section == this) {
result = map.get(key);
+ return (result == null) ? def : result;
} else if (section != null) {
- result = section.get(key);
+ return section.get(key, def);
+ } else {
+ return def;
}
-
- return (result == null) ? def : result;
}
public ConfigurationSection createSection(String path) {