Compare commits
3 Commits
cbba1ab70a
...
0bd675fc7c
Author | SHA1 | Date |
---|---|---|
Johannes Frohnmeyer | 0bd675fc7c | |
Johannes Frohnmeyer | bcd4e34f7a | |
Johannes Frohnmeyer | 7a7d009e29 |
|
@ -1,5 +1,6 @@
|
|||
package io.gitlab.jfronny.inceptum.launcher.model.inceptum;
|
||||
|
||||
import io.gitlab.jfronny.gson.compile.annotations.GPrefer;
|
||||
import io.gitlab.jfronny.gson.compile.annotations.GSerializable;
|
||||
import io.gitlab.jfronny.inceptum.common.GsonPreset;
|
||||
|
||||
|
@ -39,18 +40,21 @@ public class InstanceMeta {
|
|||
}
|
||||
|
||||
public void checkArguments() {
|
||||
arguments = arguments == null ? Arguments.EMPTY : arguments.checked();
|
||||
arguments = Arguments.checked(arguments);
|
||||
}
|
||||
|
||||
@GSerializable(configure = GsonPreset.Config.class)
|
||||
public record Arguments(List<String> jvm, List<String> client, List<String> server) {
|
||||
public static final Arguments EMPTY = new Arguments(List.of(), List.of(), List.of());
|
||||
|
||||
public Arguments checked() {
|
||||
@GPrefer public Arguments {}
|
||||
|
||||
public static Arguments checked(Arguments of) {
|
||||
if (of == null) return EMPTY;
|
||||
return new Arguments(
|
||||
jvm == null ? List.of() : jvm,
|
||||
client == null ? List.of() : client,
|
||||
server == null ? List.of() : server
|
||||
of.jvm == null ? List.of() : of.jvm,
|
||||
of.client == null ? List.of() : of.client,
|
||||
of.server == null ? List.of() : of.server
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ public class ModrinthImporter extends Importer<ModrinthModpackManifest> {
|
|||
protected void downloadMods(ModrinthModpackManifest manifest, Path instanceDir, ProcessState state) throws IOException {
|
||||
if (manifest.files() != null) {
|
||||
filesLoop: for (ModrinthModpackManifest.File file : manifest.files()) {
|
||||
Path path = instanceDir.getParent().resolve(file.path()).toAbsolutePath().normalize();
|
||||
if (!path.startsWith(instanceDir)) throw new IOException("Pack attempted to write file outside instance. This is unsupported!");
|
||||
Path path = instanceDir.resolve(file.path()).toAbsolutePath().normalize();
|
||||
if (!path.startsWith(instanceDir)) throw new IOException("Pack attempted to write file outside instance which is dangerous and thus unsupported: " + path);
|
||||
String sha1 = file.hashes().sha1();
|
||||
IOException failedDownload = new IOException("Could not download file");
|
||||
for (String url : file.downloads()) {
|
||||
|
|
|
@ -105,7 +105,7 @@ public record Instance(String id, Path path, InstanceMeta meta, ModsDirScanner m
|
|||
|
||||
public static void setSetupLock(Path instanceDir, boolean state) throws IOException {
|
||||
if (Files.exists(instanceDir.resolve(SETUP_LOCK_NAME))) {
|
||||
if (!state) Files.delete(instanceDir.resolve(SETUP_LOCK_NAME));
|
||||
if (!state) Files.deleteIfExists(instanceDir.resolve(SETUP_LOCK_NAME));
|
||||
} else {
|
||||
if (state) Files.createDirectories(instanceDir.resolve(SETUP_LOCK_NAME));
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public record Instance(String id, Path path, InstanceMeta meta, ModsDirScanner m
|
|||
try {
|
||||
if (ProcessUtils.isProcessAlive(Files.readString(path.resolve(LOCK_NAME))))
|
||||
return true;
|
||||
Files.delete(path.resolve(LOCK_NAME));
|
||||
Files.deleteIfExists(path.resolve(LOCK_NAME));
|
||||
} catch (IOException e) {
|
||||
Utils.LOGGER.error("Could not read running lock of " + getName(), e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue