Skip to content

Commit

Permalink
#15
Browse files Browse the repository at this point in the history
  • Loading branch information
ReadieFur committed Jan 1, 2022
1 parent d21d89a commit 44eaff4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion beatmods.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
DataPuller

## Mod Version
2.0.10
2.0.11

## Game Version
1.19.0
Expand Down
34 changes: 22 additions & 12 deletions src/Client/MapEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MapEvents : IInitializable, IDisposable
{
//I think I need to fix my refrences as VS does not notice when I update them.
private static BeatSaver beatSaver = new BeatSaver("BSDataPuller", Assembly.GetExecutingAssembly().GetName().Version);
private static SongDetails songDetailsCache = null;
internal static MapData.JsonData previousStaticData = new MapData.JsonData();
private Timer timer = new Timer { Interval = 250 };
private int NoteCount = 0;
Expand Down Expand Up @@ -191,13 +192,11 @@ public void LevelLoaded()
MapData.NJS = gameplayCoreSceneSetupData.difficultyBeatmap.noteJumpMovementSpeed;
MapData.CustomDifficultyLabel = difficultyData?._difficultyLabel ?? null;


if (isCustomLevel)
{
Task.Run(async () =>
void SetSongDetails()
{
SongDetails songDetails = await SongDetails.Init();
if (songDetails.songs.FindByHash(mapHash, out Song song))
if (songDetailsCache.songs.FindByHash(mapHash, out Song song))
{
MapCharacteristic mapType;
switch (gameplayCoreSceneSetupData.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName)
Expand All @@ -209,8 +208,10 @@ public void LevelLoaded()
mapType = MapCharacteristic.NinetyDegree;
break;
default:
mapType = (MapCharacteristic)Enum.Parse(typeof(MapCharacteristic),
gameplayCoreSceneSetupData.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName);
if (!Enum.TryParse(
gameplayCoreSceneSetupData.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName,
out mapType
)) { return; }
break;
}

Expand All @@ -225,17 +226,26 @@ public void LevelLoaded()
MapData.Send();
}
}
});
}

Task.Run(async () =>
if (songDetailsCache == null)
{
BeatSaverSharp.Models.Beatmap beatmap = await beatSaver.BeatmapByHash(mapHash);
if (beatmap != null)
SongDetails.Init().ContinueWith((task) =>
{
MapData.BSRKey = beatmap.ID;
if (task.Result == null) { return; }
songDetailsCache = task.Result;
SetSongDetails();
});
}
else { SetSongDetails(); }

beatSaver.BeatmapByHash(mapHash).ContinueWith((task) =>
{
if (task.Result != null)
{
MapData.BSRKey = task.Result.ID;
BeatSaverSharp.Models.BeatmapVersion mapDetails = null;
try { mapDetails = beatmap.Versions.First(map => map.Hash.ToLower() == mapHash.ToLower()); } catch (Exception ex) { Plugin.Logger.Error(ex); }
try { mapDetails = task.Result.Versions.First(map => map.Hash.ToLower() == mapHash.ToLower()); } catch (Exception ex) { Plugin.Logger.Error(ex); }
MapData.coverImage = mapDetails != null ? mapDetails.CoverURL : null;
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.10")]
[assembly: AssemblyFileVersion("2.0.10")]
[assembly: AssemblyVersion("2.0.11")]
[assembly: AssemblyFileVersion("2.0.11")]
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "DataPuller",
"name": "DataPuller",
"author": "Readie",
"version": "2.0.10",
"version": "2.0.11",
"description": "Gathers data about the current map you are playing to then be sent out over a websocket for other software to use, e.g. A web overlay like BSDP-Overlay. This mod works with multi PC setups!",
"gameVersion": "1.19.0",
"dependsOn": {
Expand Down

0 comments on commit 44eaff4

Please sign in to comment.