Exemplo n.º 1
0
        public override void OnPacket(PlayerInfoPacket data)
        {
            if (data.Players != null)
            {
                if (data.Action == 0)
                {
                    foreach (var player in data.Players)
                    {
                        players.Add(new Model.Player()
                        {
                            UUID     = player.UUID,
                            Nickname = player.Name,
                            Ping     = player.Ping,
                            Gamemode = player.Gamemode
                        });
                    }
                }

                if (data.Action == 1)
                {
                    foreach (var player in data.Players)
                    {
                        players.ContainsGuid(player.UUID).Gamemode = player.Gamemode;
                    }
                }

                if (data.Action == 2)
                {
                    foreach (var player in data.Players)
                    {
                        players.ContainsGuid(player.UUID).Ping = player.Ping;
                    }
                }

                if (data.Action == 4)
                {
                    foreach (var player in data.Players)
                    {
                        players.Remove(player.UUID);
                    }
                }
            }
        }