Move more things
This commit is contained in:
parent
5c6266634a
commit
7e42e6b02f
|
@ -28,9 +28,7 @@ public class ExportCommand extends BaseInstanceCommand {
|
|||
if (args.length == 0) throw new IllegalAccessException("You must specify a target path");
|
||||
if (args.length == 1) throw new IllegalAccessException("You must specify a version number");
|
||||
if (args.length != 2) throw new IllegalAccessException("Too many arguments");
|
||||
ProcessState state = new ProcessState();
|
||||
instance.getMds().runOnce(R::nop);
|
||||
Exporters.CURSE_FORGE.generate(state, instance, Paths.get(args.get(0)), args.get(1));
|
||||
Exporters.CURSE_FORGE.generate(new ProcessState(), instance, Paths.get(args.get(0)), args.get(1));
|
||||
}
|
||||
|
||||
private static class MultiMCExportCommand extends BaseInstanceCommand {
|
||||
|
@ -42,9 +40,7 @@ public class ExportCommand extends BaseInstanceCommand {
|
|||
protected void invoke(CommandArgs args, Instance instance) throws Exception {
|
||||
if (args.length == 0) throw new IllegalAccessException("You must specify a target path");
|
||||
if (args.length != 1) throw new IllegalAccessException("Too many arguments");
|
||||
ProcessState state = new ProcessState();
|
||||
instance.getMds().runOnce(R::nop);
|
||||
Exporters.MULTI_MC.generate(state, instance, Paths.get(args.get(0)), "1.0");
|
||||
Exporters.MULTI_MC.generate(new ProcessState(), instance, Paths.get(args.get(0)), "1.0");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,9 +54,7 @@ public class ExportCommand extends BaseInstanceCommand {
|
|||
if (args.length == 0) throw new IllegalAccessException("You must specify a target path");
|
||||
if (args.length == 1) throw new IllegalAccessException("You must specify a version number");
|
||||
if (args.length != 2) throw new IllegalAccessException("Too many arguments");
|
||||
ProcessState state = new ProcessState();
|
||||
instance.getMds().runOnce(R::nop);
|
||||
Exporters.MODRINTH.generate(state, instance, Paths.get(args.get(0)), args.get(1));
|
||||
Exporters.MODRINTH.generate(new ProcessState(), instance, Paths.get(args.get(0)), args.get(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import io.gitlab.jfronny.inceptum.cli.*;
|
|||
import io.gitlab.jfronny.inceptum.common.Utils;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.InstanceMeta;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt.Instance;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.launch.InstanceLauncher;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.launch.*;
|
||||
import io.gitlab.jfronny.inceptum.launcher.api.account.AccountManager;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.install.Steps;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class LaunchCommand extends BaseInstanceCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void invoke(CommandArgs args, Instance instance) throws IOException, InstanceLauncher.LaunchException {
|
||||
protected void invoke(CommandArgs args, Instance instance) throws IOException, LaunchException {
|
||||
if (instance.isSetupLocked()) {
|
||||
Utils.LOGGER.error("This instance is still being set up");
|
||||
return;
|
||||
|
@ -56,7 +56,7 @@ public class LaunchCommand extends BaseInstanceCommand {
|
|||
}
|
||||
Steps.reDownload(instance, Steps.createProcessState());
|
||||
if (server) {
|
||||
InstanceLauncher.launch(instance, InstanceLauncher.LaunchType.Server, restart, AccountManager.NULL_AUTH);
|
||||
InstanceLauncher.launch(instance, LaunchType.Server, restart, AccountManager.NULL_AUTH);
|
||||
} else {
|
||||
AccountManager.loadAccounts();
|
||||
InstanceLauncher.launchClient(instance);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class ModCommand extends Command {
|
|||
return;
|
||||
}
|
||||
System.out.println("Scanning installed mods, this might take a while");
|
||||
instance.getMds().runOnce((path, mod) -> {
|
||||
instance.mds().runOnce((path, mod) -> {
|
||||
boolean hasSources = mod.mod().isPresent() && !mod.mod().get().sources.isEmpty();
|
||||
boolean updatable = hasSources && mod.mod().get().sources.values().stream().anyMatch(Optional::isPresent);
|
||||
if (filterUpdatable && !updatable) return;
|
||||
|
@ -109,14 +109,14 @@ public class ModCommand extends Command {
|
|||
}
|
||||
mods.add(p);
|
||||
}
|
||||
ModsDirScanner mds = instance.getMds();
|
||||
ModsDirScanner mds = instance.mds();
|
||||
if (!ignoreDependencies && !mds.isComplete()) {
|
||||
Utils.LOGGER.error("Scanning mods dir to search for dependencies. This might take a while");
|
||||
mds.runOnce((path, mod) -> System.out.println("Scanned " + path));
|
||||
}
|
||||
for (Path mod : mods) {
|
||||
try {
|
||||
ModManager.delete(mds.get(mod), instance.modsDir(), mds);
|
||||
ModManager.delete(instance, mds.get(mod));
|
||||
} catch (IOException e) {
|
||||
Utils.LOGGER.error("Could not delete " + mod, e);
|
||||
return;
|
||||
|
@ -159,7 +159,7 @@ public class ModCommand extends Command {
|
|||
throw new IllegalArgumentException("You must specify mods to remove");
|
||||
}
|
||||
Set<Path> mods = pathSupplier.apply(args, instance.path());
|
||||
ModsDirScanner mds = instance.getMds();
|
||||
ModsDirScanner mds = instance.mds();
|
||||
if (!mds.isComplete()) {
|
||||
Utils.LOGGER.error("Scanning mods dir to search for dependencies. This might take a while");
|
||||
mds.runOnce((path, mod) -> System.out.println("Scanned " + path));
|
||||
|
@ -167,7 +167,7 @@ public class ModCommand extends Command {
|
|||
for (Path mod : mods) {
|
||||
try {
|
||||
Utils.LOGGER.info("Updating " + mod);
|
||||
ModManager.delete(mds.get(mod), instance.modsDir(), mds);
|
||||
ModManager.delete(instance, mds.get(mod));
|
||||
Mod md = mds.get(mod);
|
||||
if (md.mod().isEmpty()) {
|
||||
throw new IOException("Could not load mod description");
|
||||
|
|
|
@ -15,6 +15,7 @@ import io.gitlab.jfronny.inceptum.imgui.window.Window;
|
|||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.InstanceMeta;
|
||||
import io.gitlab.jfronny.inceptum.launcher.api.account.AccountManager;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.mds.ModsDirScanner;
|
||||
import io.gitlab.jfronny.inceptum.launcher.util.InstanceList;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.PointerBuffer;
|
||||
import org.lwjgl.glfw.*;
|
||||
|
@ -60,10 +61,7 @@ public class GuiMain {
|
|||
AccountManager.loadAccounts();
|
||||
Utils.LOGGER.info("Initializing UI");
|
||||
try {
|
||||
JFiles.listTo(MetaHolder.INSTANCE_DIR, path -> {
|
||||
if (Files.exists(path.resolve("instance.json")))
|
||||
ModsDirScanner.get(path.resolve("mods"), JFiles.readObject(path.resolve("instance.json"), InstanceMeta.class)).start();
|
||||
});
|
||||
InstanceList.forEach(instance -> instance.mds().start());
|
||||
} catch (IOException e) {
|
||||
Utils.LOGGER.error("Could not initialize MDS");
|
||||
}
|
||||
|
|
|
@ -7,8 +7,7 @@ import io.gitlab.jfronny.commons.tuple.Tuple;
|
|||
import io.gitlab.jfronny.inceptum.common.*;
|
||||
import io.gitlab.jfronny.inceptum.imgui.window.GuiUtil;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.fabric.FabricVersionLoaderInfo;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.InstanceMeta;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.LoaderInfo;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt.LoaderInfo;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt.Instance;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.mojang.*;
|
||||
import io.gitlab.jfronny.inceptum.launcher.api.FabricMetaApi;
|
||||
|
|
|
@ -25,9 +25,7 @@ import java.util.List;
|
|||
|
||||
public class AddModWindow extends Window {
|
||||
private final ImString query = new ImString("", GuiUtil.INPUT_FIELD_LENGTH);
|
||||
private final Path modsDir;
|
||||
private final InstanceMeta instance;
|
||||
private final ModsDirScanner mds;
|
||||
private final Instance instance;
|
||||
private int cfPage = 0;
|
||||
private int mrPage = 0;
|
||||
private ModrinthSearchResult mr = null;
|
||||
|
@ -35,19 +33,17 @@ public class AddModWindow extends Window {
|
|||
|
||||
public AddModWindow(Instance instance) throws IOException {
|
||||
super(instance.getName() + " - Add Mods");
|
||||
this.modsDir = instance.modsDir();
|
||||
this.instance = instance.meta();
|
||||
this.mds = instance.getMds();
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
private void reSearch() throws IOException {
|
||||
String query = this.query.get();
|
||||
new Thread(() -> {
|
||||
try {
|
||||
ModrinthSearchResult ms = ModrinthApi.search(query, mrPage, instance.getMinecraftVersion(), ModrinthProjectType.mod);
|
||||
ModrinthSearchResult ms = ModrinthApi.search(query, mrPage, instance.meta().getMinecraftVersion(), ModrinthProjectType.mod);
|
||||
if (!this.query.get().equals(query)) return;
|
||||
mr = ms;
|
||||
List<CurseforgeMod> cs = CurseforgeApi.search(instance.getMinecraftVersion(), query, cfPage, "Popularity");
|
||||
List<CurseforgeMod> cs = CurseforgeApi.search(instance.meta().getMinecraftVersion(), query, cfPage, "Popularity");
|
||||
if (!this.query.get().equals(query)) return;
|
||||
cf = cs;
|
||||
} catch (IOException e) {
|
||||
|
@ -80,7 +76,7 @@ public class AddModWindow extends Window {
|
|||
reSearch();
|
||||
}
|
||||
}
|
||||
if (mr != null && ImGui.beginTable("mods" + modsDir, 3, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders)) {
|
||||
if (mr != null && ImGui.beginTable("mods" + instance.id(), 3, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders)) {
|
||||
for (ModrinthSearchResult.ModResult mod : mr.hits) {
|
||||
String modId = (mod.slug != null ? mod.slug : mod.project_id);
|
||||
final String idPrefix = "local-";
|
||||
|
@ -93,7 +89,7 @@ public class AddModWindow extends Window {
|
|||
ImGui.text(mod.description);
|
||||
ImGui.tableNextColumn();
|
||||
boolean alreadyPresent = false;
|
||||
for (Mod mdsMod : mds.getMods()) {
|
||||
for (Mod mdsMod : instance.getMods()) {
|
||||
alreadyPresent = mdsMod.mod().isPresent()
|
||||
&& mdsMod.mod().get().sources.keySet().stream()
|
||||
.anyMatch(s -> s instanceof ModrinthModSource ms
|
||||
|
@ -109,7 +105,7 @@ public class AddModWindow extends Window {
|
|||
ModrinthVersion beta = null;
|
||||
ModrinthVersion latest = null;
|
||||
for (ModrinthVersion version : ModrinthApi.getVersions(mod.project_id)) {
|
||||
if (version.game_versions.contains(instance.getMinecraftVersion()) && version.loaders.contains("fabric")) {
|
||||
if (version.game_versions.contains(instance.meta().getMinecraftVersion()) && version.loaders.contains("fabric")) {
|
||||
latest = version;
|
||||
if (version.version_type == ModrinthVersion.VersionType.beta || version.version_type == ModrinthVersion.VersionType.release) {
|
||||
beta = version;
|
||||
|
@ -127,7 +123,7 @@ public class AddModWindow extends Window {
|
|||
ModrinthVersion finalLatest = latest;
|
||||
new Thread(() -> {
|
||||
try {
|
||||
ModManager.download(new ModrinthModSource(finalLatest.id), modsDir.resolve((mod.slug == null ? mod.project_id : mod.slug) + ModPath.EXT_IMOD), mds).write();
|
||||
ModManager.download(new ModrinthModSource(finalLatest.id), instance.modsDir().resolve((mod.slug == null ? mod.project_id : mod.slug) + ModPath.EXT_IMOD), instance.mds()).write();
|
||||
} catch (IOException e) {
|
||||
LauncherEnv.showError("Could not download mod", e);
|
||||
}
|
||||
|
@ -160,7 +156,7 @@ public class AddModWindow extends Window {
|
|||
reSearch();
|
||||
}
|
||||
}
|
||||
if (cf != null && ImGui.beginTable("curseforge" + modsDir, 3, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders)) {
|
||||
if (cf != null && ImGui.beginTable("curseforge" + instance.id(), 3, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders)) {
|
||||
for (CurseforgeMod mod : cf) {
|
||||
//TODO detail view
|
||||
ImGui.tableNextColumn();
|
||||
|
@ -169,7 +165,7 @@ public class AddModWindow extends Window {
|
|||
ImGui.text(mod.summary);
|
||||
ImGui.tableNextColumn();
|
||||
boolean alreadyPresent = false;
|
||||
for (Mod mdsMod : mds.getMods()) {
|
||||
for (Mod mdsMod : instance.mds().getMods()) {
|
||||
alreadyPresent = mdsMod.mod().isPresent()
|
||||
&& mdsMod.mod().get().sources.keySet().stream()
|
||||
.anyMatch(s -> s instanceof CurseforgeModSource ms
|
||||
|
@ -183,7 +179,7 @@ public class AddModWindow extends Window {
|
|||
if (ImGui.button("Add##" + mod.id)) {
|
||||
CurseforgeMod.LatestFileIndex latest = null;
|
||||
for (CurseforgeMod.LatestFileIndex file : mod.latestFilesIndexes) {
|
||||
if (file.gameVersion.equals(instance.getMinecraftVersion())) {
|
||||
if (file.gameVersion.equals(instance.meta().getMinecraftVersion())) {
|
||||
if (latest == null) latest = file;
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +189,7 @@ public class AddModWindow extends Window {
|
|||
CurseforgeMod.LatestFileIndex finalLatest = latest;
|
||||
new Thread(() -> {
|
||||
try {
|
||||
ModManager.download(new CurseforgeModSource(mod.id, finalLatest.fileId), modsDir.resolve((mod.slug == null ? mod.id : mod.slug) + ModPath.EXT_IMOD), mds).write();
|
||||
ModManager.download(new CurseforgeModSource(mod.id, finalLatest.fileId), instance.modsDir().resolve((mod.slug == null ? mod.id : mod.slug) + ModPath.EXT_IMOD), instance.mds()).write();
|
||||
} catch (IOException e) {
|
||||
LauncherEnv.showError("Could not download mod", e);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ExportTab extends Tab {
|
|||
|
||||
@Override
|
||||
protected void renderInner() {
|
||||
if (window.mds.isComplete()) {
|
||||
if (window.instance.mds().isComplete()) {
|
||||
for (Exporter<?> exporter : Exporters.EXPORTERS) {
|
||||
if (ImGui.button(exporter.getName())) {
|
||||
GuiMain.open(new TextBoxWindow("Version", "Please enter the current version of your modpack", "1.0", version -> {
|
||||
|
|
|
@ -5,14 +5,12 @@ import io.gitlab.jfronny.inceptum.imgui.control.Tab;
|
|||
import io.gitlab.jfronny.inceptum.imgui.window.GuiUtil;
|
||||
import io.gitlab.jfronny.inceptum.imgui.window.Window;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt.Instance;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.mds.ModsDirScanner;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class InstanceEditWindow extends Window {
|
||||
protected final Instance instance;
|
||||
protected final ModsDirScanner mds;
|
||||
private final List<Tab> tabs;
|
||||
protected boolean reDownload = false;
|
||||
protected boolean lastTabWasMods = false;
|
||||
|
@ -20,8 +18,7 @@ public class InstanceEditWindow extends Window {
|
|||
public InstanceEditWindow(Instance instance) throws IOException {
|
||||
super(instance.getName() + " - Edit");
|
||||
this.instance = instance;
|
||||
this.mds = instance.getMds();
|
||||
this.mds.start();
|
||||
this.instance.mds().start();
|
||||
this.tabs = List.of(
|
||||
new GeneralTab(this),
|
||||
new ArgumentsTab(this),
|
||||
|
|
|
@ -54,12 +54,12 @@ public class ModsTab extends Tab {
|
|||
Utils.openFile(window.instance.configDir().toFile());
|
||||
}
|
||||
try {
|
||||
Set<Mod> modSet = window.mds.getMods();
|
||||
Set<Mod> modSet = window.instance.getMods();
|
||||
boolean updatesFound = false;
|
||||
float scannedPercentage = 0;
|
||||
boolean hasUnScanned = false;
|
||||
for (Mod mod : modSet) {
|
||||
if (window.mds.hasScanned(mod.path())) scannedPercentage++;
|
||||
if (window.instance.mds().hasScanned(mod.path())) scannedPercentage++;
|
||||
else hasUnScanned = true;
|
||||
if (mod.mod().isEmpty()) continue;
|
||||
for (Optional<ModSource> value : mod.mod().get().sources.values()) {
|
||||
|
@ -108,8 +108,8 @@ public class ModsTab extends Tab {
|
|||
ImGui.beginGroup();
|
||||
if (selected == null) {
|
||||
ImGui.text("Select a mod to view settings");
|
||||
} else if (window.mds.hasScanned(selected)) {
|
||||
Mod md = window.mds.get(selected);
|
||||
} else if (window.instance.mds().hasScanned(selected)) {
|
||||
Mod md = window.instance.mds().get(selected);
|
||||
ImGui.text(md.getName());
|
||||
ImGui.separator();
|
||||
for (String s : md.getDescription()) {
|
||||
|
@ -130,13 +130,13 @@ public class ModsTab extends Tab {
|
|||
if (ImGui.button("Update to " + ms.get().getVersion())) {
|
||||
try {
|
||||
Path imodPath = md.imod().isPresent() ? md.imod().get() : window.instance.modsDir().resolve(ms.get().getShortName() + ModPath.EXT_IMOD);
|
||||
ModManager.DownloadMeta dm = ModManager.download(ms.get(), imodPath, window.mds);
|
||||
ModManager.DownloadMeta dm = ModManager.download(ms.get(), imodPath, window.instance.mds());
|
||||
Files.delete(md.path());
|
||||
if (md.imod().isPresent() && Files.exists(md.imod().get()))
|
||||
Files.delete(md.imod().get());
|
||||
dm.write();
|
||||
selected = imodPath;
|
||||
window.mds.invalidate(imodPath);
|
||||
window.instance.mds().invalidate(imodPath);
|
||||
} catch (IOException e) {
|
||||
LauncherEnv.showError("Update failed", e);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ public class ModsTab extends Tab {
|
|||
}
|
||||
|
||||
private void delete(Mod md) throws IOException {
|
||||
ModManager.delete(md, window.instance.modsDir(), window.mds);
|
||||
ModManager.delete(window.instance, md);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt;
|
||||
|
||||
import io.gitlab.jfronny.commons.io.JFiles;
|
||||
import io.gitlab.jfronny.inceptum.common.R;
|
||||
import io.gitlab.jfronny.inceptum.common.Utils;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.InstanceMeta;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.mds.ModsDirScanner;
|
||||
|
@ -11,19 +12,21 @@ import java.io.IOException;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Set;
|
||||
|
||||
public record Instance(String id, Path path, InstanceMeta meta) implements Comparable<Instance> {
|
||||
public record Instance(String id, Path path, InstanceMeta meta, ModsDirScanner mds) implements Comparable<Instance> {
|
||||
private static final String INCEPTUM_LOCK = "inceptum.lock";
|
||||
private static final String INCEPTUM_SETUP_LOCK = "inceptum.setup.lock";
|
||||
|
||||
public Instance(Path path, InstanceMeta meta) {
|
||||
this(generateId(path.getFileName().toString()), path, meta);
|
||||
public Instance(Path path, InstanceMeta meta) throws IOException {
|
||||
this(generateId(path.getFileName().toString()), path, meta, ModsDirScanner.get(path.resolve("mods"), meta));
|
||||
}
|
||||
|
||||
public Instance(String id, Path path, InstanceMeta meta) {
|
||||
public Instance(String id, Path path, InstanceMeta meta, ModsDirScanner mds) {
|
||||
this.id = id;
|
||||
this.path = path.toAbsolutePath().normalize();
|
||||
this.meta = meta;
|
||||
this.mds = mds;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,8 +71,9 @@ public record Instance(String id, Path path, InstanceMeta meta) implements Compa
|
|||
return path.resolve("config");
|
||||
}
|
||||
|
||||
public ModsDirScanner getMds() throws IOException {
|
||||
return ModsDirScanner.get(modsDir(), meta);
|
||||
public Set<Mod> getMods() throws IOException {
|
||||
mds.runOnce(R::nop);
|
||||
return mds.getMods();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package io.gitlab.jfronny.inceptum.launcher.model.inceptum;
|
||||
package io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt;
|
||||
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.fabric.FabricLoaderVersion;
|
||||
|
|
@ -11,8 +11,7 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
public record Mod(Path path, Optional<ModDescription> mod, Optional<FabricModJson> fmj,
|
||||
Optional<Path> imod) implements Comparable<Mod> {
|
||||
public record Mod(Path path, Optional<ModDescription> mod, Optional<FabricModJson> fmj, Optional<Path> imod) implements Comparable<Mod> {
|
||||
public String getName() {
|
||||
if (fmj.isEmpty()) return path.getFileName().toString();
|
||||
String base;
|
||||
|
|
|
@ -36,9 +36,7 @@ public abstract class Exporter<Manifest> {
|
|||
Manifest manifest = generateManifests(root, instance, version);
|
||||
if (instance.isFabric()) {
|
||||
state.incrementStep("Adding mods");
|
||||
ModsDirScanner mds = instance.getMds();
|
||||
if (!mds.isComplete()) throw new IOException("Mods dir scan is not yet completed");
|
||||
addMods(root, instance, new StreamIterable<>(mds.getMods().stream().filter(mod -> {
|
||||
addMods(root, instance, new StreamIterable<>(instance.getMods().stream().filter(mod -> {
|
||||
if (!ModPath.isEnabled(mod.path())) return false;
|
||||
state.updateStep(mod.path().toString());
|
||||
return true;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package io.gitlab.jfronny.inceptum.launcher.system.install;
|
||||
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.LoaderInfo;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt.LoaderInfo;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.mojang.VersionInfo;
|
||||
import io.gitlab.jfronny.inceptum.launcher.util.ProcessState;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package io.gitlab.jfronny.inceptum.launcher.system.install;
|
|||
|
||||
import io.gitlab.jfronny.inceptum.launcher.api.FabricMetaApi;
|
||||
import io.gitlab.jfronny.inceptum.launcher.api.McApi;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.LoaderInfo;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt.LoaderInfo;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt.Instance;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.mojang.VersionInfo;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.mojang.VersionsListInfo;
|
||||
|
|
|
@ -2,7 +2,7 @@ package io.gitlab.jfronny.inceptum.launcher.system.install.steps;
|
|||
|
||||
import io.gitlab.jfronny.inceptum.common.MetaHolder;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.InstanceMeta;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.LoaderInfo;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt.LoaderInfo;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt.Instance;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.install.Step;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.install.SetupStepInfo;
|
||||
|
|
|
@ -236,26 +236,4 @@ public class InstanceLauncher {
|
|||
.replace("${classpath}", classPath)
|
||||
.replace("${user_properties}", "{}");
|
||||
}
|
||||
|
||||
public enum LaunchType {
|
||||
Server("server", FabricMetaApi.FabricVersionInfoType.Server), Client("client", FabricMetaApi.FabricVersionInfoType.Client);
|
||||
|
||||
LaunchType(String name, FabricMetaApi.FabricVersionInfoType fabricMetaType) {
|
||||
this.name = name;
|
||||
this.fabricMetaType = fabricMetaType;
|
||||
}
|
||||
|
||||
public final String name;
|
||||
public final FabricMetaApi.FabricVersionInfoType fabricMetaType;
|
||||
}
|
||||
|
||||
public static class LaunchException extends Exception {
|
||||
public LaunchException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public LaunchException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package io.gitlab.jfronny.inceptum.launcher.system.launch;
|
||||
|
||||
public class LaunchException extends Exception {
|
||||
public LaunchException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public LaunchException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package io.gitlab.jfronny.inceptum.launcher.system.launch;
|
||||
|
||||
import io.gitlab.jfronny.inceptum.launcher.api.FabricMetaApi;
|
||||
|
||||
public enum LaunchType {
|
||||
Server("server", FabricMetaApi.FabricVersionInfoType.Server), Client("client", FabricMetaApi.FabricVersionInfoType.Client);
|
||||
|
||||
LaunchType(String name, FabricMetaApi.FabricVersionInfoType fabricMetaType) {
|
||||
this.name = name;
|
||||
this.fabricMetaType = fabricMetaType;
|
||||
}
|
||||
|
||||
public final String name;
|
||||
public final FabricMetaApi.FabricVersionInfoType fabricMetaType;
|
||||
}
|
|
@ -2,6 +2,7 @@ package io.gitlab.jfronny.inceptum.launcher.util;
|
|||
|
||||
import io.gitlab.jfronny.commons.io.JFiles;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.ModDescription;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt.Instance;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.rt.Mod;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.mds.ModsDirScanner;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.source.ModDownload;
|
||||
|
@ -12,16 +13,16 @@ import java.nio.file.Files;
|
|||
import java.nio.file.Path;
|
||||
|
||||
public class ModManager {
|
||||
public static void delete(Mod md, Path modsDirectory, ModsDirScanner mds) throws IOException {
|
||||
public static void delete(Instance instance, Mod md) throws IOException {
|
||||
JFiles.deleteRecursive(md.path());
|
||||
if (md.imod().isPresent() && Files.exists(md.imod().get())) Files.delete(md.imod().get());
|
||||
if (md.mod().isPresent()) {
|
||||
for (String dependency : md.mod().get().dependencies) {
|
||||
Path dep = modsDirectory.resolve(dependency);
|
||||
Mod dmd = mds.get(dep);
|
||||
Path dep = instance.modsDir().resolve(dependency);
|
||||
Mod dmd = instance.mds().get(dep);
|
||||
if (dmd.mod().isPresent()) {
|
||||
dmd.mod().get().dependencies.remove(md.path().getFileName().toString());
|
||||
if (dmd.mod().get().dependencies.isEmpty()) delete(dmd, modsDirectory, mds);
|
||||
if (dmd.mod().get().dependencies.isEmpty()) delete(instance, dmd);
|
||||
else if (dmd.imod().isPresent()) JFiles.writeObject(dmd.imod().get(), dmd.mod().get());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue