Search in sources :

Example 1 with ProxyAddListener

use of de.dytanic.cloudnetcore.cloudflare.listener.ProxyAddListener 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

CloudFlareService (de.dytanic.cloudnet.cloudflare.CloudFlareService)1 CloudFlareDatabase (de.dytanic.cloudnet.cloudflare.database.CloudFlareDatabase)1 SimpledWrapperInfo (de.dytanic.cloudnet.lib.service.SimpledWrapperInfo)1 Catcher (de.dytanic.cloudnet.lib.utility.Catcher)1 MapWrapper (de.dytanic.cloudnet.lib.utility.MapWrapper)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