diff --git a/CollabVMSharp/CollabVMClient.cs b/CollabVMSharp/CollabVMClient.cs index ab7156d..aecfd57 100644 --- a/CollabVMSharp/CollabVMClient.cs +++ b/CollabVMSharp/CollabVMClient.cs @@ -371,20 +371,32 @@ public class CollabVMClient { case "adduser": { for (int i = 2; i < msgArr.Length; i += 2) { // This can happen when a user logs in - _users.RemoveAll(u => u.Username == msgArr[i]); - var user = new User { - Username = msgArr[i], - Rank = msgArr[i + 1] switch { + var user = _users.Find(u => u.Username == msgArr[i]); + if (user == null) { + user = new User { + Username = msgArr[i], + Rank = msgArr[i + 1] switch { + "0" => Rank.Unregistered, + "1" => Rank.Registered, + "2" => Rank.Admin, + "3" => Rank.Moderator, + _ => Rank.Unregistered + }, + Turn = TurnStatus.None + }; + this._users.Add(user); + } + else + { + user.Rank = msgArr[i + 1] switch { "0" => Rank.Unregistered, "1" => Rank.Registered, "2" => Rank.Admin, "3" => Rank.Moderator, _ => Rank.Unregistered - }, - Turn = TurnStatus.None - }; + }; + } this.UserJoined.Invoke(this, user); - this._users.Add(user); } break; }