mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-18 23:27:35 +01:00
Improved YAML loading/saving.
This commit is contained in:
parent
649db3aca2
commit
9803d6b731
@ -25,6 +25,7 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
@ -216,12 +217,27 @@ private <V> void addMarshalledFlag(Map<String, Object> flagData,
|
||||
private Map<String, Object> getDomainData(DefaultDomain domain) {
|
||||
Map<String, Object> domainData = new HashMap<String, Object>();
|
||||
|
||||
domainData.put("players", domain.getPlayers());
|
||||
domainData.put("groups", domain.getGroups());
|
||||
setDomainData(domainData, "players", domain.getPlayers());
|
||||
setDomainData(domainData, "groups", domain.getGroups());
|
||||
|
||||
return domainData;
|
||||
}
|
||||
|
||||
private void setDomainData(Map<String, Object> domainData,
|
||||
String key, Set<String> domain) {
|
||||
if (domain.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> list = new ArrayList<String>();
|
||||
|
||||
for (String str : domain) {
|
||||
list.add(str);
|
||||
}
|
||||
|
||||
domainData.put(key, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ProtectedRegion> getRegions() {
|
||||
return regions;
|
||||
|
@ -75,8 +75,8 @@ public Configuration(File file) {
|
||||
super(new HashMap<String, Object>());
|
||||
|
||||
DumperOptions options = new DumperOptions();
|
||||
options.setIndent(4);
|
||||
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
options.setIndent(2);
|
||||
options.setDefaultFlowStyle(DumperOptions.FlowStyle.AUTO);
|
||||
|
||||
yaml = new Yaml(new SafeConstructor(), new Representer(), options);
|
||||
|
||||
|
@ -158,9 +158,9 @@ public void setProperty(String path, Object value) {
|
||||
* @return
|
||||
*/
|
||||
public ConfigurationNode addNode(String path) {
|
||||
ConfigurationNode node = new ConfigurationNode(
|
||||
new HashMap<String, Object>());
|
||||
setProperty(path, node);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
ConfigurationNode node = new ConfigurationNode(map);
|
||||
setProperty(path, map);
|
||||
return node;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user