Added createSection(String path, Map<String, object> map)

By: Feildmaster <admin@feildmaster.com>
This commit is contained in:
Bukkit/Spigot
2011-11-01 22:04:48 -05:00
parent 04ccdf16fd
commit 867d2bc046
4 changed files with 39 additions and 1 deletions

View File

@@ -164,6 +164,17 @@ public interface ConfigurationSection {
* @return Newly created section
*/
public ConfigurationSection createSection(String path);
/**
* Creates a {@link ConfigurationSection} at the specified path, with specified values.
* <p>
* Any value that was previously set at this path will be overwritten. If the
* previous value was itself a {@link ConfigurationSection}, it will be orphaned.
*
* @param path Path to create the section at.
* @return Newly created section
*/
public ConfigurationSection createSection(String path, Map<String, Object> map);
// Primitives
/**

View File

@@ -266,6 +266,20 @@ public class MemorySection implements ConfigurationSection {
return section.createSection(key);
}
}
public ConfigurationSection createSection(String path, Map<String, Object> map) {
ConfigurationSection section = createSection(path);
for(Map.Entry<String, Object> entry : map.entrySet()) {
if(entry.getValue() instanceof Map) {
section.createSection(entry.getKey(), (Map<String, Object>)entry.getValue());
} else {
section.set(entry.getKey(), entry.getValue());
}
}
return section;
}
// Primitives
public String getString(String path) {