/// <summary> /// Return registered user by id /// </summary> /// <param name="userId"></param> /// <param name="getInfo">Include user info</param> /// <param name="getTexture">Return user texture or not</param> /// <param name="cache"></param> /// <returns></returns> public VirtualServerEntity.User GetUser(int userId, bool getInfo = true, bool getTexture = false, bool cache = false) { if (!cache || !_entity.Users.ContainsKey(userId)) { // create object var user = new VirtualServerEntity.User() { Id = userId, }; if (getTexture) { user.Texture = _server.getTexture(userId); } if (getInfo) { // get from remote var userInfo = _server.getRegistration(userId); if (userInfo == null) { return(null); } foreach (var @i in userInfo) { user.Info.Add((VirtualServerEntity.User.UserInfo)@i.Key, @i.Value); } } // update in cache if (_entity.Users.ContainsKey(userId)) { _entity.Users[userId] = user; } else { _entity.Users.Add(userId, user); } } return(_entity.Users[userId]); }