From 70936d3c42ee12d534f2cb8bc782bf71e63ade29 Mon Sep 17 00:00:00 2001 From: nacrt <37629791+nacrt@users.noreply.github.com> Date: Sun, 14 Feb 2021 11:44:06 +0100 Subject: [PATCH] minecraft and optifine autoconfig --- SkyblockClient/Config/ConfigUtil.cs | 9 +++++++++ SkyblockClient/Config/ModConfigWorkers.cs | 20 +++++++++++++++++++ SkyblockClient/Persistence/PersistenceMain.cs | 8 ++++---- SkyblockClient/SkyblockClient.csproj | 2 +- 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/SkyblockClient/Config/ConfigUtil.cs b/SkyblockClient/Config/ConfigUtil.cs index f9d3a94..19688ae 100644 --- a/SkyblockClient/Config/ConfigUtil.cs +++ b/SkyblockClient/Config/ConfigUtil.cs @@ -64,5 +64,14 @@ public ModConfigWorkerCollection(Type configWorker, ModConfigWorkerAttribute wor this.workerAttribute = workerAttribute; } } + + public static async Task StartWorker(string id) + { + if (Utils.AvailableModOptions.ContainsKey(id)) + { + var mod = Utils.AvailableModOptions[id]; + await CreateModConfigWorker(mod); + } + } } } diff --git a/SkyblockClient/Config/ModConfigWorkers.cs b/SkyblockClient/Config/ModConfigWorkers.cs index d1dd6c7..1ba1e00 100644 --- a/SkyblockClient/Config/ModConfigWorkers.cs +++ b/SkyblockClient/Config/ModConfigWorkers.cs @@ -8,6 +8,26 @@ namespace SkyblockClient.Config { + [ModConfigWorker("minecraft")] + class ModConfigWorkerMinecraft : ModConfigWorkerBase + { + public override async Task Work() + { + string optionsFile = await helper.DownloadFileByte("minecraftoptions.txt"); + helper.Move(optionsFile, Path.Combine(Globals.skyblockRootLocation, "options.txt")); + } + } + + [ModConfigWorker("optifine")] + class ModConfigWorkerOptifine : ModConfigWorkerBase + { + public override async Task Work() + { + string optionsFile = await helper.DownloadFileByte("optifinetoptions.txt"); + helper.Move(optionsFile, Path.Combine(Globals.skyblockRootLocation, "optionsof.txt")); + } + } + [ModConfigWorker("itlt")] class ModConfigWorkerITLT : ModConfigWorkerBase { diff --git a/SkyblockClient/Persistence/PersistenceMain.cs b/SkyblockClient/Persistence/PersistenceMain.cs index 75386d4..8d3a411 100644 --- a/SkyblockClient/Persistence/PersistenceMain.cs +++ b/SkyblockClient/Persistence/PersistenceMain.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Net; using System.Threading.Tasks; -using System.Windows; using Newtonsoft.Json; using SkyblockClient.Options; using SkyblockClient.Persistence.Data; @@ -15,6 +14,7 @@ class PersistenceMain { public static async Task InstallPacks(List packs) { + await Config.ConfigUtils.StartWorker("minecraft"); await UpdateMinecraftConfigForPacks(new PersistencePacksList(packs).Packs); await InstallUniversal(Globals.skyblockResourceLocation, packs.ToArray(), "resourcepacks", false); } @@ -71,12 +71,12 @@ public static async Task InstallUniversal(string location, Option[] enabledOptio if (isMods && setAutoconfig) { + List tasks1 = new List(); foreach (ModOption mod in enabledOptions) { - List tasks1 = new List(); try { - tasks1.Add(Config.ConfigUtils.CreateModConfigWorker(mod)); + tasks1.Add(Config.ConfigUtils.StartWorker(mod.Id)); } catch (Exception e) { @@ -84,8 +84,8 @@ public static async Task InstallUniversal(string location, Option[] enabledOptio Utils.Error("An Unknown error occured, please submit the log file"); Utils.Log(e, "unkown error in Installer():if(isMods)"); } - await Task.WhenAll(tasks1.ToArray()); } + await Task.WhenAll(tasks1.ToArray()); } } catch (Exception e) diff --git a/SkyblockClient/SkyblockClient.csproj b/SkyblockClient/SkyblockClient.csproj index 4b1bbfe..f012ac7 100644 --- a/SkyblockClient/SkyblockClient.csproj +++ b/SkyblockClient/SkyblockClient.csproj @@ -8,7 +8,7 @@ {2DEA9CD8-419E-4F59-82D9-D089DC282BB7} Exe SkyblockClient - SkyblockClient-1.3.3 + SkyblockClient-1.3.4 v4.7.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}