-
Notifications
You must be signed in to change notification settings - Fork 0
/
specialSource.gradle
73 lines (65 loc) · 3.39 KB
/
specialSource.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// From : https://github.com/MrTransistorsChannel/AFK/blob/79e1ab20f3c1dad29242dca289122559f84bf8a0/specialSource.gradle
buildscript {
repositories {
mavenCentral()
}
configurations.create('specialSource')
dependencies {
specialSource 'net.md-5:SpecialSource:1.11.0:shaded'
}
}
// Spigot server code remapping: https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/
// These dependencies and mappings are installed into the local Maven repository when BuildTools builds the Spigot dependencies.
def m2Repo = new File(repositories.mavenLocal().url.path)
def remappedMojang = new File(m2Repo, 'org/spigotmc/spigot/{spigotVersion}/spigot-{spigotVersion}-remapped-mojang.jar').path
def remappedObf = new File(m2Repo, 'org/spigotmc/spigot/{spigotVersion}/spigot-{spigotVersion}-remapped-obf.jar').path
def mojangMappings = new File(m2Repo, 'org/spigotmc/minecraft-server/{spigotVersion}/minecraft-server-{spigotVersion}-maps-mojang.txt').path
def spigotMappings = new File(m2Repo, 'org/spigotmc/minecraft-server/{spigotVersion}/minecraft-server-{spigotVersion}-maps-spigot.csrg').path
def specialSource = buildscript.configurations.specialSource.resolvedConfiguration.getFirstLevelModuleDependencies {
it.group == 'net.md-5' && it.name == 'SpecialSource'
}.first().moduleArtifacts.first().file.path
// Converts from Mojang's mappings to Minecraft's obfuscated mappings.
ext.remapMojangToObfuscated = { inputFile, outputFile, spigotVersion ->
println '> remapMojangToObfuscated'
println ' Input: ' + inputFile.path
println ' Output: ' + outputFile.path
println ' Spigot version: ' + spigotVersion
def classpathSeparator = System.properties['path.separator']
exec {
commandLine 'java',
'-cp', "${specialSource}${classpathSeparator}${remappedMojang}".replace('{spigotVersion}', spigotVersion),
'net.md_5.specialsource.SpecialSource',
'--live',
'-i', inputFile.path,
'-o', outputFile.path,
'-m', mojangMappings.replace('{spigotVersion}', spigotVersion),
'--reverse'
}
}
// Converts from Minecraft's obfuscated mappings to Spigot's mappings.
ext.remapObfuscatedToSpigot = { inputFile, outputFile, spigotVersion ->
println '> remapObfuscatedToSpigot'
println ' Input: ' + inputFile.path
println ' Output: ' + outputFile.path
println ' Spigot version: ' + spigotVersion
def classpathSeparator = System.properties['path.separator']
exec {
commandLine 'java',
'-cp', "${specialSource}${classpathSeparator}${remappedObf}".replace('{spigotVersion}', spigotVersion),
'net.md_5.specialsource.SpecialSource',
'--live',
'-i', inputFile.path,
'-o', outputFile.path,
'-m', spigotMappings.replace('{spigotVersion}', spigotVersion)
}
}
// Converts from Mojang's mappings to Spigot's mappings.
ext.remapMojangToSpigot = { inputFile, intermediateFile, outputFile, spigotVersion ->
println '> remapMojangToSpigot'
println ' Input: ' + inputFile.path
println ' Intermediate: ' + intermediateFile.path
println ' Output: ' + outputFile.path
println ' Spigot version: ' + spigotVersion
remapMojangToObfuscated(inputFile, intermediateFile, spigotVersion)
remapObfuscatedToSpigot(intermediateFile, outputFile, spigotVersion)
}