53 lines
2.2 KiB
Java
53 lines
2.2 KiB
Java
package io.gitlab.jfronny.inceptum.launcher.system.setup;
|
|
|
|
import io.gitlab.jfronny.inceptum.launcher.api.FabricMetaApi;
|
|
import io.gitlab.jfronny.inceptum.launcher.api.McApi;
|
|
import io.gitlab.jfronny.inceptum.launcher.model.mojang.VersionInfo;
|
|
import io.gitlab.jfronny.inceptum.launcher.model.mojang.VersionsListInfo;
|
|
import io.gitlab.jfronny.inceptum.launcher.system.instance.Instance;
|
|
import io.gitlab.jfronny.inceptum.launcher.system.instance.LoaderInfo;
|
|
import io.gitlab.jfronny.inceptum.launcher.system.setup.steps.*;
|
|
import io.gitlab.jfronny.inceptum.launcher.util.ProcessState;
|
|
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
|
|
public class Steps {
|
|
public static Set<Step> STEPS = new LinkedHashSet<>(List.of(
|
|
new SetupDirsStep(),
|
|
new DownloadJavaStep(),
|
|
new DownloadClientStep(),
|
|
new DownloadLibrariesStep(),
|
|
new DownloadAssetsStep(),
|
|
new WriteMetadataStep(),
|
|
new RunMdsStep()
|
|
));
|
|
|
|
public static ProcessState createProcessState() {
|
|
return new ProcessState(STEPS.size(), "Initializing");
|
|
}
|
|
|
|
public static void reDownload(Instance instance, ProcessState state) throws IOException {
|
|
if (instance.isLocked) return;
|
|
boolean found = false;
|
|
for (VersionsListInfo version : McApi.getVersions().versions) {
|
|
if (version.id.equals(instance.gameVersion)) {
|
|
found = true;
|
|
VersionInfo vi = McApi.getVersionInfo(version);
|
|
if (instance.isFabric)
|
|
vi = FabricMetaApi.addFabric(vi, instance.loaderVersion, FabricMetaApi.FabricVersionInfoType.Both);
|
|
LoaderInfo li = instance.isFabric
|
|
? new LoaderInfo(LoaderInfo.Type.Fabric, instance.loaderVersion)
|
|
: LoaderInfo.NONE;
|
|
SetupStepInfo info = new SetupStepInfo(vi, li, instance.name, state);
|
|
for (Step step : Steps.STEPS) {
|
|
state.incrementStep(step.name);
|
|
step.execute(info);
|
|
if (state.isCancelled) return;
|
|
}
|
|
}
|
|
}
|
|
if (!found) throw new IOException("Could not identify minecraft version " + instance.gameVersion);
|
|
}
|
|
}
|