Fix extractServerJar jar task to use the path found in versions.list.

This commit is contained in:
modmuss50 2021-11-11 18:17:23 +00:00
parent 1f0b4b7ebc
commit 50f4f74efa
1 changed files with 18 additions and 4 deletions

View File

@ -258,13 +258,27 @@ task extractServerJar(dependsOn: downloadMcJars) {
doLast {
new ZipFile(serverBootstrapJar as File).withCloseable { zip ->
def entry = zip.getEntry("META-INF/versions/${minecraft_version}/server-${minecraft_version}.jar")
def serverVersionsEntry = zip.getEntry("META-INF/versions.list")
if (!entry) {
throw new RuntimeException("Failed to find server jar entry: ")
if (!serverVersionsEntry) {
throw new RuntimeException("Could not find versions.list")
}
zip.getInputStream(entry).withCloseable { is ->
def jarPath = null
zip.getInputStream(serverVersionsEntry).withCloseable { is ->
def versions = is.text.split("\t")
assert versions.length == 3
jarPath = versions[2]
}
def serverJarEntry = zip.getEntry("META-INF/versions/${jarPath}")
if (!serverJarEntry) {
throw new RuntimeException("Failed to find server jar entry ${jarPath}")
}
zip.getInputStream(serverJarEntry).withCloseable { is ->
serverJar.bytes = is.readAllBytes()
}
}