Search in sources :

Example 1 with WrapperMeta

use of de.dytanic.cloudnetcore.network.components.WrapperMeta in project CloudNet by Dytanic.

the class CloudConfig method createWrapper.

public void createWrapper(WrapperMeta wrapperMeta) {
    Collection<WrapperMeta> wrapperMetas = this.serviceDocument.getObject("wrapper", new TypeToken<Collection<WrapperMeta>>() {
    }.getType());
    WrapperMeta is = CollectionWrapper.filter(wrapperMetas, new Acceptable<WrapperMeta>() {

        @Override
        public boolean isAccepted(WrapperMeta wrapperMeta_) {
            return wrapperMeta_.getId().equalsIgnoreCase(wrapperMeta.getId());
        }
    });
    if (is != null)
        wrapperMetas.remove(is);
    wrapperMetas.add(wrapperMeta);
    this.serviceDocument.append("wrapper", wrapperMetas).saveAsConfig(servicePath);
    CloudNet.getInstance().getWrappers().put(wrapperMeta.getId(), new Wrapper(wrapperMeta));
}
Also used : MapWrapper(de.dytanic.cloudnet.lib.utility.MapWrapper) CollectionWrapper(de.dytanic.cloudnet.lib.utility.CollectionWrapper) Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) WrapperMeta(de.dytanic.cloudnetcore.network.components.WrapperMeta) TypeToken(com.google.gson.reflect.TypeToken)

Example 2 with WrapperMeta

use of de.dytanic.cloudnetcore.network.components.WrapperMeta in project CloudNet by Dytanic.

the class CloudConfig method defaultInitDoc.

private void defaultInitDoc(ConsoleReader consoleReader) throws Exception {
    if (Files.exists(servicePath))
        return;
    String hostName = NetworkUtils.getHostName();
    if (hostName.equals("127.0.0.1") || hostName.equalsIgnoreCase("127.0.1.1") || hostName.split("\\.").length != 4) {
        String input;
        System.out.println("Please write the first Wrapper IP address:");
        while ((input = consoleReader.readLine()) != null) {
            if ((input.equals("127.0.0.1") || input.equalsIgnoreCase("127.0.1.1") || input.split("\\.").length != 4)) {
                System.out.println("Please write the real ip address :)");
                continue;
            }
            hostName = input;
            break;
        }
    }
    new Document("wrapper", Arrays.asList(new WrapperMeta("Wrapper-1", hostName, "admin"))).append("proxyGroups", Arrays.asList(new BungeeGroup())).saveAsConfig(servicePath);
    new Document("group", new LobbyGroup()).saveAsConfig(Paths.get("groups/Lobby.json"));
}
Also used : WrapperMeta(de.dytanic.cloudnetcore.network.components.WrapperMeta) BungeeGroup(de.dytanic.cloudnetcore.util.defaults.BungeeGroup) Document(de.dytanic.cloudnet.lib.utility.document.Document) LobbyGroup(de.dytanic.cloudnetcore.util.defaults.LobbyGroup)

Aggregations

WrapperMeta (de.dytanic.cloudnetcore.network.components.WrapperMeta)2 TypeToken (com.google.gson.reflect.TypeToken)1 CollectionWrapper (de.dytanic.cloudnet.lib.utility.CollectionWrapper)1 MapWrapper (de.dytanic.cloudnet.lib.utility.MapWrapper)1 Document (de.dytanic.cloudnet.lib.utility.document.Document)1 Wrapper (de.dytanic.cloudnetcore.network.components.Wrapper)1 BungeeGroup (de.dytanic.cloudnetcore.util.defaults.BungeeGroup)1 LobbyGroup (de.dytanic.cloudnetcore.util.defaults.LobbyGroup)1