Search in sources :

Example 16 with MinecraftServer

use of de.dytanic.cloudnetcore.network.components.MinecraftServer in project CloudNet by Dytanic.

the class CommandCmd method onExecuteCommand.

@Override
public void onExecuteCommand(CommandSender sender, String[] args) {
    if (args.length > 1) {
        for (Wrapper wrapper : CloudNet.getInstance().getWrappers().values()) {
            for (MinecraftServer minecraftServer : wrapper.getServers().values()) {
                if (minecraftServer.getServiceId().getServerId().equalsIgnoreCase(args[0])) {
                    StringBuilder stringBuilder = new StringBuilder();
                    for (short i = 1; i < args.length; i++) {
                        stringBuilder.append(args[i]).append(NetworkUtils.SPACE_STRING);
                    }
                    minecraftServer.getWrapper().writeServerCommand(stringBuilder.substring(0, stringBuilder.length() - 1), minecraftServer.getServerInfo());
                    sender.sendMessage("Sending command to " + minecraftServer.getServiceId().getServerId() + " with [\"" + stringBuilder.substring(0, stringBuilder.length() - 1) + "\"]");
                    return;
                }
            }
            for (ProxyServer minecraftServer : wrapper.getProxys().values()) {
                if (minecraftServer.getServiceId().getServerId().equalsIgnoreCase(args[0])) {
                    StringBuilder stringBuilder = new StringBuilder();
                    for (short i = 1; i < args.length; i++) {
                        stringBuilder.append(args[i]).append(NetworkUtils.SPACE_STRING);
                    }
                    minecraftServer.getWrapper().writeProxyCommand(stringBuilder.substring(0, stringBuilder.length() - 1), minecraftServer.getProxyInfo());
                    sender.sendMessage("Sending command to " + minecraftServer.getServiceId().getServerId() + " with [\"" + stringBuilder.substring(0, stringBuilder.length() - 1) + "\"]");
                    return;
                }
            }
        }
    } else {
        sender.sendMessage("cmd <name> <command> | Executes a command, either from a proxy or game server");
    }
}
Also used : Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) MinecraftServer(de.dytanic.cloudnetcore.network.components.MinecraftServer) ProxyServer(de.dytanic.cloudnetcore.network.components.ProxyServer)

Example 17 with MinecraftServer

use of de.dytanic.cloudnetcore.network.components.MinecraftServer in project CloudNet by Dytanic.

the class CommandInstallPlugin method onExecuteCommand.

@Override
public void onExecuteCommand(CommandSender sender, String[] args) {
    switch(args.length) {
        case 3:
            MinecraftServer minecraftServer = CloudNet.getInstance().getServer(args[0]);
            if (minecraftServer != null && minecraftServer.getChannel() != null) {
                minecraftServer.sendCustomMessage("cloudnet_internal", "install_plugin", new Document("name", args[1]).append("url", args[2]));
                sender.sendMessage("Plugin will install on " + args[0] + "...");
            } else {
                sender.sendMessage("Server doesn't exist");
            }
            break;
        default:
            sender.sendMessage("installplugin <server> <name> <url>");
            break;
    }
}
Also used : Document(de.dytanic.cloudnet.lib.utility.document.Document) MinecraftServer(de.dytanic.cloudnetcore.network.components.MinecraftServer)

Aggregations

MinecraftServer (de.dytanic.cloudnetcore.network.components.MinecraftServer)17 ProxyServer (de.dytanic.cloudnetcore.network.components.ProxyServer)12 Wrapper (de.dytanic.cloudnetcore.network.components.Wrapper)9 CloudServer (de.dytanic.cloudnetcore.network.components.CloudServer)5 TypeToken (com.google.gson.reflect.TypeToken)3 Document (de.dytanic.cloudnet.lib.utility.document.Document)3 DefaultType (de.dytanic.cloudnet.lib.DefaultType)2 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)2 ServerGroup (de.dytanic.cloudnet.lib.server.ServerGroup)2 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)2 ServiceId (de.dytanic.cloudnet.lib.service.ServiceId)2 AuthLoginResult (de.dytanic.cloudnet.lib.network.auth.AuthLoginResult)1 PacketOutAuthResult (de.dytanic.cloudnet.lib.network.auth.packetio.PacketOutAuthResult)1 ServerProcessMeta (de.dytanic.cloudnet.lib.server.ServerProcessMeta)1 User (de.dytanic.cloudnet.lib.user.User)1 CollectionWrapper (de.dytanic.cloudnet.lib.utility.CollectionWrapper)1 ScheduledTask (de.dytanic.cloudnet.lib.utility.threading.ScheduledTask)1 WrapperChannelDisconnectEvent (de.dytanic.cloudnetcore.api.event.network.WrapperChannelDisconnectEvent)1 CloudNetClient (de.dytanic.cloudnetcore.network.CloudNetClient)1 CloudNetClientAuth (de.dytanic.cloudnetcore.network.CloudNetClientAuth)1