clean up a few things
This commit is contained in:
parent
7dc23b1279
commit
0234a3b49a
|
@ -21,7 +21,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.ecorous.esnesnon:nonsense-remapper:1.0.0-SNAPSHOT")
|
||||
implementation("org.ecorous.esnesnon:thyroxine:1.0.0-SNAPSHOT")
|
||||
implementation("org.ow2.asm:asm:9.7")
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
implementation("org.vineflower:vineflower:1.10.1")
|
||||
|
|
|
@ -27,10 +27,7 @@ import java.nio.file.FileSystems
|
|||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.StandardCopyOption
|
||||
import kotlin.io.path.appendText
|
||||
import kotlin.io.path.createDirectories
|
||||
import kotlin.io.path.deleteExisting
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.io.path.*
|
||||
|
||||
|
||||
class PhytotelmaPlugin : Plugin<Project> {
|
||||
|
@ -73,7 +70,12 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
doFirst {
|
||||
val fileName = remappedGameJarPath.fileName.toString()
|
||||
val output =
|
||||
remappedGameJarPath.resolveSibling(fileName.substring(0, fileName.lastIndexOf("-")) + "-sources.jar")
|
||||
remappedGameJarPath.resolveSibling(
|
||||
fileName.substring(
|
||||
0,
|
||||
fileName.lastIndexOf("-")
|
||||
) + "-sources.jar"
|
||||
)
|
||||
if (output.exists()) {
|
||||
println("Output $output already exists, deleting!")
|
||||
output.deleteExisting()
|
||||
|
@ -145,25 +147,26 @@ class PhytotelmaPlugin : Plugin<Project> {
|
|||
FileSystems.newFileSystem(outFile).use { fs ->
|
||||
if (includeConfiguration.isPresent) {
|
||||
val jijPath = fs.getPath("META-INF/jars")
|
||||
val files =
|
||||
listOf(Nester.run(includeConfiguration.get(), jijPath).map { it.toml() }.toList())
|
||||
val files = Nester.run(includeConfiguration.get(), jijPath).map { it.toml() }.toList()
|
||||
if (files.isNotEmpty()) {
|
||||
val manifest = fs.getPath("frog.mod.toml")
|
||||
val config: CommentedConfig =
|
||||
TomlParser().parse(manifest, FileNotFoundAction.THROW_ERROR)
|
||||
if (!config.add("frog.extensions.included_jars", files)) {
|
||||
if (!config.add("frog.extensions.included_jars", listOf(files))) {
|
||||
println("Failed to add included jars to mod manifest, make sure it doesn't include a key at 'frog.extensions.included_jars'!")
|
||||
}
|
||||
TomlWriter().write(config, manifest, WritingMode.REPLACE)
|
||||
}
|
||||
}
|
||||
fs.getPath("META-INF/MANIFEST.MF").appendText(
|
||||
"""
|
||||
val manifest = fs.getPath("META-INF/MANIFEST.MF")
|
||||
val lines = manifest.readLines().filter { it.isNotBlank() }
|
||||
.plus("""
|
||||
Built-By: Phytotelma ${this.javaClass.`package`.implementationVersion}
|
||||
Target-Namespace: Mojmap
|
||||
Built-For: Minecraft $minecraftVersion
|
||||
""".trimIndent(), StandardCharsets.UTF_8
|
||||
)
|
||||
""".trimIndent()
|
||||
)
|
||||
manifest.writeLines(lines, StandardCharsets.UTF_8)
|
||||
}
|
||||
println("Built mod to ${outFile.toUri()}")
|
||||
}
|
||||
|
|
|
@ -154,11 +154,11 @@ object AccessWidener {
|
|||
}
|
||||
}
|
||||
println(
|
||||
"Applied AccessWideners in ${
|
||||
"Applied AccessWideners (${
|
||||
"%.2fs".format(
|
||||
(System.currentTimeMillis() - startTime) / 1000f
|
||||
)
|
||||
}"
|
||||
})"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.ecorous.esnesnon.gradle.PhytotelmaPlugin
|
|||
import org.ecorous.esnesnon.gradle.VersionChecker
|
||||
import org.ecorous.esnesnon.gradle.accesswidener.AccessWidener
|
||||
import org.ecorous.esnesnon.gradle.run.RunConfigGenerator
|
||||
import org.ecorous.esnesnon.nonsense_remapper.NonsenseRemapper
|
||||
import org.ecorous.esnesnon.nonsense_remapper.Thyroxine
|
||||
import org.ecorous.esnesnon.nonsense_remapper.parser.ProguardParser
|
||||
import org.ecorous.esnesnon.nonsense_remapper.provider.MojmapProvider
|
||||
import org.ecorous.esnesnon.nonsense_remapper.provider.ParchmentProvider
|
||||
|
@ -13,18 +13,15 @@ import kotlin.io.path.notExists
|
|||
|
||||
fun Project.minecraft(
|
||||
version: String,
|
||||
parchmentVersion: String = ParchmentProvider.findForMinecraftVersion(version)
|
||||
parchmentVersion: String? = null
|
||||
): Project { // return self to allow for chaining
|
||||
if (VersionChecker.validateVersion(version)) {
|
||||
println("Setting up Minecraft...")
|
||||
val parchment = parchmentVersion?:ParchmentProvider.findForMinecraftVersion(version)
|
||||
PhytotelmaPlugin.minecraftVersion = version
|
||||
PhytotelmaPlugin.parchmentVersion = parchmentVersion
|
||||
PhytotelmaPlugin.parchmentVersion = parchment
|
||||
println("Valid version! $version")
|
||||
val clientData = VersionChecker.fetchClientDownload(version)
|
||||
println("Client data: ${clientData.url}")
|
||||
// download client data
|
||||
println("Downloading client...")
|
||||
val clientJar = VersionChecker.downloadClient(version)
|
||||
println("Downloaded client!")
|
||||
val remappedJar = clientJar.resolveSibling("client-$version-remapped.jar")
|
||||
PhytotelmaPlugin.remappedGameJarPath = remappedJar
|
||||
println("Time to setup Minecraft!")
|
||||
|
@ -33,10 +30,10 @@ fun Project.minecraft(
|
|||
println("Remapping the game...")
|
||||
val data = ProguardParser.read(MojmapProvider.get(version, clientJar.resolveSibling("client-$version.txt")).orElseThrow()).reverse()
|
||||
val paramMappings = ParchmentProvider.getParchment(
|
||||
version, parchmentVersion,
|
||||
PhytotelmaPlugin.nonsenseCacheDir.resolve("org/parchmentmc/parchment/$version/$parchmentVersion")
|
||||
version, parchment,
|
||||
PhytotelmaPlugin.nonsenseCacheDir.resolve("org/parchmentmc/parchment/$version/$parchment")
|
||||
)
|
||||
NonsenseRemapper.remap(data, clientJar, remappedJar, true, paramMappings)
|
||||
Thyroxine.remap(data, clientJar, remappedJar, true, paramMappings)
|
||||
}
|
||||
println("Adding dependencies...")
|
||||
dependencies.add("implementation","net.minecrell:terminalconsoleappender:1.2.0")
|
||||
|
@ -50,7 +47,7 @@ fun Project.minecraft(
|
|||
|
||||
if (applyAW) {
|
||||
project.afterEvaluate {
|
||||
println("Applying accesswideners")
|
||||
println("Applying AccessWideners..")
|
||||
AccessWidener.apply(this, remappedJar)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue