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));
}
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"));
}
Aggregations