From b8e5ef0ac2e7b192a95a2013f6d92024bb4415d7 Mon Sep 17 00:00:00 2001 From: kenx00x Date: Wed, 3 Aug 2022 15:03:01 +0200 Subject: [PATCH 1/9] fix for beatsaber 1.24.0 --- ModelDownloader/HarmonyPatches/ModelDownloaderPatches.cs | 2 +- ModelDownloader/Plugin.cs | 4 ++-- ModelDownloader/manifest.json | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ModelDownloader/HarmonyPatches/ModelDownloaderPatches.cs b/ModelDownloader/HarmonyPatches/ModelDownloaderPatches.cs index 8eda94a..2f93e9d 100644 --- a/ModelDownloader/HarmonyPatches/ModelDownloaderPatches.cs +++ b/ModelDownloader/HarmonyPatches/ModelDownloaderPatches.cs @@ -31,7 +31,7 @@ internal static void RemoveHarmonyPatches() { if (instance != null && IsPatched) { - instance.UnpatchAll(InstanceId); + Harmony.UnpatchID(InstanceId); IsPatched = false; } } diff --git a/ModelDownloader/Plugin.cs b/ModelDownloader/Plugin.cs index a35345b..8862904 100644 --- a/ModelDownloader/Plugin.cs +++ b/ModelDownloader/Plugin.cs @@ -27,8 +27,8 @@ public void Init(IPALogger logger, Config config, Zenjector zenjector) Instance = this; Log = logger; Log.Info("ModelDownloader initialized."); - zenjector.OnApp().WithParameters(config.Generated()); - zenjector.OnMenu(); + zenjector.Install(Location.App, config.Generated()); + zenjector.Install(Location.Menu); } [OnStart] diff --git a/ModelDownloader/manifest.json b/ModelDownloader/manifest.json index 3059f3d..1053cc3 100644 --- a/ModelDownloader/manifest.json +++ b/ModelDownloader/manifest.json @@ -3,13 +3,13 @@ "id": "ModelDownloader", "name": "ModelDownloader", "author": "Bobbie", - "version": "1.1.2", + "version": "1.1.3", "description": "A PC Beat Saber mod that allows you to download Sabers, Notes, Platforms, and Avatars directly from ModelSaber, all from a convenient window within your game.", - "gameVersion": "1.15.0", + "gameVersion": "1.24.0", "dependsOn": { "BSIPA": "^4.0.5", "BeatSaberMarkupLanguage": "^1.3.5", - "SiraUtil": "^2.2.0" + "SiraUtil": "^3.1.0" }, "features": [] } \ No newline at end of file From ea42e3854584c2d0699a6040ddff8a935d2c15c4 Mon Sep 17 00:00:00 2001 From: kenx00x Date: Sat, 4 Mar 2023 16:01:58 +0100 Subject: [PATCH 2/9] 1.28 --- ModelDownloader/Properties/AssemblyInfo.cs | 4 ++-- ModelDownloader/manifest.json | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ModelDownloader/Properties/AssemblyInfo.cs b/ModelDownloader/Properties/AssemblyInfo.cs index 3418c7b..ec277e4 100644 --- a/ModelDownloader/Properties/AssemblyInfo.cs +++ b/ModelDownloader/Properties/AssemblyInfo.cs @@ -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("1.1.2")] -[assembly: AssemblyFileVersion("1.1.2")] +[assembly: AssemblyVersion("1.1.4")] +[assembly: AssemblyFileVersion("1.1.4")] diff --git a/ModelDownloader/manifest.json b/ModelDownloader/manifest.json index 1053cc3..f505c89 100644 --- a/ModelDownloader/manifest.json +++ b/ModelDownloader/manifest.json @@ -3,13 +3,13 @@ "id": "ModelDownloader", "name": "ModelDownloader", "author": "Bobbie", - "version": "1.1.3", + "version": "1.1.4", "description": "A PC Beat Saber mod that allows you to download Sabers, Notes, Platforms, and Avatars directly from ModelSaber, all from a convenient window within your game.", - "gameVersion": "1.24.0", + "gameVersion": "1.28.0", "dependsOn": { - "BSIPA": "^4.0.5", - "BeatSaberMarkupLanguage": "^1.3.5", - "SiraUtil": "^3.1.0" + "BSIPA": "^4.2.2", + "BeatSaberMarkupLanguage": "^1.6.8", + "SiraUtil": "^3.1.2" }, "features": [] } \ No newline at end of file From 42519febe73f9a2b773b166c7506e6423bec8431 Mon Sep 17 00:00:00 2001 From: kenx00x Date: Thu, 9 Mar 2023 21:19:12 +0100 Subject: [PATCH 3/9] update copyright to 2023 --- ModelDownloader/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModelDownloader/Properties/AssemblyInfo.cs b/ModelDownloader/Properties/AssemblyInfo.cs index ec277e4..3c61b58 100644 --- a/ModelDownloader/Properties/AssemblyInfo.cs +++ b/ModelDownloader/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ModelDownloader")] -[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] From 898fd0d6cf8c3ed09064374f8c3967cfc2375059 Mon Sep 17 00:00:00 2001 From: kenx00x Date: Thu, 9 Mar 2023 21:19:33 +0100 Subject: [PATCH 4/9] update dependency to new version --- ModelDownloader/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModelDownloader/manifest.json b/ModelDownloader/manifest.json index f505c89..df46eee 100644 --- a/ModelDownloader/manifest.json +++ b/ModelDownloader/manifest.json @@ -8,7 +8,7 @@ "gameVersion": "1.28.0", "dependsOn": { "BSIPA": "^4.2.2", - "BeatSaberMarkupLanguage": "^1.6.8", + "BeatSaberMarkupLanguage": "^1.6.9", "SiraUtil": "^3.1.2" }, "features": [] From d27ee3af350f42837dcb18a568c86d675f303eba Mon Sep 17 00:00:00 2001 From: kenx00x Date: Fri, 7 Apr 2023 15:46:59 +0200 Subject: [PATCH 5/9] fix ArgumentException: Illegal characters in path. --- ModelDownloader/Utils/DownloadUtils.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ModelDownloader/Utils/DownloadUtils.cs b/ModelDownloader/Utils/DownloadUtils.cs index 3101193..9cde6f6 100644 --- a/ModelDownloader/Utils/DownloadUtils.cs +++ b/ModelDownloader/Utils/DownloadUtils.cs @@ -66,6 +66,9 @@ public static async void DownloadModel(ModelsaberEntry model, string DownloadPat byte[] fileBytes = await ModelsaberUtils.GetModelBytes(model); string modelFileName = model.Download.Substring(model.Download.LastIndexOf("/") + 1); + // Remove illegal characters from the filename + modelFileName = new string(modelFileName.Where(c => !Path.GetInvalidFileNameChars().Contains(c)).ToArray()); + Plugin.Log.Info("Checking hash..."); if (model.Hash.ToLower() == MD5Checksum(fileBytes).ToLower()) Plugin.Log.Info($"Hash check for {model.Name} passed!"); else From a05b99732ad6fbb34b7512662792ca1fcc88bb92 Mon Sep 17 00:00:00 2001 From: kenx00x Date: Fri, 7 Apr 2023 15:49:48 +0200 Subject: [PATCH 6/9] update version --- ModelDownloader/Properties/AssemblyInfo.cs | 4 ++-- ModelDownloader/manifest.json | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ModelDownloader/Properties/AssemblyInfo.cs b/ModelDownloader/Properties/AssemblyInfo.cs index 3c61b58..ed783a1 100644 --- a/ModelDownloader/Properties/AssemblyInfo.cs +++ b/ModelDownloader/Properties/AssemblyInfo.cs @@ -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("1.1.4")] -[assembly: AssemblyFileVersion("1.1.4")] +[assembly: AssemblyVersion("1.1.5")] +[assembly: AssemblyFileVersion("1.1.5")] diff --git a/ModelDownloader/manifest.json b/ModelDownloader/manifest.json index df46eee..8decfd9 100644 --- a/ModelDownloader/manifest.json +++ b/ModelDownloader/manifest.json @@ -3,12 +3,12 @@ "id": "ModelDownloader", "name": "ModelDownloader", "author": "Bobbie", - "version": "1.1.4", + "version": "1.1.5", "description": "A PC Beat Saber mod that allows you to download Sabers, Notes, Platforms, and Avatars directly from ModelSaber, all from a convenient window within your game.", - "gameVersion": "1.28.0", + "gameVersion": "1.29.0", "dependsOn": { "BSIPA": "^4.2.2", - "BeatSaberMarkupLanguage": "^1.6.9", + "BeatSaberMarkupLanguage": "^1.6.10", "SiraUtil": "^3.1.2" }, "features": [] From 2dc8cbe783e0156bfc586074f0fbdd5dea5b1a9d Mon Sep 17 00:00:00 2001 From: kenx00x Date: Fri, 7 Apr 2023 16:34:56 +0200 Subject: [PATCH 7/9] fix broken download due to bad URL which caused hash validations errors --- ModelDownloader/Properties/AssemblyInfo.cs | 4 ++-- ModelDownloader/Utils/ModelsaberUtils.cs | 5 +++++ ModelDownloader/manifest.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ModelDownloader/Properties/AssemblyInfo.cs b/ModelDownloader/Properties/AssemblyInfo.cs index ed783a1..2a674bb 100644 --- a/ModelDownloader/Properties/AssemblyInfo.cs +++ b/ModelDownloader/Properties/AssemblyInfo.cs @@ -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("1.1.5")] -[assembly: AssemblyFileVersion("1.1.5")] +[assembly: AssemblyVersion("1.1.6")] +[assembly: AssemblyFileVersion("1.1.6")] diff --git a/ModelDownloader/Utils/ModelsaberUtils.cs b/ModelDownloader/Utils/ModelsaberUtils.cs index 77029e9..9c05a5d 100644 --- a/ModelDownloader/Utils/ModelsaberUtils.cs +++ b/ModelDownloader/Utils/ModelsaberUtils.cs @@ -104,6 +104,11 @@ public static async Task GetModelBytes(ModelsaberEntry entry) { downloadURL = new Uri(entry.Download.Substring(0, entry.Download.LastIndexOf("/")) + "/" + entry.Download); } + //encode URL + int index = downloadURL.ToString().LastIndexOf('/'); + string basePart = downloadURL.ToString().Substring(0, index + 1); + string encodedPart = Uri.EscapeDataString(downloadURL.ToString().Substring(index + 1)); + downloadURL = new Uri(basePart + encodedPart); client.BaseAddress = null; HttpResponseMessage response = await client.GetAsync(downloadURL); byte[] modelBytes = await response.Content.ReadAsByteArrayAsync(); diff --git a/ModelDownloader/manifest.json b/ModelDownloader/manifest.json index 8decfd9..93b969f 100644 --- a/ModelDownloader/manifest.json +++ b/ModelDownloader/manifest.json @@ -3,7 +3,7 @@ "id": "ModelDownloader", "name": "ModelDownloader", "author": "Bobbie", - "version": "1.1.5", + "version": "1.1.6", "description": "A PC Beat Saber mod that allows you to download Sabers, Notes, Platforms, and Avatars directly from ModelSaber, all from a convenient window within your game.", "gameVersion": "1.29.0", "dependsOn": { From af3282d1b4edabc1aa0b2d1248af24783f0d56ea Mon Sep 17 00:00:00 2001 From: kenx00x Date: Fri, 7 Apr 2023 16:58:51 +0200 Subject: [PATCH 8/9] fix indentation --- ModelDownloader/Utils/ModelsaberUtils.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ModelDownloader/Utils/ModelsaberUtils.cs b/ModelDownloader/Utils/ModelsaberUtils.cs index 9c05a5d..b0580d0 100644 --- a/ModelDownloader/Utils/ModelsaberUtils.cs +++ b/ModelDownloader/Utils/ModelsaberUtils.cs @@ -103,11 +103,11 @@ public static async Task GetModelBytes(ModelsaberEntry entry) if (!Uri.TryCreate(entry.Download, UriKind.Absolute, out downloadURL)) { downloadURL = new Uri(entry.Download.Substring(0, entry.Download.LastIndexOf("/")) + "/" + entry.Download); - } - //encode URL - int index = downloadURL.ToString().LastIndexOf('/'); - string basePart = downloadURL.ToString().Substring(0, index + 1); - string encodedPart = Uri.EscapeDataString(downloadURL.ToString().Substring(index + 1)); + } + //encode URL + int index = downloadURL.ToString().LastIndexOf('/'); + string basePart = downloadURL.ToString().Substring(0, index + 1); + string encodedPart = Uri.EscapeDataString(downloadURL.ToString().Substring(index + 1)); downloadURL = new Uri(basePart + encodedPart); client.BaseAddress = null; HttpResponseMessage response = await client.GetAsync(downloadURL); From e8c42d26ca24f9bde15f37946ae36e17fcf87fde Mon Sep 17 00:00:00 2001 From: kenx00x Date: Fri, 7 Apr 2023 17:00:29 +0200 Subject: [PATCH 9/9] fix indentation --- ModelDownloader/Utils/ModelsaberUtils.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ModelDownloader/Utils/ModelsaberUtils.cs b/ModelDownloader/Utils/ModelsaberUtils.cs index b0580d0..bc4d203 100644 --- a/ModelDownloader/Utils/ModelsaberUtils.cs +++ b/ModelDownloader/Utils/ModelsaberUtils.cs @@ -107,8 +107,8 @@ public static async Task GetModelBytes(ModelsaberEntry entry) //encode URL int index = downloadURL.ToString().LastIndexOf('/'); string basePart = downloadURL.ToString().Substring(0, index + 1); - string encodedPart = Uri.EscapeDataString(downloadURL.ToString().Substring(index + 1)); - downloadURL = new Uri(basePart + encodedPart); + string encodedPart = Uri.EscapeDataString(downloadURL.ToString().Substring(index + 1)); + downloadURL = new Uri(basePart + encodedPart); client.BaseAddress = null; HttpResponseMessage response = await client.GetAsync(downloadURL); byte[] modelBytes = await response.Content.ReadAsByteArrayAsync();