Implement default assignment system (#25)

This commit is contained in:
Luck committed 2016-10-16 13:58:57 +01:00
1 parent 02a75fc32a
commit 13fbc7dd39
12 files changed
+578 -54

No files matched your search

@@ -34,6 +34,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -97,9 +98,33 @@ class SpongeConfig extends AbstractConfiguration<LPSpongePlugin> {
return getNode(path).getBoolean(def);
}
@Override
protected List<String> getList(String path, List<String> def) {
ConfigurationNode node = getNode(path);
if (node.isVirtual()) {
return def;
}
return node.getList(Object::toString);
}
@Override
protected List<String> getObjectList(String path, List<String> def) {
ConfigurationNode node = getNode(path);
if (node.isVirtual()) {
return def;
}
return node.getChildrenList().stream().map(n -> (String) n.getKey()).collect(Collectors.toList());
}
@Override
protected Map<String, String> getMap(String path, Map<String, String> def) {
ConfigurationNode node = getNode(path);
if (node.isVirtual()) {
return def;
}
return node.getChildrenList().stream().collect(Collectors.toMap(n -> (String) n.getKey(), ConfigurationNode::getString));
}
}