public static PlayerRecord Load(string path, string steamId, PpPlugin plugin) { PlayerRecord player = new PlayerRecord(path, steamId, plugin); try { player.Read(); return(player); } catch (Exception e) { plugin.Error($"Preference record {steamId} threw an exception while loading:\n{e}"); return(null); } }
public void Read() { foreach (string file in Directory.GetFiles(directory, "*.txt")) { string steamId = Path.GetFileNameWithoutExtension(file); PlayerRecord record = PlayerRecord.Load(file, steamId, plugin); if (record == null) { plugin.Error($"Preference record {file} is either corrupt or out of date."); } else { if (records.ContainsKey(steamId)) { records[steamId] = record; } else { records.Add(steamId, record); } } } }