Ejemplo n.º 1
0
        public ListForm(ClassicubeServer[] servers, ClassicubeService classicube)
        {
            InitializeComponent();
            _servers = servers;
            _filtered = servers;
            _service = classicube;

            _lvwColumnSorter = new ListViewColumnSorter();
            listView1.ListViewItemSorter = _lvwColumnSorter;
        }
Ejemplo n.º 2
0
        public ClassicubeServer[] GetAllServers()
        {
            var serverString = GetServers();
            var jsonObj = (JArray)(JToken.Parse(serverString)["servers"]);
            var result = new ClassicubeServer[jsonObj.Count];

            for (var i = 0; i < result.Length; i++) {
                result[i] = new ClassicubeServer {
                    Hash = jsonObj[i]["hash"].Value<string>(),
                    Ip = jsonObj[i]["ip"].Value<string>(),
                    Port = jsonObj[i]["port"].Value<int>(),
                    OnlinePlayers = jsonObj[i]["players"].Value<int>(),
                    MaxPlayers = jsonObj[i]["maxplayers"].Value<int>(),
                    Mppass = jsonObj[i]["mppass"].Value<string>(),
                    Name = jsonObj[i]["name"].Value<string>(),
                    Software = jsonObj[i]["software"].Value<string>(),
                    Uptime = jsonObj[i]["uptime"].Value<int>()
                };
            }

            return result;
        }
Ejemplo n.º 3
0
        public ClassicubeServer GetServerByUrl(string url)
        {
            var serverString = GetServers();
            var jsonObj = (JArray)(JToken.Parse(serverString)["servers"]);
            var mySplits = url.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

            url = mySplits[mySplits.Length - 1];

            var server = new ClassicubeServer();

            foreach (var item in jsonObj) {
                if (!String.Equals(item["hash"].Value<string>(), url, StringComparison.CurrentCultureIgnoreCase))
                    continue;

                server.Hash = item["hash"].Value<string>();
                server.Ip = item["ip"].Value<string>();
                server.Mppass = item["mppass"].Value<string>();
                server.Port = item["port"].Value<int>();
                server.MaxPlayers = item["maxplayers"].Value<int>();
                server.OnlinePlayers = item["players"].Value<int>();
                server.Software = item["software"].Value<string>();
                break;
            }

            return server;
        }
Ejemplo n.º 4
0
        public ClassicubeServer GetServerInfo(string serverName)
        {
            var serverString = GetServers();
            var jsonObj = (JArray)(JToken.Parse(serverString)["servers"]);
            var server = new ClassicubeServer();

            foreach (var item in jsonObj) {
                if (item["name"].Value<string>().ToLower() != serverName.ToLower())
                    continue;

                server.Hash = item["hash"].Value<string>();
                server.Ip = item["ip"].Value<string>();
                server.Mppass = item["mppass"].Value<string>();
                server.Port = item["port"].Value<int>();
                server.MaxPlayers = item["maxplayers"].Value<int>();
                server.OnlinePlayers = item["players"].Value<int>();
                server.Software = item["software"].Value<string>();
                break;
            }

            return server;
        }