feat: support specifying the MDS to use with a property
This commit is contained in:
parent
9db150efe6
commit
91c5686fde
|
@ -1,9 +1,11 @@
|
||||||
package io.gitlab.jfronny.inceptum.launcher.system.mds;
|
package io.gitlab.jfronny.inceptum.launcher.system.mds;
|
||||||
|
|
||||||
import io.gitlab.jfronny.commons.throwable.ThrowingBiConsumer;
|
import io.gitlab.jfronny.commons.throwable.ThrowingBiConsumer;
|
||||||
|
import io.gitlab.jfronny.inceptum.common.Utils;
|
||||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.InstanceMeta;
|
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.InstanceMeta;
|
||||||
import io.gitlab.jfronny.inceptum.launcher.system.mds.flow.FlowMds;
|
import io.gitlab.jfronny.inceptum.launcher.system.mds.flow.FlowMds;
|
||||||
import io.gitlab.jfronny.inceptum.launcher.system.mds.noop.NoopMds;
|
import io.gitlab.jfronny.inceptum.launcher.system.mds.noop.NoopMds;
|
||||||
|
import io.gitlab.jfronny.inceptum.launcher.system.mds.threaded.ThreadedMds;
|
||||||
import io.gitlab.jfronny.inceptum.launcher.util.GameVersionParser;
|
import io.gitlab.jfronny.inceptum.launcher.util.GameVersionParser;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
@ -13,9 +15,22 @@ import java.nio.file.Path;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface ModsDirScanner extends Closeable {
|
public interface ModsDirScanner extends Closeable {
|
||||||
|
String MDS_KIND = switch (System.getProperty("inceptum.mds.kind", "flow").toLowerCase()) {
|
||||||
|
case "flow" -> "flow";
|
||||||
|
case "threaded" -> "threaded";
|
||||||
|
case "noop" -> "noop";
|
||||||
|
case String s -> {
|
||||||
|
Utils.LOGGER.error("Unknown mds kind: " + s + ", using flow");
|
||||||
|
yield "flow";
|
||||||
|
}
|
||||||
|
};
|
||||||
static ModsDirScanner get(Path modsDir, InstanceMeta meta) throws IOException {
|
static ModsDirScanner get(Path modsDir, InstanceMeta meta) throws IOException {
|
||||||
if (Files.exists(modsDir)) return FlowMds.get(modsDir, meta);//ThreadedMds.get(modsDir, meta);
|
//TODO use a primitive pattern and guard once available
|
||||||
return new NoopMds(GameVersionParser.getGameVersion(meta.gameVersion));
|
return switch (MDS_KIND) {
|
||||||
|
case String s when s.equals("flow") && Files.exists(modsDir) -> FlowMds.get(modsDir, meta);
|
||||||
|
case String s when s.equals("threaded") && Files.exists(modsDir) -> ThreadedMds.get(modsDir, meta);
|
||||||
|
default -> new NoopMds(GameVersionParser.getGameVersion(meta.gameVersion));
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void closeAll() {
|
static void closeAll() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user