Skip to content

Commit

Permalink
1.20 several fix
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Jul 27, 2021
1 parent 548f361 commit 6f809df
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'io.izzel.arclight'
version '1.19'
version '1.20'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,36 @@ class ArclightGradlePlugin implements Plugin<Project> {
project.configurations.implementation.extendsFrom(conf)
def buildTools = project.file("${arclightExt.sharedSpigot ? project.rootProject.buildDir : project.buildDir}/arclight_cache/buildtools")
def buildToolsFile = new File(buildTools, 'BuildTools.jar')
def downloadSpigot = project.tasks.create('downloadBuildTools', DownloadBuildToolsTask, {
it.output = buildToolsFile
})
downloadSpigot.doFirst {
if (buildToolsFile.exists()) throw new StopExecutionException()
def downloadSpigot
if (project.rootProject.tasks.findByPath('downloadBuildTools')) {
downloadSpigot = project.rootProject.tasks.getByName('downloadBuildTools')
} else {
downloadSpigot = project.rootProject.tasks.create('downloadBuildTools', DownloadBuildToolsTask, {
it.output = buildToolsFile
})
downloadSpigot.doFirst {
if (buildToolsFile.exists()) throw new StopExecutionException()
}
}
def buildSpigot
if (project.rootProject.tasks.findByPath('buildSpigotTask')) {
buildSpigot = project.rootProject.tasks.getByName('buildSpigotTask')
} else {
buildSpigot = project.rootProject.tasks.create('buildSpigotTask', BuildSpigotTask, project)
project.afterEvaluate {
buildSpigot.doFirst {
if (new File(buildTools, "spigot-${arclightExt.mcVersion}.jar").exists()) {
throw new StopExecutionException()
}
}
buildSpigot.configure { BuildSpigotTask task ->
task.buildTools = buildToolsFile
task.outputDir = buildTools
task.mcVersion = arclightExt.mcVersion
task.dependsOn(downloadSpigot)
}
}
}
def buildSpigot = project.tasks.create('buildSpigotTask', BuildSpigotTask, project)
def processMapping = project.tasks.create('processMapping', ProcessMappingV2Task)
def remapSpigot = project.tasks.create('remapSpigotJar', RemapSpigotTask)
def generateMeta = project.tasks.create('generateArclightMeta', Copy)
Expand All @@ -57,17 +80,6 @@ class ArclightGradlePlugin implements Plugin<Project> {
task.dependsOn(remapSpigot)
}
project.afterEvaluate {
buildSpigot.doFirst {
if (new File(buildTools, "spigot-${arclightExt.mcVersion}.jar").exists()) {
throw new StopExecutionException()
}
}
buildSpigot.configure { BuildSpigotTask task ->
task.buildTools = buildToolsFile
task.outputDir = buildTools
task.mcVersion = arclightExt.mcVersion
task.dependsOn(downloadSpigot)
}
def extractSrg = project.tasks.getByName('extractSrg') as ExtractMCPData
def createSrgToMcp = project.tasks.getByName('createSrgToMcp') as GenerateSRG
processMapping.configure { ProcessMappingV2Task task ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ProcessMappingV2Task extends DefaultTask {
private static final def PKG = [
'it', 'org/apache', 'jline', 'org/codehaus', 'org/eclipse'
]
private static final Map<String, String> KNOWN_WRONG_MAP = ['m_7870_': 'startDrownedConversion']

private File buildData
private File inSrg
Expand Down Expand Up @@ -63,8 +64,15 @@ class ProcessMappingV2Task extends DefaultTask {
}
def srgRev = srg.reverse()
def finalMap = srgRev.merge(csrg).reverse()
Map<String, String> seenNames = [:]
finalMap.topLevelClassMappings.each {
it.methodMappings.each { m ->
if (!it.fullObfuscatedName.contains('/')) {
return
}
it.methodMappings.each { MethodMapping m ->
if (!m.hasDeobfuscatedName()) {
return
}
def s = m.deobfuscatedName
if (!s.startsWith('m_')) {
def c = srgRev.getTopLevelClassMapping(m.parent.deobfuscatedName).get()
Expand All @@ -79,10 +87,28 @@ class ProcessMappingV2Task extends DefaultTask {
println('No mapping found for ' + m)
}
}
} else {
def old = seenNames[m.deobfuscatedName]
if (old) {
if ((old.length() > 2 || m.obfuscatedName.length() > 2) && old != m.obfuscatedName) {
if (old.length() > 2 && m.obfuscatedName.length() > 2) {
if (KNOWN_WRONG_MAP[m.deobfuscatedName] != m.obfuscatedName) {
println("Duplicate [$old, ${m.obfuscatedName}] -> ${m.deobfuscatedName} in ${m.parent.fullDeobfuscatedName}")
}
} else {
seenNames[m.deobfuscatedName] = m.obfuscatedName.length() > old.length() ? m.obfuscatedName : old
}
}
} else {
seenNames[m.deobfuscatedName] = m.obfuscatedName
}
}
}
}
new File(outDir, 'bukkit_srg.srg').withWriter {
PKG.each { pkg ->
it.writeLine("PK: org/bukkit/craftbukkit/libs/$pkg $pkg")
}
new TSrgWriter(it) {
def remapper = new Remapper() {
@Override
Expand All @@ -106,7 +132,8 @@ class ProcessMappingV2Task extends DefaultTask {
@Override
protected void writeMethodMapping(MethodMapping mapping) {
this.writer.println(String.format("\t%s %s %s",
mapping.getObfuscatedName(), remapper.mapMethodDesc(mapping.getObfuscatedDescriptor()),
seenNames.getOrDefault(mapping.getDeobfuscatedName(), mapping.getObfuscatedName()),
remapper.mapMethodDesc(mapping.getObfuscatedDescriptor()),
mapping.getDeobfuscatedName()))
}
}.write(finalMap)
Expand Down

0 comments on commit 6f809df

Please sign in to comment.