902 {
903 if (!RoomServiceUtils.IsOnlineHost())
904 {
905 return;
906 }
907
908
909 string sanitizedFileName = string.Concat(fileName.Split(Path.GetInvalidFileNameChars()));
910
911
912 if (!sanitizedFileName.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
913 {
914 sanitizedFileName += ".json";
915 }
916
917
918 string pluginFolderPath = BepInEx.Paths.PluginPath;
919 string filePath = Path.Combine(pluginFolderPath, sanitizedFileName);
920
921
922 var combinedData = new List<object>();
923
924 foreach (var level in Plugin.Instance.levelInfo)
925 {
926 var hash = level.Key;
927 var levelData = level.Value;
928 var times = Plugin.Instance.playerTimes.ContainsKey(hash) ? Plugin.Instance.playerTimes[hash] : new List<PlayerTime>();
929
930
931 combinedData.Add(new
932 {
933 Hash = levelData.Hash,
934 Author = levelData.Author,
935 Name = levelData.Name,
936 Uid = levelData.Uid,
937 WorkshopId = levelData.WorkshopId,
938 Times = times
939 });
940 }
941
942
943 string json = JsonConvert.SerializeObject(combinedData, Formatting.Indented);
944 File.WriteAllText(filePath, json);
945 }