public static void LoadInventories() { string data = FileManager.ReadFullFile(DataFileNames.UserInventoriesFile); Dictionary <ulong, UserInventoryNode> UserInventories = JsonConvert.DeserializeObject <Dictionary <ulong, UserInventoryNode> >(data) ?? new Dictionary <ulong, UserInventoryNode>(); foreach (ulong id in UserInventories.Keys) { if (BotUtils.GetGUser(id) == null) { continue; } if (UserDataManager.UserData.ContainsKey(id)) { // User has a data file, things are all good UserDataManager.GetUserData(BotUtils.GetGUser(id)).Inventory = UserInventories[id]; } else { // wacky things are going on, create a user profile and then load inventory UserDataManager.AddUser(BotUtils.GetGUser(id)); UserDataManager.GetUserData(BotUtils.GetGUser(id)).Inventory = UserInventories[id]; } } KLog.Info("Loaded Inventories."); }