Skip to content

Commit

Permalink
minecraft and optifine autoconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
nacrt committed Feb 14, 2021
1 parent d512961 commit 70936d3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
9 changes: 9 additions & 0 deletions SkyblockClient/Config/ConfigUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
20 changes: 20 additions & 0 deletions SkyblockClient/Config/ModConfigWorkers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions SkyblockClient/Persistence/PersistenceMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,6 +14,7 @@ class PersistenceMain
{
public static async Task InstallPacks(List<PackOption> packs)
{
await Config.ConfigUtils.StartWorker("minecraft");
await UpdateMinecraftConfigForPacks(new PersistencePacksList(packs).Packs);
await InstallUniversal(Globals.skyblockResourceLocation, packs.ToArray(), "resourcepacks", false);
}
Expand Down Expand Up @@ -71,21 +71,21 @@ public static async Task InstallUniversal(string location, Option[] enabledOptio

if (isMods && setAutoconfig)
{
List<Task> tasks1 = new List<Task>();
foreach (ModOption mod in enabledOptions)
{
List<Task> tasks1 = new List<Task>();
try
{
tasks1.Add(Config.ConfigUtils.CreateModConfigWorker(mod));
tasks1.Add(Config.ConfigUtils.StartWorker(mod.Id));
}
catch (Exception e)
{
Utils.Debug(e.Message);
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)
Expand Down
2 changes: 1 addition & 1 deletion SkyblockClient/SkyblockClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ProjectGuid>{2DEA9CD8-419E-4F59-82D9-D089DC282BB7}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>SkyblockClient</RootNamespace>
<AssemblyName>SkyblockClient-1.3.3</AssemblyName>
<AssemblyName>SkyblockClient-1.3.4</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Expand Down

0 comments on commit 70936d3

Please sign in to comment.