mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-19 07:38:12 +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.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
import com.sk89q.worldedit.BlockVector2D;
|
||||||
@ -216,12 +217,27 @@ private <V> void addMarshalledFlag(Map<String, Object> flagData,
|
|||||||
private Map<String, Object> getDomainData(DefaultDomain domain) {
|
private Map<String, Object> getDomainData(DefaultDomain domain) {
|
||||||
Map<String, Object> domainData = new HashMap<String, Object>();
|
Map<String, Object> domainData = new HashMap<String, Object>();
|
||||||
|
|
||||||
domainData.put("players", domain.getPlayers());
|
setDomainData(domainData, "players", domain.getPlayers());
|
||||||
domainData.put("groups", domain.getGroups());
|
setDomainData(domainData, "groups", domain.getGroups());
|
||||||
|
|
||||||
return domainData;
|
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
|
@Override
|
||||||
public Map<String, ProtectedRegion> getRegions() {
|
public Map<String, ProtectedRegion> getRegions() {
|
||||||
return regions;
|
return regions;
|
||||||
|
@ -75,8 +75,8 @@ public Configuration(File file) {
|
|||||||
super(new HashMap<String, Object>());
|
super(new HashMap<String, Object>());
|
||||||
|
|
||||||
DumperOptions options = new DumperOptions();
|
DumperOptions options = new DumperOptions();
|
||||||
options.setIndent(4);
|
options.setIndent(2);
|
||||||
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
options.setDefaultFlowStyle(DumperOptions.FlowStyle.AUTO);
|
||||||
|
|
||||||
yaml = new Yaml(new SafeConstructor(), new Representer(), options);
|
yaml = new Yaml(new SafeConstructor(), new Representer(), options);
|
||||||
|
|
||||||
|
@ -158,9 +158,9 @@ public void setProperty(String path, Object value) {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ConfigurationNode addNode(String path) {
|
public ConfigurationNode addNode(String path) {
|
||||||
ConfigurationNode node = new ConfigurationNode(
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
new HashMap<String, Object>());
|
ConfigurationNode node = new ConfigurationNode(map);
|
||||||
setProperty(path, node);
|
setProperty(path, map);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user