use of de.dytanic.cloudnet.lib.network.WrapperExternal in project CloudNet by Dytanic.
the class PacketInWrapperInfo method handleInput.
@Override
public void handleInput(Document data, PacketSender packetSender) {
WrapperExternal wrapperExternal = data.getObject("wrapper", new TypeToken<WrapperExternal>() {
}.getType());
CloudNetWrapper.getInstance().setSimpledUser(wrapperExternal.getUser());
CloudNetWrapper.getInstance().getServerGroups().clear();
NetworkUtils.addAll(CloudNetWrapper.getInstance().getServerGroups(), wrapperExternal.getServerGroups(), new Acceptable<ServerGroup>() {
@Override
public boolean isAccepted(ServerGroup value) {
System.out.println("Importing server group [" + value.getName() + "] from CloudNet-Master");
return true;
}
});
CloudNetWrapper.getInstance().getProxyGroups().clear();
NetworkUtils.addAll(CloudNetWrapper.getInstance().getProxyGroups(), wrapperExternal.getProxyGroups(), new Acceptable<ProxyGroup>() {
@Override
public boolean isAccepted(ProxyGroup value) {
System.out.println("Importing proxy group [" + value.getName() + "] from CloudNet-Master");
return true;
}
});
}
use of de.dytanic.cloudnet.lib.network.WrapperExternal in project CloudNet by Dytanic.
the class Wrapper method updateWrapper.
public Wrapper updateWrapper() {
if (getChannel() == null)
return this;
java.util.Map<String, ServerGroup> groups = NetworkUtils.newConcurrentHashMap();
for (ServerGroup serverGroup : CloudNet.getInstance().getServerGroups().values()) if (serverGroup.getWrapper().contains(networkInfo.getId())) {
groups.put(serverGroup.getName(), serverGroup);
sendPacket(new PacketOutCreateTemplate(serverGroup));
}
java.util.Map<String, ProxyGroup> proxyGroups = NetworkUtils.newConcurrentHashMap();
for (ProxyGroup serverGroup : CloudNet.getInstance().getProxyGroups().values()) if (serverGroup.getWrapper().contains(networkInfo.getId())) {
proxyGroups.put(serverGroup.getName(), serverGroup);
sendPacket(new PacketOutCreateTemplate(serverGroup));
}
SimpledUser simpledUser = null;
User user = CollectionWrapper.filter(CloudNet.getInstance().getUsers(), new Acceptable<User>() {
@Override
public boolean isAccepted(User value) {
return networkInfo.getUser().equals(value.getName());
}
});
if (user != null) {
simpledUser = user.toSimple();
}
WrapperExternal wrapperExternal = new WrapperExternal(CloudNet.getInstance().getNetworkManager().newCloudNetwork(), simpledUser, groups, proxyGroups);
sendPacket(new PacketOutWrapperInfo(wrapperExternal));
return this;
}
Aggregations