diff options
author | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-12-09 15:50:20 +0000 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2011-12-09 15:50:20 +0000 |
commit | 397d0f284af523a9ed77d58eea32f57e2e8f9155 (patch) | |
tree | a67c125bcad5bf9b593a2ebec9b6b55b4e90219b | |
parent | 56f4e89e06b3ddd6a3e2acddbbd1371a7e9f7c3c (diff) | |
download | bukkit-397d0f284af523a9ed77d58eea32f57e2e8f9155.tar bukkit-397d0f284af523a9ed77d58eea32f57e2e8f9155.tar.gz bukkit-397d0f284af523a9ed77d58eea32f57e2e8f9155.tar.lz bukkit-397d0f284af523a9ed77d58eea32f57e2e8f9155.tar.xz bukkit-397d0f284af523a9ed77d58eea32f57e2e8f9155.zip |
Fixed MemorySection list methods' return types + NPEs. This fixes BUKKIT-213, thanks to Sleaker
-rw-r--r-- | src/main/java/org/bukkit/configuration/MemorySection.java | 63 |
1 files changed, 54 insertions, 9 deletions
diff --git a/src/main/java/org/bukkit/configuration/MemorySection.java b/src/main/java/org/bukkit/configuration/MemorySection.java index 68254d0a..7f4ea7cf 100644 --- a/src/main/java/org/bukkit/configuration/MemorySection.java +++ b/src/main/java/org/bukkit/configuration/MemorySection.java @@ -445,12 +445,17 @@ public class MemorySection implements ConfigurationSection { return val instanceof List; } - public List getStringList(String path) { + public List<String> getStringList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List<Object> list = getList(path); + + if (list == null) { + return null; + } + List<String> result = new ArrayList(); for (Object object : list) { @@ -462,12 +467,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getIntegerList(String path) { + public List<Integer> getIntegerList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List<Object> list = getList(path); + + if (list == null) { + return null; + } + List<Integer> result = new ArrayList(); for (Object object : list) { @@ -497,12 +507,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getBooleanList(String path) { + public List<Boolean> getBooleanList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List<Object> list = getList(path); + + if (list == null) { + return null; + } + List<Boolean> result = new ArrayList(); for (Object object : list) { @@ -520,12 +535,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getDoubleList(String path) { + public List<Double> getDoubleList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List<Object> list = getList(path); + + if (list == null) { + return null; + } + List<Double> result = new ArrayList(); for (Object object : list) { @@ -555,12 +575,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getFloatList(String path) { + public List<Float> getFloatList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List<Object> list = getList(path); + + if (list == null) { + return null; + } + List<Float> result = new ArrayList(); for (Object object : list) { @@ -590,12 +615,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getLongList(String path) { + public List<Long> getLongList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List<Object> list = getList(path); + + if (list == null) { + return null; + } + List<Long> result = new ArrayList(); for (Object object : list) { @@ -625,12 +655,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getByteList(String path) { + public List<Byte> getByteList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List<Object> list = getList(path); + + if (list == null) { + return null; + } + List<Byte> result = new ArrayList(); for (Object object : list) { @@ -660,12 +695,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getCharacterList(String path) { + public List<Character> getCharacterList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List<Object> list = getList(path); + + if (list == null) { + return null; + } + List<Character> result = new ArrayList(); for (Object object : list) { @@ -697,12 +737,17 @@ public class MemorySection implements ConfigurationSection { return result; } - public List getShortList(String path) { + public List<Short> getShortList(String path) { if (path == null) { throw new IllegalArgumentException("Path cannot be null"); } List<Object> list = getList(path); + + if (list == null) { + return null; + } + List<Short> result = new ArrayList(); for (Object object : list) { |