Beispiel #1
0
        static void SendTabHeader(Client p)
        {
            //Donor donor = Donors.GetDonor(p.MinecraftUsername);

            PlayerListItem list = new PlayerListItem(PlayerListItem.Actions.AddPlayer);

            //Username ping is always sent
            //list.AddPlayer(header11, Chat.Bold + p.MinecraftUsername, 100);

            //Line 1, other 2 columns
            /*            if (donor == null || donor.ExpireLegacy < DateTime.Now)
                list.AddPlayer(header12, "You go " + Chat.Gold + "/donate");
            else
                list.AddPlayer(header12, Chat.Gold + "Donor");
            */

            /*if (p.Inbox == 0)
                list.AddPlayer(header13, Chat.Gray + "no mail", -1);
            else
                list.AddPlayer(header13, Chat.Red + p.Inbox + " mail /read", 0);
            */

            //Line 2
            //list.AddPlayer(header21, Chat.Gray + p.Country);

            /*if (p.Inbox == 0)
                list.AddPlayer(header23, "2");
            else
                list.AddPlayer(header23, Chat.Gray + "Read: " + Chat.Red + "/read");
            */

            //Line 3
            //list.AddPlayer(header31, "3");
            //list.AddPlayer(header32, "4");
            //list.AddPlayer(header33, "5");
            
            //list.AddPlayer(header41, Chat.Gray + Chat.Underline + "Players");
            //list.AddPlayer(header42, "6");
            //list.AddPlayer(header43, "7");

            //Full list of players
            foreach (var i in List)
            {
                list.AddPlayer(i.UUID, PlayerName(i), (int)i.Ping);
                //list.AddPlayer(i.UUID, i.MinecraftUsername, (int)i.Ping);
            }

            p.Queue.Queue(list);
        }
Beispiel #2
0
        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);
            }
        }