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