use of de.dytanic.cloudnet.lib.server.ServerGroup in project CloudNet by Dytanic.
the class CloudConfig method getServerGroups.
public java.util.Map<String, ServerGroup> getServerGroups() {
/*
Collection<ServerGroup> collection = serviceDocument.getObject("serverGroups", new TypeToken<Collection<ServerGroup>>() {
}.getType());
return MapWrapper.collectionCatcherHashMap(collection, new Catcher<String, ServerGroup>() {
@Override
public String doCatch(ServerGroup key)
{
return key.getName();
}
});
*/
Map<String, ServerGroup> groups = NetworkUtils.newConcurrentHashMap();
if (serviceDocument.contains("serverGroups")) {
Collection<ServerGroup> collection = serviceDocument.getObject("serverGroups", new TypeToken<Collection<ServerGroup>>() {
}.getType());
for (ServerGroup serverGroup : collection) createGroup(serverGroup);
serviceDocument.remove("serverGroups");
serviceDocument.saveAsConfig(servicePath);
}
File groupsDirectory = new File("groups");
Document entry;
if (groupsDirectory.isDirectory())
for (File file : groupsDirectory.listFiles()) {
if (file.getName().endsWith(".json"))
try {
entry = Document.$loadDocument(file);
ServerGroup serverGroup = entry.getObject("group", ServerGroup.TYPE);
groups.put(serverGroup.getName(), serverGroup);
} catch (Throwable ex) {
System.out.println("Cannot load servergroup file [" + file.getName() + "]");
}
}
return groups;
}
Aggregations