use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class CloudNet method startProxy.
public void startProxy(ProxyGroup proxyGroup) {
Wrapper wrapper = fetchPerformanceWrapper(proxyGroup.getMemory(), toWrapperInstances(proxyGroup.getWrapper()));
if (wrapper == null)
return;
Collection<Integer> collection = CollectionWrapper.getCollection(getProxys(), new Catcher<Integer, ProxyServer>() {
@Override
public Integer doCatch(ProxyServer key) {
return key.getProxyInfo().getPort();
}
});
collection.addAll(wrapper.getBinndedPorts());
int startport = proxyGroup.getStartPort();
while (collection.contains(startport)) {
startport++;
}
ProxyProcessMeta proxyProcessMeta = new ProxyProcessMeta(newServiceId(proxyGroup, wrapper), proxyGroup.getMemory(), startport, new String[] {}, null, Arrays.asList(), new Document());
wrapper.startProxy(proxyProcessMeta);
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class DatabaseImpl method getDocument.
@Override
public Document getDocument(String name) {
Document document = documents.get(name);
if (document == null) {
File doc = new File("database/" + this.name + NetworkUtils.SLASH_STRING + name);
if (doc.exists()) {
document = Document.loadDocument(doc);
this.documents.put(doc.getName(), document);
return document;
}
}
return document;
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class ConfigSignLayout method loadLayout.
public de.dytanic.cloudnet.lib.serverselectors.sign.SignLayoutConfig loadLayout() {
Document document = Document.loadDocument(path);
if (!document.getDocument("layout_config").contains("knockbackOnSmallDistance")) {
Document document1 = document.getDocument("layout_config").append("knockbackOnSmallDistance", false);
document.append("layout_config", document1);
document.saveAsConfig(path);
}
if (!document.getDocument("layout_config").contains("distance")) {
Document document1 = document.getDocument("layout_config").append("distance", 1D);
document.append("layout_config", document1);
document.saveAsConfig(path);
}
if (!document.getDocument("layout_config").contains("strength")) {
Document document1 = document.getDocument("layout_config").append("strength", 0.8D);
document.append("layout_config", document1);
document.saveAsConfig(path);
}
SignLayoutConfig signLayoutConfig = document.getObject("layout_config", new TypeToken<de.dytanic.cloudnet.lib.serverselectors.sign.SignLayoutConfig>() {
}.getType());
boolean injectable = false;
for (SignGroupLayouts groupLayouts : signLayoutConfig.getGroupLayouts()) {
{
SignLayout signLayout = CollectionWrapper.filter(groupLayouts.getLayouts(), new Acceptable<SignLayout>() {
@Override
public boolean isAccepted(SignLayout signLayout) {
return signLayout.getName().equalsIgnoreCase("empty");
}
});
if (signLayout == null) {
groupLayouts.getLayouts().add(new SignLayout("empty", new String[] { "%server%", "&6%state%", "%online_players%/%max_players%", "%motd%" }, 159, 1));
injectable = true;
}
}
}
if (injectable) {
document.append("layout_config", signLayoutConfig).saveAsConfig(path);
}
return signLayoutConfig;
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class SignDatabase method removeSign.
public SignDatabase removeSign(UUID uniqueId) {
Document x = database.getDocument("signs");
Document document = x.getDocument("signs");
document.remove(uniqueId.toString());
database.insert(document);
return this;
}
use of de.dytanic.cloudnet.lib.utility.document.Document in project CloudNet by Dytanic.
the class SignDatabase method loadAll.
public java.util.Map<UUID, Sign> loadAll() {
Document x = database.getDocument("signs");
Document document = x.getDocument("signs");
Type typeToken = new TypeToken<Sign>() {
}.getType();
java.util.Map<UUID, Sign> signs = new LinkedHashMap<>();
for (String key : document.keys()) {
signs.put(UUID.fromString(key), document.getObject(key, typeToken));
}
return signs;
}
Aggregations