public string LastJoinHost() { string ret = ""; SGGValheimMod.Log("Getting last IP for current character"); CharacterHost charToIP = LastJoinIP(); if (charToIP != null) { ret = charToIP.IPHost; } return(ret); }
// replaced with AddJoinIP //public void SetJoinIP(string currentIP) //{ // SGGValheimMod.Log("Setting Join IP for : " + Character + " to " + currentIP); // List<CharacterHost> characterToIPList = AllHosts; // CharacterHost charToIP = characterToIPList.Find(x => x.Character == Character && x.ServerType == ServerTypes.JoinIP); //if we find the character and server type, set their last IP. // if (charToIP != null) // { // charToIP.IPHost = currentIP; // } // else // { // no character found, add them to the list of characters. // charToIP = new CharacterHost() { Character = Character, IPHost = currentIP, ServerType = ServerTypes.JoinIP }; // characterToIPList.Add(charToIP); // } // CurrentSelected = charToIP; // SaveChanges(); //} public void AddJoinIP(string currentIP) { SGGValheimMod.Log("Setting Join IP for : " + Character + " to " + currentIP); CharacterHost charToIP = FindServer(currentIP); if (charToIP != null) //already exists, no need to resave { CurrentSelected = charToIP; return; } charToIP = new CharacterHost() { Character = Character, IPHost = currentIP, ServerType = ServerTypes.JoinIP }; AllHosts.Add(charToIP); CurrentSelected = charToIP; SaveChanges(); }