forked from openrs2/openrs2
parent
1552b53ace
commit
a52d58e8b5
@ -0,0 +1,23 @@ |
||||
package dev.openrs2 |
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand |
||||
import com.github.ajalt.clikt.core.subcommands |
||||
import dev.openrs2.bundler.BundleCommand |
||||
import dev.openrs2.decompiler.DecompileCommand |
||||
import dev.openrs2.deob.DeobfuscateCommand |
||||
import dev.openrs2.deob.ast.AstDeobfuscateCommand |
||||
import dev.openrs2.game.GameCommand |
||||
|
||||
fun main(args: Array<String>) = Command().subcommands( |
||||
BundleCommand(), |
||||
DecompileCommand(), |
||||
DeobfuscateCommand(), |
||||
AstDeobfuscateCommand(), |
||||
GameCommand() |
||||
).main(args) |
||||
|
||||
class Command : CliktCommand(name = "openrs2") { |
||||
override fun run() { |
||||
// empty |
||||
} |
||||
} |
@ -1,39 +0,0 @@ |
||||
package dev.openrs2 |
||||
|
||||
import kotlin.system.exitProcess |
||||
import dev.openrs2.bundler.main as bundlerMain |
||||
import dev.openrs2.decompiler.main as decompilerMain |
||||
import dev.openrs2.deob.ast.main as astDeobfuscatorMain |
||||
import dev.openrs2.deob.main as deobfuscatorMain |
||||
import dev.openrs2.game.main as gameMain |
||||
|
||||
fun main(args: Array<String>) { |
||||
val command: String |
||||
val commandArgs: Array<String> |
||||
if (args.isEmpty()) { |
||||
command = "game" |
||||
commandArgs = emptyArray() |
||||
} else { |
||||
command = args[0] |
||||
commandArgs = args.copyOfRange(1, args.size) |
||||
} |
||||
|
||||
when (command) { |
||||
"bundle" -> bundlerMain() |
||||
"decompile" -> decompilerMain() |
||||
"deob" -> deobfuscatorMain() |
||||
"deob-ast" -> astDeobfuscatorMain() |
||||
"game" -> gameMain() |
||||
else -> { |
||||
System.err.println("Usage: openrs2 [<command> [<args>]]") |
||||
System.err.println() |
||||
System.err.println("Commands:") |
||||
System.err.println(" bundle") |
||||
System.err.println(" decompile") |
||||
System.err.println(" deob") |
||||
System.err.println(" deob-ast") |
||||
System.err.println(" game") |
||||
exitProcess(1) |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,15 @@ |
||||
package dev.openrs2.bundler |
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand |
||||
import com.google.inject.Guice |
||||
import java.nio.file.Paths |
||||
|
||||
fun main(args: Array<String>) = BundleCommand().main(args) |
||||
|
||||
class BundleCommand : CliktCommand(name = "bundle") { |
||||
override fun run() { |
||||
val injector = Guice.createInjector(BundlerModule()) |
||||
val bundler = injector.getInstance(Bundler::class.java) |
||||
bundler.run(Paths.get("nonfree/code"), Paths.get("nonfree/code/bundle"), Paths.get("conf/loader.p12")) |
||||
} |
||||
} |
@ -0,0 +1,33 @@ |
||||
package dev.openrs2.decompiler |
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand |
||||
import java.nio.file.Path |
||||
import java.nio.file.Paths |
||||
|
||||
fun main(args: Array<String>) = DecompileCommand().main(args) |
||||
|
||||
class DecompileCommand : CliktCommand(name = "decompile") { |
||||
override fun run() { |
||||
val deobOutput = Paths.get("nonfree/code/deob") |
||||
val sources = listOf( |
||||
deobOutput.resolve("runescape_gl.jar"), |
||||
deobOutput.resolve("jaggl.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() |
||||
} |
||||
} |
||||
|
||||
private fun getDestination(archive: String): Path { |
||||
var dir = archive.replace(Regex("(?:_gl)?[.]jar$"), "") |
||||
when (dir) { |
||||
"runescape" -> dir = "client" |
||||
"jaggl" -> dir = "gl" |
||||
} |
||||
return Paths.get("nonfree").resolve(dir).resolve("src/main/java") |
||||
} |
||||
} |
@ -0,0 +1,22 @@ |
||||
package dev.openrs2.deob.ast |
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand |
||||
import java.nio.file.Paths |
||||
|
||||
fun main(args: Array<String>) = AstDeobfuscateCommand().main(args) |
||||
|
||||
class AstDeobfuscateCommand : CliktCommand(name = "deob-ast") { |
||||
override fun run() { |
||||
val deobfuscator = AstDeobfuscator( |
||||
listOf( |
||||
Paths.get("nonfree/client/src/main/java"), |
||||
Paths.get("nonfree/gl/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() |
||||
} |
||||
} |
@ -0,0 +1,13 @@ |
||||
package dev.openrs2.deob |
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand |
||||
import java.nio.file.Paths |
||||
|
||||
fun main(args: Array<String>) = DeobfuscateCommand().main(args) |
||||
|
||||
class DeobfuscateCommand : CliktCommand(name = "deob") { |
||||
override fun run() { |
||||
val deobfuscator = Deobfuscator(Paths.get("nonfree/code"), Paths.get("nonfree/code/deob")) |
||||
deobfuscator.run() |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
package dev.openrs2.game |
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand |
||||
import com.google.inject.Guice |
||||
|
||||
fun main(args: Array<String>) = GameCommand().main(args) |
||||
|
||||
class GameCommand : CliktCommand(name = "game") { |
||||
override fun run() { |
||||
val injector = Guice.createInjector(GameModule()) |
||||
val server = injector.getInstance(GameServer::class.java) |
||||
server.run() |
||||
} |
||||
} |
Loading…
Reference in new issue