applyCraftBukkit now works

This commit is contained in:
Mariell Hoversholm 2021-03-27 23:45:02 +01:00
parent 5c07640131
commit bbe536e51b
No known key found for this signature in database
GPG key ID: 7E8663CA3C537F64
6 changed files with 16 additions and 11 deletions

View file

@ -74,7 +74,7 @@ dependencies {
shade("org.cadixdev:lorenz-io-proguard:$lorenzVersion")
shade("org.cadixdev:atlas:0.2.0")
shade("org.cadixdev:at:0.1.0-rc1")
shade("org.cadixdev:mercury:0.1.0-rc2-PW-SNAPSHOT")
shade("org.cadixdev:mercury:0.1.0-rc2-SNAPSHOT")
shade("net.fabricmc:lorenz-tiny:3.0.0")

View file

@ -323,7 +323,7 @@ class Paperweight : Plugin<Project> {
val filterVanillaJar by tasks.registering<FilterJar> {
inputJar.set(downloadServerJar.flatMap { it.outputJar })
includes.set(listOf("/*.class", "/net/minecraft/**"))
includes.set(listOf("/*.class", "/net/minecraft/**", "/com/mojang/math/**"))
}
return GeneralTasks(buildDataInfo, downloadServerJar, filterVanillaJar)
@ -443,7 +443,7 @@ class Paperweight : Plugin<Project> {
val patchCraftBukkit by tasks.registering<ApplyDiffPatches> {
sourceJar.set(spigotDecompileJar.flatMap { it.outputJar })
sourceBasePath.set("net/minecraft/server")
sourceBasePath.set(".")
branch.set("patched")
patchDir.set(extension.craftBukkit.patchDir)

View file

@ -22,6 +22,7 @@
package io.papermc.paperweight.ext
import java.io.File
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.ProjectLayout
import org.gradle.api.file.RegularFileProperty
@ -35,3 +36,6 @@ fun ObjectFactory.dirFrom(base: DirectoryProperty, name: String): DirectoryPrope
fun ObjectFactory.fileFrom(base: DirectoryProperty, name: String): RegularFileProperty =
fileProperty().convention(base.file(name))
fun File.listFilesRecursively(): Set<File>? =
listFiles()?.flatMapTo(mutableSetOf()) { setOf(it) + (it.listFilesRecursively() ?: emptySet()) }

View file

@ -23,6 +23,7 @@
package io.papermc.paperweight.tasks
import io.papermc.paperweight.PaperweightException
import io.papermc.paperweight.ext.listFilesRecursively
import io.papermc.paperweight.util.Command
import io.papermc.paperweight.util.Git
import io.papermc.paperweight.util.UselessOutputStream
@ -68,9 +69,9 @@ abstract class ApplyDiffPatches : ControllableOutputTask() {
val outputDirFile = basePatchDirFile.resolve(sourceBasePath.get())
outputDirFile.deleteRecursively()
val patchList = patchDir.file.listFiles() ?: throw PaperweightException(
"Patch directory does not exist ${patchDir.file}"
)
val patchList = patchDir.file.listFilesRecursively()
?.filter { it.isFile }
?: throw PaperweightException("Patch directory does not exist ${patchDir.file}")
if (patchList.isEmpty()) {
throw PaperweightException("No patch files found in ${patchDir.file}")
}
@ -79,7 +80,7 @@ abstract class ApplyDiffPatches : ControllableOutputTask() {
val uri = URI.create("jar:" + sourceJar.file.toURI())
FileSystems.newFileSystem(uri, mapOf<String, Any>()).use { fs ->
for (file in patchList) {
val javaName = file.name.replaceAfterLast('.', "java")
val javaName = file.toRelativeString(patchDir.file).replaceAfterLast('.', "java")
val out = outputDirFile.resolve(javaName)
val sourcePath = fs.getPath(sourceBasePath.get(), javaName)
@ -97,7 +98,7 @@ abstract class ApplyDiffPatches : ControllableOutputTask() {
// Apply patches
for (file in patchList) {
val javaName = file.name.replaceAfterLast('.', "java")
val javaName = file.toRelativeString(patchDir.file).replaceAfterLast('.', "java")
if (printOutput.get()) {
println("Patching ${javaName.removeSuffix(".java")}")

View file

@ -77,7 +77,7 @@ abstract class GenerateMappings : DefaultTask() {
fun run() {
val vanillaMappings = MappingFormats.PROGUARD.createReader(vanillaMappings.path).use { it.read() }.reverse()
val paramMappings = FileSystems.newFileSystem(paramMappings.path, null).use { fs ->
val paramMappings = FileSystems.newFileSystem(paramMappings.path, null as ClassLoader?).use { fs ->
val path = fs.getPath("mappings", "mappings.tiny")
MappingFormats.TINY.read(path, "official", "named")
}

View file

@ -92,8 +92,8 @@ abstract class RemapJarAtlas : BaseTask() {
override fun execute() {
val mappings = MappingFormats.TINY.read(parameters.mappingsFile.path, parameters.fromNamespace.get(), parameters.toNamespace.get())
val oldPack = "net/minecraft/server"
val newPack = "$oldPack/v${parameters.packageVersion.get()}"
val oldPack = "net/minecraft"
val newPack = "$oldPack/server/v${parameters.packageVersion.get()}"
Atlas().let { atlas ->
atlas.install { ctx -> JarEntryRemappingTransformer(LorenzRemapper(mappings, ctx.inheritanceProvider())) }
atlas.install { JarEntryRemappingTransformer(PackageRemapper(oldPack, newPack)) }