use of de.dytanic.cloudnetcore.network.components.MinecraftServer in project CloudNet by Dytanic.
the class CommandList method onExecuteCommand.
@Override
public void onExecuteCommand(CommandSender sender, String[] args) {
sender.sendMessage("CloudNet: ");
int memory = 0, maxMemory = 0;
for (Wrapper wrapper : CloudNet.getInstance().getWrappers().values()) {
memory += wrapper.getUsedMemory();
maxMemory += wrapper.getMaxMemory();
sender.sendMessage("Wrapper: [" + wrapper.getServerId() + "] @" + wrapper.getNetworkInfo().getHostName());
sender.sendMessage("Info: CPU Usage: " + NetworkUtils.DECIMAL_FORMAT.format(wrapper.getCpuUsage()) + "/100% | Memory: " + wrapper.getUsedMemory() + NetworkUtils.SLASH_STRING + wrapper.getMaxMemory() + "MB");
sender.sendMessage(" ", "Proxys:");
for (ProxyServer proxyServer : wrapper.getProxys().values()) {
sender.sendMessage("Proxy [" + proxyServer.getServerId() + "] @" + proxyServer.getNetworkInfo().getHostName() + " | " + proxyServer.getProxyInfo().getOnlineCount() + NetworkUtils.SLASH_STRING + CloudNet.getInstance().getProxyGroups().get(proxyServer.getProxyInfo().getServiceId().getGroup()).getProxyConfig().getMaxPlayers() + " | State: " + (proxyServer.getChannel() != null ? "connected" : "not connected"));
}
sender.sendMessage(" ", "Servers:");
for (MinecraftServer proxyServer : wrapper.getServers().values()) {
sender.sendMessage("Server [" + proxyServer.getServerId() + "] @" + proxyServer.getServerInfo().getHost() + " | " + proxyServer.getServerInfo().getOnlineCount() + NetworkUtils.SLASH_STRING + proxyServer.getServerInfo().getMaxPlayers() + " | State: " + (proxyServer.getChannel() != null ? "connected" : "not connected"));
}
sender.sendMessage(" ");
}
for (CloudPlayer cloudPlayer : CloudNet.getInstance().getNetworkManager().getOnlinePlayers().values()) {
sender.sendMessage("* " + cloudPlayer.getUniqueId() + "#" + cloudPlayer.getName() + " - " + cloudPlayer.getProxy() + ":" + cloudPlayer.getServer());
}
sender.sendMessage(" ");
sender.sendMessage("CloudNet uses " + memory + NetworkUtils.SLASH_STRING + maxMemory + "MB ");
}
use of de.dytanic.cloudnetcore.network.components.MinecraftServer in project CloudNet by Dytanic.
the class CommandScreen method onExecuteCommand.
@Override
public void onExecuteCommand(CommandSender sender, String[] args) {
if (CloudNet.getInstance().getScreenProvider().getMainServiceId() != null && args.length > 1 && args[0].equalsIgnoreCase("write")) {
ServiceId serviceId = CloudNet.getInstance().getScreenProvider().getMainServiceId();
StringBuilder stringBuilder = new StringBuilder();
for (short i = 1; i < args.length; i++) {
stringBuilder.append(args[i]).append(NetworkUtils.SPACE_STRING);
}
String commandLine = stringBuilder.substring(0, stringBuilder.length() - 1);
Wrapper wrapper = CloudNet.getInstance().getWrappers().get(serviceId.getWrapperId());
if (wrapper != null) {
if (wrapper.getServers().containsKey(serviceId.getServerId())) {
wrapper.writeServerCommand(commandLine, wrapper.getServers().get(serviceId.getServerId()).getServerInfo());
}
if (wrapper.getProxys().containsKey(serviceId.getServerId())) {
wrapper.writeProxyCommand(commandLine, wrapper.getProxys().get(serviceId.getServerId()).getProxyInfo());
}
}
return;
}
switch(args.length) {
case 1:
if (args[0].equalsIgnoreCase("leave") && CloudNet.getInstance().getScreenProvider().getMainServiceId() != null) {
ServiceId serviceId = CloudNet.getInstance().getScreenProvider().getMainServiceId();
CloudNet.getInstance().getScreenProvider().disableScreen(serviceId.getServerId());
CloudNet.getInstance().getScreenProvider().setMainServiceId(null);
sender.sendMessage("You left the screen session");
return;
}
break;
case 2:
if (args[0].equalsIgnoreCase("-s") || args[0].equalsIgnoreCase("server")) {
MinecraftServer minecraftServer = CloudNet.getInstance().getServer(args[1]);
if (minecraftServer != null) {
ServiceId serviceId = CloudNet.getInstance().getScreenProvider().getMainServiceId();
if (serviceId != null) {
CloudNet.getInstance().getScreenProvider().disableScreen(serviceId.getServerId());
CloudNet.getInstance().getScreenProvider().setMainServiceId(null);
}
minecraftServer.getWrapper().enableScreen(minecraftServer.getServerInfo());
sender.sendMessage("You joined the screen session of " + minecraftServer.getServerId());
CloudNet.getInstance().getScreenProvider().setMainServiceId(minecraftServer.getServiceId());
}
return;
}
if (args[0].equalsIgnoreCase("-p") || args[0].equalsIgnoreCase("proxy")) {
ProxyServer minecraftServer = CloudNet.getInstance().getProxy(args[1]);
if (minecraftServer != null) {
ServiceId serviceId = CloudNet.getInstance().getScreenProvider().getMainServiceId();
if (serviceId != null) {
CloudNet.getInstance().getScreenProvider().disableScreen(serviceId.getServerId());
CloudNet.getInstance().getScreenProvider().setMainServiceId(null);
}
minecraftServer.getWrapper().enableScreen(minecraftServer.getProxyInfo());
sender.sendMessage("You joined the screen session of " + minecraftServer.getServerId());
CloudNet.getInstance().getScreenProvider().setMainServiceId(minecraftServer.getServiceId());
}
return;
}
break;
default:
sender.sendMessage("screen server (-s) | proxy (-p) <name> | The output of the console of the service is transferred to the console of this instance", "screen leave | The console output closes", "screen write <command> | You write a command directly into the console of the service");
break;
}
}
use of de.dytanic.cloudnetcore.network.components.MinecraftServer in project CloudNet by Dytanic.
the class CommandShutdown method onExecuteCommand.
@Override
public void onExecuteCommand(CommandSender sender, String[] args) {
switch(args.length) {
case 2:
if (args[0].equalsIgnoreCase("wrapper")) {
if (CloudNet.getInstance().getWrappers().containsKey(args[1])) {
Wrapper wrapper = CloudNet.getInstance().getWrappers().get(args[1]);
if (wrapper.getChannel() != null) {
wrapper.writeCommand("stop");
}
sender.sendMessage("Wrapper " + args[1] + " was stopped");
} else {
sender.sendMessage("Wrapper doesn't exist");
}
return;
}
if (args[0].equalsIgnoreCase("group")) {
if (CloudNet.getInstance().getServerGroups().containsKey(args[1])) {
System.out.println("All servers of the server group " + args[1] + " will be stopped...");
CollectionWrapper.iterator(CloudNet.getInstance().getServers(args[1]), new Runnabled<MinecraftServer>() {
@Override
public void run(MinecraftServer obj) {
obj.getWrapper().stopServer(obj);
NetworkUtils.sleepUninterruptedly(1000);
}
});
return;
}
if (CloudNet.getInstance().getProxyGroups().containsKey(args[1])) {
System.out.println("All proxies of the proxy group " + args[1] + " will be stopped");
CollectionWrapper.iterator(CloudNet.getInstance().getProxys(args[1]), new Runnabled<ProxyServer>() {
@Override
public void run(ProxyServer obj) {
obj.getWrapper().stopProxy(obj);
NetworkUtils.sleepUninterruptedly(1000);
}
});
return;
}
sender.sendMessage("Group doesn't exist");
return;
}
if (args[0].equalsIgnoreCase("server")) {
MinecraftServer proxyServer = CloudNet.getInstance().getServer(args[1]);
if (proxyServer != null) {
proxyServer.getWrapper().stopServer(proxyServer);
sender.sendMessage("Server " + args[1] + " was stopped!");
} else {
CloudServer proxyServers = CloudNet.getInstance().getCloudGameServer(args[1]);
if (proxyServers != null) {
proxyServers.getWrapper().stopServer(proxyServers);
} else {
sender.sendMessage("The server doesn't exist");
}
}
return;
}
if (args[0].equalsIgnoreCase("proxy")) {
ProxyServer proxyServer = CloudNet.getInstance().getProxy(args[1]);
if (proxyServer != null) {
proxyServer.getWrapper().stopProxy(proxyServer);
sender.sendMessage("Proxy server " + args[1] + " was stopped!");
} else {
sender.sendMessage("The proxy doesn't exist");
}
return;
}
break;
default:
sender.sendMessage(NetworkUtils.SPACE_STRING, "shutdown WRAPPER <wrapper-id> | Stops a wrapper service with the respective \"wrapper ID\"", "shutdown GROUP <group-id> | Stops a group of either proxy or servergroup, and restarts it by default", "shutdown PROXY <proxy-id> | Stops a BungeeCord service and after preconfiguring the group, a new one is started", "shutdown SERVER <server-id> | Stops a Minecraft server service and after preconfiguring the group, a new one is started", NetworkUtils.SPACE_STRING);
break;
}
}
use of de.dytanic.cloudnetcore.network.components.MinecraftServer in project CloudNet by Dytanic.
the class CommandDelete method onExecuteCommand.
@Override
public void onExecuteCommand(CommandSender sender, String[] args) {
switch(args.length) {
case 2:
if (args[0].equalsIgnoreCase("serverGroup")) {
if (CloudNet.getInstance().getServerGroups().containsKey(args[1])) {
ServerGroup serverGroup = CloudNet.getInstance().getServerGroups().get(args[1]);
CloudNet.getInstance().getConfig().deleteGroup(serverGroup);
CloudNet.getInstance().getServerGroups().remove(args[1]);
CloudNet.getInstance().getNetworkManager().updateAll();
for (MinecraftServer minecraftServer : CloudNet.getInstance().getServers(args[1])) {
minecraftServer.getWrapper().stopServer(minecraftServer);
}
sender.sendMessage("The group was successfully deleted");
} else {
sender.sendMessage("The server group doesn't exists");
}
}
break;
default:
sender.sendMessage("delete serverGroup <name>");
break;
}
}
use of de.dytanic.cloudnetcore.network.components.MinecraftServer in project CloudNet by Dytanic.
the class CommandInfo method onExecuteCommand.
@Override
public void onExecuteCommand(CommandSender sender, String[] args) {
switch(args.length) {
case 2:
{
switch(args[0].toLowerCase()) {
case "server":
{
MinecraftServer minecraftServer = CloudNet.getInstance().getServer(args[1]);
if (minecraftServer == null)
return;
sender.sendMessage(NetworkUtils.SPACE_STRING, "Server: " + minecraftServer.getServiceId().getServerId(), "UUID: " + minecraftServer.getServiceId().getUniqueId(), "GameId: " + minecraftServer.getServiceId().getGameId(), "Group: " + minecraftServer.getServiceId().getGroup(), NetworkUtils.SPACE_STRING, "Connection: " + (minecraftServer.getChannel() != null ? "connected" : "not connected"), "State: " + (minecraftServer.getServerInfo().isOnline() ? "Online" : "Offline") + " | " + minecraftServer.getServerInfo().getServerState(), "Online: " + minecraftServer.getServerInfo().getOnlineCount() + NetworkUtils.SLASH_STRING + minecraftServer.getServerInfo().getMaxPlayers(), "Motd: " + minecraftServer.getServerInfo().getMotd(), NetworkUtils.SPACE_STRING, "Memory: " + minecraftServer.getServerInfo().getMemory(), "Address: " + minecraftServer.getServerInfo().getHost(), "Port: " + minecraftServer.getServerInfo().getPort(), NetworkUtils.SPACE_STRING);
}
break;
case "proxy":
{
ProxyServer proxyServer = CloudNet.getInstance().getProxy(args[1]);
if (proxyServer == null)
return;
sender.sendMessage(NetworkUtils.SPACE_STRING, "Proxy: " + proxyServer.getServiceId().getServerId(), "UUID: " + proxyServer.getServiceId().getUniqueId(), "GameId: " + proxyServer.getServiceId().getGameId(), "Group: " + proxyServer.getServiceId().getGroup(), NetworkUtils.SPACE_STRING, "Connection: " + (proxyServer.getChannel() != null ? "connected" : "not connected"), "State: " + (proxyServer.getProxyInfo().isOnline() ? "Online" : "Offline"), "Online: " + proxyServer.getProxyInfo().getOnlineCount(), NetworkUtils.SPACE_STRING, "Memory: " + proxyServer.getProxyInfo().getMemory(), "Address: " + proxyServer.getProxyInfo().getHost(), "Port: " + proxyServer.getProxyInfo().getPort(), NetworkUtils.SPACE_STRING);
}
break;
case "wrapper":
{
Wrapper wrapper = CloudNet.getInstance().getWrappers().get(args[1]);
if (wrapper == null)
return;
sender.sendMessage(NetworkUtils.SPACE_STRING, "WrapperId: " + wrapper.getServerId(), NetworkUtils.SPACE_STRING, "Connection: " + (wrapper.getChannel() != null ? "connected" : "not connected"), "Servers started: " + wrapper.getServers().size(), "Proxys started: " + wrapper.getProxys().size(), NetworkUtils.SPACE_STRING, "Address: " + wrapper.getNetworkInfo().getHostName(), "Memory: " + wrapper.getUsedMemoryAndWaitings() + NetworkUtils.SLASH_STRING + (wrapper.getWrapperInfo() != null ? wrapper.getWrapperInfo().getMemory() + NetworkUtils.EMPTY_STRING : "0") + "MB", "CPU Cores: " + (wrapper.getWrapperInfo() != null ? wrapper.getWrapperInfo().getAvailableProcessors() + NetworkUtils.EMPTY_STRING : "0"), "CPU Usage: " + wrapper.getCpuUsage(), NetworkUtils.SPACE_STRING);
}
break;
}
}
break;
default:
sender.sendMessage("info SERVER <server> | monitor all informations about a game server", "info PROXY <proxy> | monitor all informations about a proxy server", "info WRAPPER <wrapper-id> | monitor all informations about a wrapper");
break;
}
}
Aggregations