public static void LogoutPlayer(Client pp) { bool removed = false; lock (list) { removed = list.Contains(pp); list.Remove(pp); List = list.ToArray(); } if (removed) { QueueToAll(PlayerListItem.RemovePlayer(pp)); } //PlayerList.UpdateRefreshTabPlayers(); Log.WriteUsersLog(); if (removed && pp.MinecraftUsername != null && pp.Settings.Cloaked == null && Banned.CheckBanned(pp) == null && pp.MinecraftUsername != "Player") { Chatting.Parser.Say(Chat.Gray, pp.Name + " left the game"); } }
public static void UpdateTabPlayers() { try { var next = new Dictionary <Client, string>(); var additem = new PlayerListItem(PlayerListItem.Actions.AddPlayer); var update = new PlayerListItem(PlayerListItem.Actions.UpdateLatency); //Active players foreach (Client a in List) { //Send players own bold status //var own = new PlayerListItem(PlayerListItem.Actions.AddPlayer); //own.AddPlayer(header11, Chat.Bold + a.MinecraftUsername, (int)a.Ping); //a.Queue.Queue(own); string s = PlayerName(a); if (a.Settings.Cloaked != null || a.MinecraftUsername == "Player") { continue; } if (prevList.ContainsKey(a)) { string old = prevList[a]; if (old == s) { update.AddPlayer(a.UUID, s, (int)a.Ping); prevList.Remove(a); } else { additem.AddPlayer(a.UUID, s, (int)a.Ping); } } else { additem.AddPlayer(a.UUID, s, (int)a.Ping); } next.Add(a, s); } //Remove gone players if (prevList.Count > 0) { var remove = new PlayerListItem(PlayerListItem.Actions.RemovePlayer); foreach (var n in prevList.Keys) { remove.RemovePlayer(n.UUID); } QueueToAll(remove); } if (additem.Players.Count > 0) { QueueToAll(additem); } if (update.Players.Count > 0) { QueueToAll(update); } prevList = next; } catch (Exception e) { Log.WriteServer(e); } }