Use top-level Kotlin main() functions

master
Graham 5 years ago
parent a99d5973ae
commit 77e8b0cdc0
  1. 2
      all/pom.xml
  2. 2
      all/src/bin/openrs2-decompiler
  3. 2
      all/src/bin/openrs2-decompiler.cmd
  4. 2
      all/src/bin/openrs2-deob
  5. 2
      all/src/bin/openrs2-deob-ast
  6. 2
      all/src/bin/openrs2-deob-ast.cmd
  7. 2
      all/src/bin/openrs2-deob.cmd
  8. 2
      all/src/bin/openrs2-game
  9. 2
      all/src/bin/openrs2-game.cmd
  10. 53
      decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt
  11. 31
      deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt
  12. 11
      deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt
  13. 5
      game/src/main/java/dev/openrs2/game/GameServer.kt

@ -59,7 +59,7 @@
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>dev.openrs2.game.GameServer</Main-Class>
<Main-Class>dev.openrs2.game.GameServerKt</Main-Class>
</manifestEntries>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />

@ -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 "$@"

@ -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 %*

@ -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 "$@"

@ -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 "$@"

@ -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 %*

@ -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 %*

@ -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 "$@"

@ -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 %*

@ -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<Path>,
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<String>) {
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()
}
}
}
}

@ -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<Path>) {
fun run() {
val solver = CombinedTypeSolver(ReflectionTypeSolver(true))
@ -63,21 +78,5 @@ class AstDeobfuscator(private val modules: List<Path>) {
NewInstanceTransformer(),
EncloseTransformer()
)
@JvmStatic
fun main(args: Array<String>) {
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()
}
}
}

@ -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<String>) {
val deobfuscator = Deobfuscator(Paths.get("nonfree/code"), Paths.get("nonfree/code/deob"))
deobfuscator.run()
}
}
}

@ -1,7 +1,4 @@
package dev.openrs2.game
object GameServer {
@JvmStatic
fun main(args: Array<String>) {
}
fun main() {
}

Loading…
Cancel
Save