Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
        }