Skip to content

Commit 6440805

Browse files
committed
reformat all
1 parent 2caf7f3 commit 6440805

File tree

60 files changed

+597
-452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+597
-452
lines changed

README.en.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ fixes some bugs of RTM and make RTM more useful!
1313

1414
- [RTM](https://www.curseforge.com/minecraft/mc-mods/realtrainmod) the newest version when a release of fixRTM
1515
- [NGT Lib](https://www.curseforge.com/minecraft/mc-mods/ngtlib) (dependencies of RTM)
16-
- [Minecraft Forge](https://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.12.2.html) 14.23.5.2847 or later is supported.
16+
- [Minecraft Forge](https://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.12.2.html) 14.23.5.2847 or
17+
later is supported.
1718

1819
[here](version-map.md) is a version mapping between fixRTM and RTM

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ RTMのバグを減らし、使いやすくする!
1818

1919
- [RTM](https://www.curseforge.com/minecraft/mc-mods/realtrainmod) fixRTMのリリース時の最新バージョン
2020
- [NGT Lib](https://www.curseforge.com/minecraft/mc-mods/ngtlib) (RTMの前提mod)
21-
- [Minecraft Forge](https://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.12.2.html) 14.23.5.2847以降がサポートバージョンです。
21+
- [Minecraft Forge](https://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.12.2.html)
22+
14.23.5.2847以降がサポートバージョンです。
2223

2324
対応表は[こちら](version-map.md)

build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ minecraft {
5757
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
5858
}
5959

60-
configurations{
60+
configurations {
6161
shade
6262
compile.extendsFrom shade
6363
}
@@ -69,7 +69,7 @@ repositories {
6969
dependencies {
7070
shade "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
7171
shade group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '1.1.0'
72-
shade ("io.sigpipe:jbsdiff:1.0") {
72+
shade("io.sigpipe:jbsdiff:1.0") {
7373
exclude group: "org.apache.commons", module: "commons-compress"
7474
}
7575
shade "com.anatawa12.sai:sai:0.0.2"
@@ -126,15 +126,15 @@ runClient {
126126
}
127127

128128
jar {
129-
configurations.shade.each {dep ->
130-
from(project.zipTree(dep)){
129+
configurations.shade.each { dep ->
130+
from(project.zipTree(dep)) {
131131
exclude 'META-INF', 'META-INF/**'
132132
exclude 'LICENSE.txt'
133133
}
134134
}
135135

136136
manifest {
137-
attributes("FMLCorePlugin" : "com.anatawa12.fixRtm.asm.FixRtmCorePlugin",
137+
attributes("FMLCorePlugin": "com.anatawa12.fixRtm.asm.FixRtmCorePlugin",
138138
"FMLCorePluginContainsFMLMod": "*",
139139
'FMLAT': 'fix-rtm_at.cfg',
140140
)
@@ -144,6 +144,7 @@ jar {
144144
def compileJasmOutput = compileJasm.dir
145145

146146
import com.anatawa12.javaStabGen.gradle.GenerateJavaStab
147+
147148
task generateJavaStab(type: GenerateJavaStab) {
148149
generatedDir = file("$buildDir/generated/stab")
149150
classpath = files(compileJasmOutput)

buildSrc/src/main/kotlin/CheckClassesSame.kt

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ import java.util.zip.ZipFile
1313

1414
open class CheckClassesSame : DefaultTask() {
1515
private val logger = LoggerFactory.getLogger("CheckClassesSame")
16-
@InputFile var src: File? = null
17-
@InputFile var dst: File? = null
18-
@Input var rootPackage: String? = null
16+
@InputFile
17+
var src: File? = null
18+
@InputFile
19+
var dst: File? = null
20+
@Input
21+
var rootPackage: String? = null
1922

2023
private val differences = mutableSetOf<Difference>()
2124

@@ -33,8 +36,8 @@ open class CheckClassesSame : DefaultTask() {
3336
val srcClasses = mutableSetOf<String>()
3437

3538
srcZip.entries().asSequence().forEach { srcEntry ->
36-
if(!srcEntry.name.endsWith(".class")) return@forEach
37-
if(!srcEntry.name.startsWith(rootPackagePath)) return@forEach
39+
if (!srcEntry.name.endsWith(".class")) return@forEach
40+
if (!srcEntry.name.startsWith(rootPackagePath)) return@forEach
3841
srcClasses.add(srcEntry.name)
3942
val dstEntry = dstZip.getEntry(srcEntry.name)
4043
if (dstEntry == null) return@forEach addDiff(Difference.ClassOnlyInSrc(srcEntry.name.removeSuffix(".class")))
@@ -45,8 +48,8 @@ open class CheckClassesSame : DefaultTask() {
4548
}
4649

4750
srcZip.entries().asSequence().forEach { dstEntry ->
48-
if(!dstEntry.name.endsWith(".class")) return@forEach
49-
if(!dstEntry.name.startsWith(rootPackagePath)) return@forEach
51+
if (!dstEntry.name.endsWith(".class")) return@forEach
52+
if (!dstEntry.name.startsWith(rootPackagePath)) return@forEach
5053
if (dstEntry.name !in srcClasses)
5154
addDiff(Difference.ClassOnlyInDst(dstEntry.name.removeSuffix(".class")))
5255
}
@@ -140,67 +143,81 @@ open class CheckClassesSame : DefaultTask() {
140143
if (srcInsn.opcode != dstInsn.opcode) return false
141144
if (srcInsn.javaClass != dstInsn.javaClass) return false
142145
when (srcInsn) {
143-
is FieldInsnNode -> { dstInsn as FieldInsnNode
146+
is FieldInsnNode -> {
147+
dstInsn as FieldInsnNode
144148
if (srcInsn.owner != dstInsn.owner) return false
145149
if (srcInsn.name != dstInsn.name) return false
146150
if (srcInsn.desc != dstInsn.desc) return false
147151
}
148-
is IincInsnNode -> { dstInsn as IincInsnNode
152+
is IincInsnNode -> {
153+
dstInsn as IincInsnNode
149154
if (srcInsn.`var` != dstInsn.`var`) return false
150155
if (srcInsn.incr != dstInsn.incr) return false
151156
}
152-
is InsnNode -> { dstInsn as InsnNode
157+
is InsnNode -> {
158+
dstInsn as InsnNode
153159
}
154-
is IntInsnNode -> { dstInsn as IntInsnNode
160+
is IntInsnNode -> {
161+
dstInsn as IntInsnNode
155162
if (srcInsn.operand != dstInsn.operand) return false
156163
}
157-
is InvokeDynamicInsnNode -> { dstInsn as InvokeDynamicInsnNode
164+
is InvokeDynamicInsnNode -> {
165+
dstInsn as InvokeDynamicInsnNode
158166
if (srcInsn.name != dstInsn.name) return false
159167
if (srcInsn.desc != dstInsn.desc) return false
160168
if (srcInsn.bsm != dstInsn.bsm) return false
161169
if (!srcInsn.bsmArgs.contentEquals(dstInsn.bsmArgs)) return false
162170
}
163-
is JumpInsnNode -> { dstInsn as JumpInsnNode
171+
is JumpInsnNode -> {
172+
dstInsn as JumpInsnNode
164173
//if (srcInsn.label != dstInsn.label) return false
165174
}
166-
is LdcInsnNode -> { dstInsn as LdcInsnNode
175+
is LdcInsnNode -> {
176+
dstInsn as LdcInsnNode
167177
if (srcInsn.cst != dstInsn.cst) return false
168178
}
169-
is LookupSwitchInsnNode -> { dstInsn as LookupSwitchInsnNode
179+
is LookupSwitchInsnNode -> {
180+
dstInsn as LookupSwitchInsnNode
170181
//if (srcInsn.dflt != dstInsn.dflt) return false
171182
if (srcInsn.keys != dstInsn.keys) return false
172183
//if (srcInsn.labels != dstInsn.labels) return false
173184
}
174-
is MethodInsnNode -> { dstInsn as MethodInsnNode
185+
is MethodInsnNode -> {
186+
dstInsn as MethodInsnNode
175187
if (srcInsn.owner != dstInsn.owner) return false
176188
if (srcInsn.name != dstInsn.name) return false
177189
if (srcInsn.desc != dstInsn.desc) return false
178190
if (srcInsn.itf != dstInsn.itf) return false
179191
}
180-
is MultiANewArrayInsnNode -> { dstInsn as MultiANewArrayInsnNode
192+
is MultiANewArrayInsnNode -> {
193+
dstInsn as MultiANewArrayInsnNode
181194
if (srcInsn.desc != dstInsn.desc) return false
182195
if (srcInsn.dims != dstInsn.dims) return false
183196
}
184-
is TableSwitchInsnNode -> { dstInsn as TableSwitchInsnNode
197+
is TableSwitchInsnNode -> {
198+
dstInsn as TableSwitchInsnNode
185199
if (srcInsn.min != dstInsn.min) return false
186200
if (srcInsn.max != dstInsn.max) return false
187201
//if (srcInsn.dflt != dstInsn.dflt) return false
188202
//if (srcInsn.labels != dstInsn.labels) return false
189203
}
190-
is TypeInsnNode -> { dstInsn as TypeInsnNode
204+
is TypeInsnNode -> {
205+
dstInsn as TypeInsnNode
191206
if (srcInsn.desc != dstInsn.desc) return false
192207
}
193-
is VarInsnNode -> { dstInsn as VarInsnNode
208+
is VarInsnNode -> {
209+
dstInsn as VarInsnNode
194210
if (srcInsn.`var` != dstInsn.`var`) return false
195211
}
196212
else -> error("Not yet implemented: ${srcInsn.javaClass.simpleName}")
197213
}
198214
return true
199215
}
200216

201-
private fun readClass(byteArray: ByteArray): ClassNode
202-
= ClassNode().apply { ClassReader(byteArray)
203-
.accept(this, ClassReader.SKIP_DEBUG + ClassReader.SKIP_FRAMES) }
217+
private fun readClass(byteArray: ByteArray): ClassNode = ClassNode().apply {
218+
ClassReader(byteArray)
219+
.accept(this, ClassReader.SKIP_DEBUG + ClassReader.SKIP_FRAMES)
220+
}
204221

205222
private fun <K, V> Map<K, V>.zipNullable(other: Map<K, V>): Map<K, Pair<V?, V?>> {
206223
val result = mutableMapOf<K, Pair<V?, V?>>()
@@ -225,12 +242,33 @@ open class CheckClassesSame : DefaultTask() {
225242
data class MethodOnlyInSrc(val owner: String, val name: String, val desc: String) : Difference()
226243
data class MethodOnlyInDst(val owner: String, val name: String, val desc: String) : Difference()
227244
data class ClassSignatureChanged(val className: String, val src: String?, val dst: String?) : Difference()
228-
data class FieldSignatureChanged(val owner: String, val name: String, val desc: String, val src: String?, val dst: String?) : Difference()
229-
data class MethodSignatureChanged(val owner: String, val name: String, val desc: String, val src: String?, val dst: String?) : Difference()
245+
data class FieldSignatureChanged(
246+
val owner: String,
247+
val name: String,
248+
val desc: String,
249+
val src: String?,
250+
val dst: String?
251+
) : Difference()
252+
253+
data class MethodSignatureChanged(
254+
val owner: String,
255+
val name: String,
256+
val desc: String,
257+
val src: String?,
258+
val dst: String?
259+
) : Difference()
260+
230261
data class FieldAccessChanged(val owner: String, val name: String, val desc: String) : Difference()
231262
data class MethodAccessChanged(val owner: String, val name: String, val desc: String) : Difference()
232263
data class FieldValueChanged(val owner: String, val name: String, val desc: String) : Difference()
233-
data class MethodCodeChanged(val owner: String, val name: String, val desc: String, val source: List<AbstractInsnNode>, val patch: Patch<AbstractInsnNode>) : Difference()
264+
data class MethodCodeChanged(
265+
val owner: String,
266+
val name: String,
267+
val desc: String,
268+
val source: List<AbstractInsnNode>,
269+
val patch: Patch<AbstractInsnNode>
270+
) : Difference()
271+
234272
data class AnnotationDefaultChanged(val owner: String, val name: String, val desc: String) : Difference()
235273
}
236274
}

buildSrc/src/main/kotlin/DeObfuscateJar.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import java.io.File
88
open class DeObfuscateJar : DefaultTask() {
99
@InputFile
1010
var srgFile: File? = null
11+
1112
@InputFile
1213
var obfuscatedJar: File? = null
14+
1315
@OutputFile
1416
var deObfuscatedJar: File? = null
1517

buildSrc/src/main/kotlin/DownloadModJar.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import kotlin.properties.Delegates
1111
open class DownloadModJar : DefaultTask() {
1212
var projectId: Int by Delegates.notNull()
1313

14-
@OutputFile lateinit var to: File
15-
@Input lateinit var version: String
14+
@OutputFile
15+
lateinit var to: File
16+
@Input
17+
lateinit var version: String
1618

1719
@TaskAction
1820
fun download() {
@@ -24,10 +26,10 @@ open class DownloadModJar : DefaultTask() {
2426
error("project#$projectId files not found")
2527

2628
val file = files.get()
27-
.filterNot { "1.12.2" !in it.gameVersionStrings() }
28-
.filter { version in it.displayName() }
29-
.singleOrNull()
30-
?: error("project#$projectId version $version not found or found two or more")
29+
.filterNot { "1.12.2" !in it.gameVersionStrings() }
30+
.filter { version in it.displayName() }
31+
.singleOrNull()
32+
?: error("project#$projectId version $version not found or found two or more")
3133

3234
println("file name is: ${file.displayName()}, id: ${file.id()}")
3335

buildSrc/src/main/kotlin/MakeClassBsdiffPatch.kt

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import io.sigpipe.jbsdiff.Diff
22
import org.gradle.api.DefaultTask
33
import org.gradle.api.file.FileTree
4-
import org.gradle.api.provider.Provider
5-
import org.gradle.api.tasks.*
6-
import org.objectweb.asm.ClassReader
7-
import org.objectweb.asm.ClassWriter
4+
import org.gradle.api.tasks.Input
5+
import org.gradle.api.tasks.InputFiles
6+
import org.gradle.api.tasks.OutputDirectory
7+
import org.gradle.api.tasks.TaskAction
88
import java.io.File
99
import java.security.MessageDigest
1010

1111
open class MakeClassBsdiffPatch : DefaultTask() {
12-
@InputFiles var oldFiles: FileTree = project.files().asFileTree
13-
@InputFiles var newFiles: FileTree = project.files().asFileTree
14-
@OutputDirectory var outTo: File? = null
15-
@Input var patchPrefix: String? = null
12+
@InputFiles
13+
var oldFiles: FileTree = project.files().asFileTree
14+
@InputFiles
15+
var newFiles: FileTree = project.files().asFileTree
16+
@OutputDirectory
17+
var outTo: File? = null
18+
@Input
19+
var patchPrefix: String? = null
1620

1721
@TaskAction
1822
fun run() {
@@ -21,8 +25,8 @@ open class MakeClassBsdiffPatch : DefaultTask() {
2125
val outTo = outTo ?: error("outTo not inited")
2226
val patchPrefix = patchPrefix ?: error("patchPrefix not inited")
2327

24-
check ((oldFiles.keys - newFiles.keys).isEmpty()) { "some files are deleted: ${oldFiles.keys - newFiles.keys}" }
25-
check ((newFiles.keys - oldFiles.keys).isEmpty()) { "some files are added: ${newFiles.keys - oldFiles.keys}" }
28+
check((oldFiles.keys - newFiles.keys).isEmpty()) { "some files are deleted: ${oldFiles.keys - newFiles.keys}" }
29+
check((newFiles.keys - oldFiles.keys).isEmpty()) { "some files are added: ${newFiles.keys - oldFiles.keys}" }
2630

2731
val patchDir = outTo.resolve(patchPrefix)
2832
val sha1 = MessageDigest.getInstance("SHA-1")

buildSrc/src/main/kotlin/PrintFieldStructure.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import java.util.function.Predicate
1212
open class PrintFieldStructure : DefaultTask() {
1313
@InputFiles
1414
var files: FileTree = project.files().asFileTree
15+
1516
@OutputDirectory
1617
var outTo: File? = null
1718
var superClass: String? = null
@@ -44,8 +45,8 @@ open class PrintFieldStructure : DefaultTask() {
4445
}
4546

4647
outTo.resolve("${hClass.internalName}.txt")
47-
.apply { parentFile.mkdirs() }
48-
.writeText(file)
48+
.apply { parentFile.mkdirs() }
49+
.writeText(file)
4950
}
5051
}
5152

@@ -64,11 +65,11 @@ open class PrintFieldStructure : DefaultTask() {
6465
yieldAll(childClasses)
6566
if (isLoaded) {
6667
yieldAll(fields.asSequence()
67-
.filter { !it.isStatic }
68-
.filter { it.type[0] == 'L' }
69-
.map { it.type.substring(1, it.type.length - 1) }
70-
.map { loader.getByInternalName(it) }
71-
.toSet())
68+
.filter { !it.isStatic }
69+
.filter { it.type[0] == 'L' }
70+
.map { it.type.substring(1, it.type.length - 1) }
71+
.map { loader.getByInternalName(it) }
72+
.toSet())
7273
}
7374
}
7475

buildSrc/src/main/kotlin/PrintMethodCode.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import java.io.PrintWriter
1212
open class PrintMethodCode : DefaultTask() {
1313
@InputFiles
1414
var files: FileTree = project.files().asFileTree
15+
1516
@OutputFile
1617
var outTo: File? = null
1718
var ofClass: String? = null
@@ -31,7 +32,7 @@ open class PrintMethodCode : DefaultTask() {
3132
throw IllegalStateException("ofClass is not loaded")
3233

3334
val method = theClass.methods.singleOrNull { it.name == methodName && it.desc == methodDesc }
34-
?: throw IllegalStateException("method is not loaded")
35+
?: throw IllegalStateException("method is not loaded")
3536

3637
val node = method.node
3738
val printer = Textifier()

buildSrc/src/main/kotlin/PrintStaticFields.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import java.io.File
99
open class PrintStaticFields : DefaultTask() {
1010
@InputFiles
1111
var files: FileTree = project.files().asFileTree
12+
1213
@OutputFile
1314
var outTo: File? = null
1415
var ofClass: String? = null
@@ -32,6 +33,6 @@ open class PrintStaticFields : DefaultTask() {
3233
}
3334

3435
outTo.apply { parentFile.mkdirs() }
35-
.writeText(file)
36+
.writeText(file)
3637
}
3738
}

0 commit comments

Comments
 (0)