From 77e8b0cdc01c4c2b4cdfa0dc7043a97628dd5ae4 Mon Sep 17 00:00:00 2001 From: Graham Date: Thu, 26 Dec 2019 22:05:17 +0000 Subject: [PATCH] Use top-level Kotlin main() functions --- all/pom.xml | 2 +- all/src/bin/openrs2-decompiler | 2 +- all/src/bin/openrs2-decompiler.cmd | 2 +- all/src/bin/openrs2-deob | 2 +- all/src/bin/openrs2-deob-ast | 2 +- all/src/bin/openrs2-deob-ast.cmd | 2 +- all/src/bin/openrs2-deob.cmd | 2 +- all/src/bin/openrs2-game | 2 +- all/src/bin/openrs2-game.cmd | 2 +- .../java/dev/openrs2/decompiler/Decompiler.kt | 53 +++++++++---------- .../dev/openrs2/deob/ast/AstDeobfuscator.kt | 31 ++++++----- .../java/dev/openrs2/deob/Deobfuscator.kt | 11 ++-- .../main/java/dev/openrs2/game/GameServer.kt | 5 +- 13 files changed, 56 insertions(+), 62 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 051795bd72..dc42224961 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -59,7 +59,7 @@ - dev.openrs2.game.GameServer + dev.openrs2.game.GameServerKt diff --git a/all/src/bin/openrs2-decompiler b/all/src/bin/openrs2-decompiler index b06e58506b..3ec9762ded 100755 --- a/all/src/bin/openrs2-decompiler +++ b/all/src/bin/openrs2-decompiler @@ -1,3 +1,3 @@ #!/bin/sh -e cd `dirname "$0"`/.. -exec java -cp lib/openrs2.jar dev.openrs2.decompiler.Decompiler "$@" +exec java -cp lib/openrs2.jar dev.openrs2.decompiler.DecompilerKt "$@" diff --git a/all/src/bin/openrs2-decompiler.cmd b/all/src/bin/openrs2-decompiler.cmd index 5cc4d3a78a..80ff0303d5 100644 --- a/all/src/bin/openrs2-decompiler.cmd +++ b/all/src/bin/openrs2-decompiler.cmd @@ -1,3 +1,3 @@ @echo off cd /d %~dp0\.. -java -cp lib\openrs2.jar dev.openrs2.decompiler.Decompiler %* +java -cp lib\openrs2.jar dev.openrs2.decompiler.DecompilerKt %* diff --git a/all/src/bin/openrs2-deob b/all/src/bin/openrs2-deob index 04d00c165f..34eadfce5d 100755 --- a/all/src/bin/openrs2-deob +++ b/all/src/bin/openrs2-deob @@ -1,3 +1,3 @@ #!/bin/sh -e cd `dirname "$0"`/.. -exec java -cp lib/openrs2.jar dev.openrs2.deob.Deobfuscator "$@" +exec java -cp lib/openrs2.jar dev.openrs2.deob.DeobfuscatorKt "$@" diff --git a/all/src/bin/openrs2-deob-ast b/all/src/bin/openrs2-deob-ast index a4440c2bd5..e4ca8e9996 100755 --- a/all/src/bin/openrs2-deob-ast +++ b/all/src/bin/openrs2-deob-ast @@ -1,3 +1,3 @@ #!/bin/sh -e cd `dirname "$0"`/.. -exec java -cp lib/openrs2.jar dev.openrs2.deob.ast.AstDeobfuscator "$@" +exec java -cp lib/openrs2.jar dev.openrs2.deob.ast.AstDeobfuscatorKt "$@" diff --git a/all/src/bin/openrs2-deob-ast.cmd b/all/src/bin/openrs2-deob-ast.cmd index 6122db5cc7..19eed260d8 100644 --- a/all/src/bin/openrs2-deob-ast.cmd +++ b/all/src/bin/openrs2-deob-ast.cmd @@ -1,3 +1,3 @@ @echo off cd /d %~dp0\.. -java -cp lib\openrs2.jar dev.openrs2.deob.ast.AstDeobfuscator %* +java -cp lib\openrs2.jar dev.openrs2.deob.ast.AstDeobfuscatorKt %* diff --git a/all/src/bin/openrs2-deob.cmd b/all/src/bin/openrs2-deob.cmd index 38af8ddaff..d4b07b4abb 100644 --- a/all/src/bin/openrs2-deob.cmd +++ b/all/src/bin/openrs2-deob.cmd @@ -1,3 +1,3 @@ @echo off cd /d %~dp0\.. -java -cp lib\openrs2.jar dev.openrs2.deob.Deobfuscator %* +java -cp lib\openrs2.jar dev.openrs2.deob.DeobfuscatorKt %* diff --git a/all/src/bin/openrs2-game b/all/src/bin/openrs2-game index 6854b95a3a..7305adc941 100755 --- a/all/src/bin/openrs2-game +++ b/all/src/bin/openrs2-game @@ -1,3 +1,3 @@ #!/bin/sh -e cd `dirname "$0"`/.. -exec java -cp lib/openrs2.jar dev.openrs2.game.GameServer "$@" +exec java -cp lib/openrs2.jar dev.openrs2.game.GameServerKt "$@" diff --git a/all/src/bin/openrs2-game.cmd b/all/src/bin/openrs2-game.cmd index e0b17aa0fa..c33e74d5e2 100644 --- a/all/src/bin/openrs2-game.cmd +++ b/all/src/bin/openrs2-game.cmd @@ -1,3 +1,3 @@ @echo off cd /d %~dp0\.. -java -cp lib\openrs2.jar dev.openrs2.game.GameServer %* +java -cp lib\openrs2.jar dev.openrs2.game.GameServerKt %* diff --git a/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt b/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt index ca38566f9d..c4eca7679e 100644 --- a/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt +++ b/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt @@ -6,6 +6,32 @@ import java.io.Closeable import java.nio.file.Path import java.nio.file.Paths +private fun getDestination(archive: String): Path { + var dir = archive.replace(Regex("(?:_gl)?[.]jar$"), "") + when (dir) { + "runescape" -> dir = "client" + "jaggl" -> dir = "gl" + "jaggl_dri" -> dir = "gl-dri" + } + return Paths.get("nonfree").resolve(dir).resolve("src/main/java") +} + +fun main() { + val deobOutput = Paths.get("nonfree/code/deob") + val sources = listOf( + deobOutput.resolve("runescape_gl.jar"), + deobOutput.resolve("jaggl.jar"), + deobOutput.resolve("jaggl_dri.jar"), + deobOutput.resolve("loader_gl.jar"), + deobOutput.resolve("signlink_gl.jar"), + deobOutput.resolve("unpack_gl.jar"), + deobOutput.resolve("unpacker_gl.jar") + ) + Decompiler(sources, ::getDestination).use { + it.run() + } +} + class Decompiler( private val sources: List, destination: (String) -> Path @@ -30,32 +56,5 @@ class Decompiler( IFernflowerPreferences.INDENT_STRING to "\t", IFernflowerPreferences.SYNTHETIC_NOT_SET to "1" ) - - private fun getDestination(archive: String): Path { - var dir = archive.replace(Regex("(?:_gl)?[.]jar$"), "") - when (dir) { - "runescape" -> dir = "client" - "jaggl" -> dir = "gl" - "jaggl_dri" -> dir = "gl-dri" - } - return Paths.get("nonfree").resolve(dir).resolve("src/main/java") - } - - @JvmStatic - fun main(args: Array) { - val deobOutput = Paths.get("nonfree/code/deob") - val sources = listOf( - deobOutput.resolve("runescape_gl.jar"), - deobOutput.resolve("jaggl.jar"), - deobOutput.resolve("jaggl_dri.jar"), - deobOutput.resolve("loader_gl.jar"), - deobOutput.resolve("signlink_gl.jar"), - deobOutput.resolve("unpack_gl.jar"), - deobOutput.resolve("unpacker_gl.jar") - ) - Decompiler(sources, this::getDestination).use { - it.run() - } - } } } diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt index 7bda7d9b5a..220f0611f7 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt @@ -13,6 +13,21 @@ import java.nio.file.Path import java.nio.file.Paths import java.util.function.Function +fun main() { + val deobfuscator = AstDeobfuscator( + listOf( + Paths.get("nonfree/client/src/main/java"), + Paths.get("nonfree/gl/src/main/java"), + Paths.get("nonfree/gl-dri/src/main/java"), + Paths.get("nonfree/loader/src/main/java"), + Paths.get("nonfree/signlink/src/main/java"), + Paths.get("nonfree/unpack/src/main/java"), + Paths.get("nonfree/unpacker/src/main/java") + ) + ) + deobfuscator.run() +} + class AstDeobfuscator(private val modules: List) { fun run() { val solver = CombinedTypeSolver(ReflectionTypeSolver(true)) @@ -63,21 +78,5 @@ class AstDeobfuscator(private val modules: List) { NewInstanceTransformer(), EncloseTransformer() ) - - @JvmStatic - fun main(args: Array) { - val deobfuscator = AstDeobfuscator( - listOf( - Paths.get("nonfree/client/src/main/java"), - Paths.get("nonfree/gl/src/main/java"), - Paths.get("nonfree/gl-dri/src/main/java"), - Paths.get("nonfree/loader/src/main/java"), - Paths.get("nonfree/signlink/src/main/java"), - Paths.get("nonfree/unpack/src/main/java"), - Paths.get("nonfree/unpacker/src/main/java") - ) - ) - deobfuscator.run() - } } } diff --git a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt index 8e53c7c5b7..eb54e08778 100644 --- a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt +++ b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt @@ -13,6 +13,11 @@ import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths +fun main() { + val deobfuscator = Deobfuscator(Paths.get("nonfree/code"), Paths.get("nonfree/code/deob")) + deobfuscator.run() +} + class Deobfuscator(private val input: Path, private val output: Path) { fun run() { // read input jars/packs @@ -141,11 +146,5 @@ class Deobfuscator(private val input: Path, private val output: Path) { ResetTransformer(), AccessTransformer() ) - - @JvmStatic - fun main(args: Array) { - val deobfuscator = Deobfuscator(Paths.get("nonfree/code"), Paths.get("nonfree/code/deob")) - deobfuscator.run() - } } } diff --git a/game/src/main/java/dev/openrs2/game/GameServer.kt b/game/src/main/java/dev/openrs2/game/GameServer.kt index 06b9706f66..25e406ca73 100644 --- a/game/src/main/java/dev/openrs2/game/GameServer.kt +++ b/game/src/main/java/dev/openrs2/game/GameServer.kt @@ -1,7 +1,4 @@ package dev.openrs2.game -object GameServer { - @JvmStatic - fun main(args: Array) { - } +fun main() { }