Search in sources :

Example 61 with Document

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);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LocalCloudWrapper(de.dytanic.cloudnetcore.setup.LocalCloudWrapper) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Example 62 with Document

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;
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document) File(java.io.File)

Example 63 with 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;
}
Also used : SignLayout(de.dytanic.cloudnet.lib.serverselectors.sign.SignLayout) SignLayoutConfig(de.dytanic.cloudnet.lib.serverselectors.sign.SignLayoutConfig) TypeToken(com.google.gson.reflect.TypeToken) Acceptable(de.dytanic.cloudnet.lib.utility.Acceptable) SignGroupLayouts(de.dytanic.cloudnet.lib.serverselectors.sign.SignGroupLayouts) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Example 64 with Document

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;
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document) DatabaseDocument(de.dytanic.cloudnet.lib.database.DatabaseDocument)

Example 65 with Document

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;
}
Also used : Type(java.lang.reflect.Type) Sign(de.dytanic.cloudnet.lib.serverselectors.sign.Sign) Document(de.dytanic.cloudnet.lib.utility.document.Document) DatabaseDocument(de.dytanic.cloudnet.lib.database.DatabaseDocument) UUID(java.util.UUID) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Document (de.dytanic.cloudnet.lib.utility.document.Document)69 DatabaseDocument (de.dytanic.cloudnet.lib.database.DatabaseDocument)26 TypeToken (com.google.gson.reflect.TypeToken)7 ArrayList (java.util.ArrayList)7 File (java.io.File)6 UUID (java.util.UUID)6 OfflinePlayer (de.dytanic.cloudnet.lib.player.OfflinePlayer)5 ServerGroup (de.dytanic.cloudnet.lib.server.ServerGroup)5 ServerConfig (de.dytanic.cloudnet.lib.server.ServerConfig)4 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)4 HttpURLConnection (java.net.HttpURLConnection)4 URL (java.net.URL)4 ConnectableAddress (de.dytanic.cloudnet.lib.ConnectableAddress)3 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)3 Template (de.dytanic.cloudnet.lib.server.template.Template)3 ServerInstallablePlugin (de.dytanic.cloudnet.lib.service.plugin.ServerInstallablePlugin)3 SimpledUser (de.dytanic.cloudnet.lib.user.SimpledUser)3 Acceptable (de.dytanic.cloudnet.lib.utility.Acceptable)3 MinecraftServer (de.dytanic.cloudnetcore.network.components.MinecraftServer)3 IOException (java.io.IOException)3