public void v2RefreshStatus() { try { WebClient wc; RunOnAternos(wc = new WebClient(), () => { string r = wc.DownloadString("https://aternos.org/server"); string lastStatus = r .Split(new string[] { "var lastStatus = {" }, StringSplitOptions.None)[1] .Split(new string[] { "};" }, StringSplitOptions.None)[0]; AlanV rv = new AlanV(lastStatus); string ip = rv.Get("ip")[0].Split('.')[0]; string software = rv.Get("software")[0]; string version = rv.Get("version")[0]; string status = rv.Get("class")[1]; switch (status) { case "offline": FProgram.ExecuteScript("SetStatus", new object[] { "offline", ip, software, version, "", "" }); break; case "online": string ps = lastStatus .Split(new string[] { "\"playerlist\":[" }, StringSplitOptions.None)[1] .Split(']')[0]; string[] players; if (ps.Contains(",")) { players = ps.Split(','); } else { players = new string[] { ps } }; for (int i = 0; i < players.Length; i++) { players[i] = players[i].Replace("\"", ""); if (!Players.Contains(players[i]) && players[i].Length > 3) { FProgram.ExecuteScript("AddPlayer", new object[] { players[i] }); } } for (int i = 0; i < Players.Length; i++) { if (!players.Contains(Players[i])) { FProgram.ExecuteScript("RemovePlayer", new object[] { Players[i] }); } } Players = players; FProgram.ExecuteScript("SetStatus", new object[] { "online", ip, software, version, "", "" }); break; case "queueing": int per = (int)Double.Parse(lastStatus .Split(new string[] { "\"percentage\":" }, StringSplitOptions.None)[1] .Split(',')[0]); try { string icon = rv.Get("icon")[0]; if (icon == "fa-exclamation-triangle") { Confirm(); } } catch { } FProgram.ExecuteScript("SetStatus", new object[] { "queue", ip, software, version, rv.Get("time")[0], per }); break; case "loading": case "loading starting": FProgram.ExecuteScript("SetStatus", new object[] { "queue", ip, software, version, "Ucitavanje resursa", 0 }); break; } }); } catch { } }
public void v2RefreshStatus() { try { Console.WriteLine(GC.GetTotalMemory(false)); WebClient wc; RunOnAternos(wc = new WebClient(), () => { string r = wc.DownloadString("https://aternos.org/server"); string lastStatus = r .Split(new string[] { "var lastStatus = {" }, StringSplitOptions.None)[1] .Split(new string[] { "};" }, StringSplitOptions.None)[0]; string ip = AlanV.QuickFindValue(lastStatus, "ip")[0].Split('.')[0]; string software = AlanV.QuickFindValue(lastStatus, "software")[0]; string version = AlanV.QuickFindValue(lastStatus, "version")[0]; string status = AlanV.QuickFindValue(lastStatus, "class")[1]; switch (status) { case "offline": ServerManager.SetStatus("offline", ip, software, version, "", 0); break; case "online": string ps = lastStatus .Split(new string[] { "\"playerlist\":[" }, StringSplitOptions.None)[1] .Split(']')[0]; string[] players; if (ps.Contains(",")) { players = ps.Split(','); } else { players = new string[] { ps } }; for (int i = 0; i < players.Length; i++) { players[i] = players[i].Replace("\"", ""); if (!Players.Contains(players[i]) && players[i].Length > 3) { PlayerManager.AddPlayer(players[i]); } } for (int i = 0; i < Players.Length; i++) { if (!players.Contains(Players[i])) { PlayerManager.RemovePlayer(Players[i]); } } Players = players; ServerManager.SetStatus("online", ip, software, version, "", 0); break; case "queueing": int per = (int)Double.Parse(lastStatus .Split(new string[] { "\"percentage\":" }, StringSplitOptions.None)[1] .Split(',')[0]); try { string icon = AlanV.QuickFindValue(lastStatus, "icon")[0]; if (icon == "fa-exclamation-triangle") { Confirm(); } } catch { } ServerManager.SetStatus("queue", ip, software, version, AlanV.QuickFindValue(lastStatus, "time")[0], per); break; case "loading": case "loading starting": ServerManager.SetStatus("queue", ip, software, version, "Ucitavanje resursa", 0); break; } GC.Collect(2); Console.WriteLine(GC.GetTotalMemory(false)); }, false); } catch { } }