public static void AddClone(CloneInfo clone) { bool exists = Clones.Exists(e => e.Character == clone.Character && e.IP == clone.IP && e.UUID == clone.UUID); if (exists) { return; } string query = $"INSERT INTO Clones (CharacterName, IP, UUID) VALUES ('{clone.Character}', '{clone.IP}', '{clone.UUID}');"; if (db.Query(query) != 1) { TShock.Log.ConsoleError("Error inserting new character into clone DB."); } Clones.Add(clone); }
public static void Reload() { Clones = new List <CloneInfo>(); string query = "SELECT * FROM Clones;"; using (QueryResult reader = db.QueryReader(query)) { while (reader.Read()) { CloneInfo clone = new CloneInfo() { ID = reader.Get <int>("ID"), Character = reader.Get <string>("CharacterName"), IP = reader.Get <string>("IP"), UUID = reader.Get <string>("UUID") }; Clones.Add(clone); } } }