Search in sources :

Example 1 with Catcher

use of de.dytanic.cloudnet.lib.utility.Catcher in project CloudNet by Dytanic.

the class NetworkManager method newCloudNetwork.

public CloudNetwork newCloudNetwork() {
    CloudNetwork cloudNetwork = new CloudNetwork();
    cloudNetwork.setOnlineCount(getOnlineCount());
    cloudNetwork.setMessages(messageConfig.load());
    cloudNetwork.setModules(moduleProperties);
    // cloudNetwork.setNotifySystem(CloudNet.getInstance().getConfig().isNotifyService());
    cloudNetwork.setWebPort(CloudNet.getInstance().getConfig().getWebServerConfig().getPort());
    // cloudNetwork.setDevServices(CloudNet.getInstance().getConfig().isCloudDevServices());
    Collection<WrapperInfo> wrappers = new LinkedList<>();
    for (Wrapper wrapper : CloudNet.getInstance().getWrappers().values()) if (wrapper.getWrapperInfo() != null)
        wrappers.add(wrapper.getWrapperInfo());
    cloudNetwork.setWrappers(wrappers);
    cloudNetwork.setServerGroups(MapWrapper.transform(CloudNet.getInstance().getServerGroups(), new Catcher<String, String>() {

        @Override
        public String doCatch(String key) {
            return key;
        }
    }, new Catcher<SimpleServerGroup, ServerGroup>() {

        @Override
        public SimpleServerGroup doCatch(ServerGroup key) {
            return key.toSimple();
        }
    }));
    // cloudNetwork.setPermissionPool(permissionPool);
    cloudNetwork.setProxyGroups(CloudNet.getInstance().getProxyGroups());
    cloudNetwork.setModules(moduleProperties);
    return cloudNetwork;
}
Also used : Catcher(de.dytanic.cloudnet.lib.utility.Catcher) MapWrapper(de.dytanic.cloudnet.lib.utility.MapWrapper) CollectionWrapper(de.dytanic.cloudnet.lib.utility.CollectionWrapper) ServerGroup(de.dytanic.cloudnet.lib.server.ServerGroup) SimpleServerGroup(de.dytanic.cloudnet.lib.server.SimpleServerGroup) WrapperInfo(de.dytanic.cloudnet.lib.network.WrapperInfo) CloudNetwork(de.dytanic.cloudnet.lib.CloudNetwork)

Example 2 with Catcher

use of de.dytanic.cloudnet.lib.utility.Catcher in project CloudNet by Dytanic.

the class CloudFlareModule method onBootstrap.

@Override
public void onBootstrap() {
    configCloudFlare = new ConfigCloudFlare();
    cloudFlareDatabase = new CloudFlareDatabase(getCloud().getDatabaseManager().getDatabase("cloud_internal_cfg"));
    try {
        CloudFlareService cloudFlareAPI = new CloudFlareService(configCloudFlare.load());
        cloudFlareAPI.bootstrap(MapWrapper.transform(getCloud().getWrappers(), new Catcher<String, String>() {

            @Override
            public String doCatch(String key) {
                return key;
            }
        }, new Catcher<SimpledWrapperInfo, Wrapper>() {

            @Override
            public SimpledWrapperInfo doCatch(Wrapper key) {
                return new SimpledWrapperInfo(key.getServerId(), key.getNetworkInfo().getHostName());
            }
        }), getCloud().getProxyGroups(), cloudFlareDatabase);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    getCloud().getEventManager().registerListener(this, new ProxyAddListener());
    getCloud().getEventManager().registerListener(this, new ProxyRemoveListener());
}
Also used : CloudFlareService(de.dytanic.cloudnet.cloudflare.CloudFlareService) Catcher(de.dytanic.cloudnet.lib.utility.Catcher) MapWrapper(de.dytanic.cloudnet.lib.utility.MapWrapper) Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) CloudFlareDatabase(de.dytanic.cloudnet.cloudflare.database.CloudFlareDatabase) SimpledWrapperInfo(de.dytanic.cloudnet.lib.service.SimpledWrapperInfo) ProxyAddListener(de.dytanic.cloudnetcore.cloudflare.listener.ProxyAddListener) ConfigCloudFlare(de.dytanic.cloudnetcore.cloudflare.config.ConfigCloudFlare) ProxyRemoveListener(de.dytanic.cloudnetcore.cloudflare.listener.ProxyRemoveListener)

Aggregations

Catcher (de.dytanic.cloudnet.lib.utility.Catcher)2 MapWrapper (de.dytanic.cloudnet.lib.utility.MapWrapper)2 CloudFlareService (de.dytanic.cloudnet.cloudflare.CloudFlareService)1 CloudFlareDatabase (de.dytanic.cloudnet.cloudflare.database.CloudFlareDatabase)1 CloudNetwork (de.dytanic.cloudnet.lib.CloudNetwork)1 WrapperInfo (de.dytanic.cloudnet.lib.network.WrapperInfo)1 ServerGroup (de.dytanic.cloudnet.lib.server.ServerGroup)1 SimpleServerGroup (de.dytanic.cloudnet.lib.server.SimpleServerGroup)1 SimpledWrapperInfo (de.dytanic.cloudnet.lib.service.SimpledWrapperInfo)1 CollectionWrapper (de.dytanic.cloudnet.lib.utility.CollectionWrapper)1 ConfigCloudFlare (de.dytanic.cloudnetcore.cloudflare.config.ConfigCloudFlare)1 ProxyAddListener (de.dytanic.cloudnetcore.cloudflare.listener.ProxyAddListener)1 ProxyRemoveListener (de.dytanic.cloudnetcore.cloudflare.listener.ProxyRemoveListener)1 Wrapper (de.dytanic.cloudnetcore.network.components.Wrapper)1