Search in sources :

Example 6 with ServerInfo

use of de.dytanic.cloudnet.lib.server.info.ServerInfo in project CloudNet by Dytanic.

the class PacketInCopyDirectory method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    if (!data.contains("directory") || !data.contains("serverInfo"))
        return;
    ServerInfo serverInfo = data.getObject("serverInfo", ServerInfo.TYPE);
    GameServer gameServer = CloudNetWrapper.getInstance().getServers().get(serverInfo.getServiceId().getServerId());
    if (gameServer == null)
        return;
    if (gameServer.getServerProcess().getMeta().getTemplate().getBackend().equals(TemplateResource.LOCAL))
        gameServer.copyDirectory(data.getString("directory"));
}
Also used : ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo) GameServer(de.dytanic.cloudnetwrapper.server.GameServer)

Example 7 with ServerInfo

use of de.dytanic.cloudnet.lib.server.info.ServerInfo in project CloudNet by Dytanic.

the class PacketInCopyServer method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    ServerInfo serverInfo = data.getObject("serverInfo", new TypeToken<ServerInfo>() {
    }.getType());
    GameServer gameServer = CloudNetWrapper.getInstance().getServers().get(serverInfo.getServiceId().getServerId());
    if (gameServer != null) {
        if (!data.contains("template")) {
            CloudNetWrapper.getInstance().getScheduler().runTaskAsync(new Runnable() {

                @Override
                public void run() {
                    gameServer.copy();
                }
            });
        } else {
            CloudNetWrapper.getInstance().getScheduler().runTaskAsync(new Runnable() {

                @Override
                public void run() {
                    gameServer.copy(data.getObject("template", new TypeToken<Template>() {
                    }.getType()));
                }
            });
        }
    }
}
Also used : ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo) TypeToken(com.google.gson.reflect.TypeToken) GameServer(de.dytanic.cloudnetwrapper.server.GameServer)

Example 8 with ServerInfo

use of de.dytanic.cloudnet.lib.server.info.ServerInfo in project CloudNet by Dytanic.

the class ProxiedListener method handleServerKick.

@EventHandler
public void handleServerKick(ServerKickEvent e) {
    if (e.getCancelServer() != null) {
        ServerInfo serverInfo = CloudProxy.getInstance().getCachedServers().get(e.getKickedFrom().getName());
        String fallback;
        if (CloudAPI.getInstance().getServerGroupData(serverInfo.getServiceId().getGroup()) != null && CloudAPI.getInstance().getServerGroupData(serverInfo.getServiceId().getGroup()).isKickedForceFallback()) {
            fallback = CloudProxy.getInstance().fallbackOnEnabledKick(e.getPlayer(), serverInfo.getServiceId().getGroup(), e.getKickedFrom().getName());
        } else {
            fallback = CloudProxy.getInstance().fallback(e.getPlayer(), e.getKickedFrom().getName());
        }
        ProxiedPlayerFallbackEvent proxiedPlayerFallbackEvent = new ProxiedPlayerFallbackEvent(e.getPlayer(), CloudAPI.getInstance().getOnlinePlayer(e.getPlayer().getUniqueId()), ProxiedPlayerFallbackEvent.FallbackType.SERVER_KICK, fallback);
        ProxyServer.getInstance().getPluginManager().callEvent(proxiedPlayerFallbackEvent);
        fallback = proxiedPlayerFallbackEvent.getFallback();
        if (fallback != null) {
            e.setCancelled(true);
            e.setCancelServer((ProxyServer.getInstance().getServerInfo(fallback)));
            e.getPlayer().sendMessage(e.getKickReasonComponent());
        }
    }
}
Also used : ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo) ProxiedPlayerFallbackEvent(de.dytanic.cloudnet.bridge.event.proxied.ProxiedPlayerFallbackEvent) EventHandler(net.md_5.bungee.event.EventHandler)

Example 9 with ServerInfo

use of de.dytanic.cloudnet.lib.server.info.ServerInfo in project CloudNet by Dytanic.

the class MobSelector method getOnlineCount.

public Return<Integer, Integer> getOnlineCount(String group) {
    int atomicInteger = 0;
    int atomicInteger1 = 0;
    for (ServerInfo serverInfo : this.servers.values()) {
        if (serverInfo.getServiceId().getGroup().equalsIgnoreCase(group)) {
            atomicInteger = atomicInteger + serverInfo.getOnlineCount();
            atomicInteger1 = atomicInteger1 + serverInfo.getMaxPlayers();
        }
    }
    return new Return<>(atomicInteger, atomicInteger1);
}
Also used : ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo)

Example 10 with ServerInfo

use of de.dytanic.cloudnet.lib.server.info.ServerInfo in project CloudNet by Dytanic.

the class MobSelector method init.

public void init() {
    CloudAPI.getInstance().getNetworkHandlerProvider().registerHandler(new NetworkHandlerAdapterImplx());
    Bukkit.getScheduler().runTask(CloudServer.getInstance().getPlugin(), new Runnable() {

        @Override
        public void run() {
            NetworkUtils.addAll(servers, MapWrapper.collectionCatcherHashMap(CloudAPI.getInstance().getServers(), new Catcher<String, ServerInfo>() {

                @Override
                public String doCatch(ServerInfo key) {
                    return key.getServiceId().getServerId();
                }
            }));
            Bukkit.getScheduler().runTaskAsynchronously(CloudServer.getInstance().getPlugin(), new Runnable() {

                @Override
                public void run() {
                    for (ServerInfo serverInfo : servers.values()) {
                        handleUpdate(serverInfo);
                    }
                }
            });
        }
    });
    if (ReflectionUtil.forName("org.bukkit.entity.ArmorStand") != null) {
        try {
            Bukkit.getPluginManager().registerEvents((Listener) ReflectionUtil.forName("de.dytanic.cloudnet.bridge.internal.listener.v18_112.ArmorStandListener").newInstance(), CloudServer.getInstance().getPlugin());
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    Bukkit.getPluginManager().registerEvents(new ListenrImpl(), CloudServer.getInstance().getPlugin());
}
Also used : ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo)

Aggregations

ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)24 TypeToken (com.google.gson.reflect.TypeToken)6 Wrapper (de.dytanic.cloudnetcore.network.components.Wrapper)5 ArrayList (java.util.ArrayList)5 ServerGroup (de.dytanic.cloudnet.lib.server.ServerGroup)4 Document (de.dytanic.cloudnet.lib.utility.document.Document)4 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)3 ServerFallback (de.dytanic.cloudnet.lib.proxylayout.ServerFallback)3 Properties (java.util.Properties)3 PacketOutUpdateServerInfo (de.dytanic.cloudnet.api.network.packet.out.PacketOutUpdateServerInfo)2 ProxiedPlayerFallbackEvent (de.dytanic.cloudnet.bridge.event.proxied.ProxiedPlayerFallbackEvent)2 ConnectableAddress (de.dytanic.cloudnet.lib.ConnectableAddress)2 OfflinePlayer (de.dytanic.cloudnet.lib.player.OfflinePlayer)2 ServerConfig (de.dytanic.cloudnet.lib.server.ServerConfig)2 Template (de.dytanic.cloudnet.lib.server.template.Template)2 ServerInstallablePlugin (de.dytanic.cloudnet.lib.service.plugin.ServerInstallablePlugin)2 SimpledUser (de.dytanic.cloudnet.lib.user.SimpledUser)2 Acceptable (de.dytanic.cloudnet.lib.utility.Acceptable)2 ScheduledTask (de.dytanic.cloudnet.lib.utility.threading.ScheduledTask)2 CloudServer (de.dytanic.cloudnetcore.network.components.CloudServer)2