Extract bundler for 1.18 server support
This commit is contained in:
parent
9d55944eee
commit
95c6990b5e
|
@ -22,7 +22,7 @@ allprojects {
|
|||
|
||||
ext {
|
||||
lwjglVersion = '3.2.3'
|
||||
imguiVersion = '1.84.1.3'
|
||||
imguiVersion = '1.84.1.4'
|
||||
log4jVersion = '2.14.1'
|
||||
flavorProp = project.hasProperty('flavor') ? project.getProperty('flavor') : 'custom'
|
||||
flavor = flavorProp
|
||||
|
@ -48,7 +48,7 @@ dependencies {
|
|||
implementation 'org.slf4j:slf4j-api:1.7.32'
|
||||
implementation 'ch.qos.logback:logback-classic:1.2.7'
|
||||
implementation 'net.freeutils:jlhttp:2.6'
|
||||
implementation 'org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r'
|
||||
implementation 'org.eclipse.jgit:org.eclipse.jgit:6.0.0.202111291000-r'
|
||||
implementation project(":wrapper")
|
||||
|
||||
implementation platform("org.lwjgl:lwjgl-bom:$lwjglVersion")
|
||||
|
|
|
@ -6,6 +6,7 @@ import io.gitlab.jfronny.inceptum.model.inceptum.InstanceMeta;
|
|||
import io.gitlab.jfronny.inceptum.model.inceptum.LoaderInfo;
|
||||
import io.gitlab.jfronny.inceptum.model.mojang.VersionInfo;
|
||||
import io.gitlab.jfronny.inceptum.model.mojang.VersionsListInfo;
|
||||
import io.gitlab.jfronny.inceptum.util.ProcessUtils;
|
||||
import io.gitlab.jfronny.inceptum.util.Utils;
|
||||
import io.gitlab.jfronny.inceptum.util.api.FabricMetaApi;
|
||||
import io.gitlab.jfronny.inceptum.util.api.McApi;
|
||||
|
@ -41,7 +42,11 @@ public class Steps {
|
|||
|
||||
public static void reDownload(Path instance) throws IOException {
|
||||
if (Files.exists(instance.resolve("inceptum.setup.lock"))) return;
|
||||
if (Files.exists(instance.resolve("inceptum.lock"))) return;
|
||||
if (Files.exists(instance.resolve("inceptum.lock"))) {
|
||||
if (ProcessUtils.isProcessAlive(Files.readString(instance.resolve("inceptum.lock")))) {
|
||||
return;
|
||||
} else Files.delete(instance.resolve("inceptum.lock"));
|
||||
}
|
||||
InstanceMeta im = Utils.loadObject(instance.resolve("instance.json"), InstanceMeta.class);
|
||||
boolean found = false;
|
||||
for (VersionsListInfo version : McApi.getVersions().versions) {
|
||||
|
|
|
@ -3,11 +3,14 @@ package io.gitlab.jfronny.inceptum.install.steps;
|
|||
import io.gitlab.jfronny.inceptum.Inceptum;
|
||||
import io.gitlab.jfronny.inceptum.install.SetupStepInfo;
|
||||
import io.gitlab.jfronny.inceptum.install.Step;
|
||||
import io.gitlab.jfronny.inceptum.model.ComparableVersion;
|
||||
import io.gitlab.jfronny.inceptum.model.inceptum.InstanceMeta;
|
||||
import io.gitlab.jfronny.inceptum.model.mojang.MojangFileDownload;
|
||||
import io.gitlab.jfronny.inceptum.util.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -27,10 +30,27 @@ public class DownloadClientStep implements Step {
|
|||
info.setState("Downloading Client");
|
||||
Utils.downloadFile(client.url, client.sha1, clientPath);
|
||||
}
|
||||
Inceptum.LOGGER.info(serverPath.toString());
|
||||
Inceptum.LOGGER.info(Boolean.toString(Files.exists(serverPath)));
|
||||
if (!Files.exists(serverPath)) {
|
||||
MojangFileDownload client = info.version().downloads.server;
|
||||
info.setState("Downloading Server");
|
||||
Utils.downloadFile(client.url, client.sha1, serverPath);
|
||||
MojangFileDownload server = info.version().downloads.server;
|
||||
if (new ComparableVersion(minecraftVersion).compareTo("1.18") >= 0) {
|
||||
info.setState("Downloading Bundler");
|
||||
Path p = Files.createTempFile("bundler", ".jar");
|
||||
Utils.downloadFile(server.url, server.sha1, p);
|
||||
try (FileSystem fs = Utils.openZipFile(p, false)) {
|
||||
Files.copy(fs.getPath("META-INF", "versions", minecraftVersion, "server-" + minecraftVersion + ".jar"),
|
||||
serverPath);
|
||||
} catch (URISyntaxException e) {
|
||||
Files.delete(p);
|
||||
throw new IOException("Could not open bundler zip", e);
|
||||
}
|
||||
Files.delete(p);
|
||||
}
|
||||
else {
|
||||
info.setState("Downloading Server");
|
||||
Utils.downloadFile(server.url, server.sha1, serverPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,10 @@ public class SetupDirsStep implements Step {
|
|||
if (!Files.exists(iDir.resolve("config")))
|
||||
Files.createDirectories(iDir.resolve("config"));
|
||||
}
|
||||
Path eulaTxt = iDir.resolve("eula.txt");
|
||||
if (!Files.exists(eulaTxt)) {
|
||||
Files.writeString(eulaTxt, "eula=true");
|
||||
}
|
||||
Files.createDirectories(Inceptum.NATIVES_DIR.resolve(InstanceMeta.getMinecraftVersion(info.version().id)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,10 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public int compareTo(String version) {
|
||||
return compareTo(new ComparableVersion(version));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return string.hashCode();
|
||||
|
@ -43,6 +47,9 @@ public class ComparableVersion implements Comparable<ComparableVersion> {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof ComparableVersion cv && compareTo(cv) == 0;
|
||||
if (obj instanceof ComparableVersion cv && compareTo(cv) == 0
|
||||
|| obj instanceof String str && compareTo(str) == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue