public static void UpdateBlueprints(ulong discordID, PlayerBlueprints newbps) { PlayerBlueprints oldbps = playerBlueprints.FirstOrDefault(x => x.DiscordID == discordID); if (oldbps == default(PlayerBlueprints)) { playerBlueprints.Add(newbps); SaveBlueprints(discordID); } else { playerBlueprints.Remove(oldbps); playerBlueprints.Add(newbps); SaveBlueprints(discordID); } }
public static bool SaveBlueprints(ulong discordID) { if (playerBlueprints.FirstOrDefault(x => x.DiscordID == discordID) == default(PlayerBlueprints)) { return(false); } //If the file already exists, delete it File.Delete($"Users/Blueprints/{discordID}.json"); //Obtain the players blueprints PlayerBlueprints bps = playerBlueprints.FirstOrDefault(x => x.DiscordID == discordID); //Write the blueprints to a file Utilities.WriteToJsonFile($"Users/Blueprints/{discordID}.json", bps); return(true); }