aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.attach_pid1282750
-rw-r--r--settings.gradle.kts1
-rw-r--r--src/main/kotlin/mcprepack/App.kt25
-rw-r--r--src/main/kotlin/mcprepack/CSVFile.kt8
-rw-r--r--test/build.gradle.kts12
5 files changed, 39 insertions, 7 deletions
diff --git a/.attach_pid128275 b/.attach_pid128275
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.attach_pid128275
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 6452643..c1d8cc6 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -8,3 +8,4 @@
*/
rootProject.name = "mcprepack"
+include("test") \ No newline at end of file
diff --git a/src/main/kotlin/mcprepack/App.kt b/src/main/kotlin/mcprepack/App.kt
index 688716b..1972c62 100644
--- a/src/main/kotlin/mcprepack/App.kt
+++ b/src/main/kotlin/mcprepack/App.kt
@@ -107,21 +107,29 @@ fun main(): Unit = lifecycle("Repacking") {
val fields = readCSV(mcpStableFs.getPath("/fields.csv"))
val methods = readCSV(mcpStableFs.getPath("/methods.csv"))
val tinyFile = TinyV2Reader.read(classesTiny)
+ fun commentOrEmptyList(comment: String?) =
+ if (comment.isNullOrBlank()) listOf()
+ else listOf(comment)
+
val newTiny =
TinyFile(TinyHeader(listOf("official", "intermediary", "named"), 2, 0, mapOf()), tinyFile.classEntries.map {
TinyClass(it.classNames + listOf(it.classNames[1]), it.methods.map { method ->
val mcpMethod = methods.indexedBySearge[method.methodNames[1]]
- TinyMethod(method.methodDescriptorInFirstNamespace,
+ TinyMethod(
+ method.methodDescriptorInFirstNamespace,
method.methodNames + listOf(mcpMethod?.get("name") ?: method.methodNames[1]),
method.parameters,
method.localVariables,
- method.comments + (mcpMethod?.get("desc")?.let { listOf(it) } ?: listOf()))
- // TODO parameter names and better comments?
+ method.comments + commentOrEmptyList(mcpMethod?.get("desc"))
+ )
+ // TODO parameter names
}, it.fields.map { field ->
val mcpField = fields.indexedBySearge[field.fieldNames[1]]
- TinyField(findFieldDescriptorInMergedJar(it.classNames[0], field.fieldNames[0]),
+ TinyField(
+ findFieldDescriptorInMergedJar(it.classNames[0], field.fieldNames[0]),
field.fieldNames + listOf(mcpField?.get("name") ?: field.fieldNames[1]),
- field.comments + (mcpField?.get("desc")?.let { listOf(it) } ?: listOf()))
+ field.comments + commentOrEmptyList(mcpField?.get("desc"))
+ )
}, it.comments.map { it })
})
val newTinyFile = WorkContext.file("tiny-joined-enhanced", "tiny")
@@ -415,9 +423,12 @@ fun main(): Unit = lifecycle("Repacking") {
}
fun readCSV(path: Path): CSVFile {
- // TODO proper "" handling
val lines = Files.readAllLines(path)
val headers = lines.first().split(",")
- val entries = lines.drop(1).map { it.split(",", limit = headers.size) }
+ val entries = lines.drop(1).map {
+ it.split(",", limit = headers.size).map {
+ if (it.firstOrNull() == '"') it.drop(1).dropLast(1).replace("\"\"", "\"") else it
+ }
+ }
return CSVFile(headers, entries)
}
diff --git a/src/main/kotlin/mcprepack/CSVFile.kt b/src/main/kotlin/mcprepack/CSVFile.kt
index 1ddc03f..b2bcfaa 100644
--- a/src/main/kotlin/mcprepack/CSVFile.kt
+++ b/src/main/kotlin/mcprepack/CSVFile.kt
@@ -3,4 +3,12 @@ package mcprepack
data class CSVFile(val headers: List<String>, val entries: List<List<String>>) {
val map = entries.map { headers.zip(it).toMap() }
val indexedBySearge = map.associateBy { it["searge"] }
+ val indexedByParamName = map.groupBy {
+ val match = it["param"]?.let { paramRegex.matchEntire(it) } ?: return@groupBy null
+ match.groupValues[1].toInt()
+ }
+
+ companion object {
+ val paramRegex = "p_([0-9]+)_([0-9]+)_.*".toRegex()
+ }
}
diff --git a/test/build.gradle.kts b/test/build.gradle.kts
new file mode 100644
index 0000000..490253e
--- /dev/null
+++ b/test/build.gradle.kts
@@ -0,0 +1,12 @@
+plugins {
+ `maven-publish`
+}
+
+
+publishing {
+ publications {
+ create<MavenPublication>("yarn") {
+ artifact(file("aaa"))
+ }
+ }
+} \ No newline at end of file