Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
package org.openrs2.bundler.transform
|
|
|
|
import com.github.michaelbull.logging.InlineLogger
|
|
import org.objectweb.asm.tree.ClassNode
|
|
import org.objectweb.asm.tree.LdcInsnNode
|
|
import org.objectweb.asm.tree.MethodNode
|
|
import org.openrs2.asm.classpath.ClassPath
|
|
import org.openrs2.asm.classpath.Library
|
|
import org.openrs2.asm.transform.Transformer
|
|
import org.openrs2.conf.Config
|
|
import javax.inject.Inject
|
|
import javax.inject.Singleton
|
|
|
|
@Singleton
|
|
public class NameTransformer @Inject constructor(
|
|
private val config: Config
|
|
) : Transformer() {
|
|
private var names = 0
|
|
|
|
override fun preTransform(classPath: ClassPath) {
|
|
names = 0
|
|
}
|
|
|
|
override fun transformCode(classPath: ClassPath, library: Library, clazz: ClassNode, method: MethodNode): Boolean {
|
|
for (insn in method.instructions) {
|
|
if (insn !is LdcInsnNode) {
|
|
continue
|
|
}
|
|
|
|
val cst = insn.cst
|
|
if (cst !is String) {
|
|
continue
|
|
}
|
|
|
|
insn.cst = cst.replace("RuneScape", config.game)
|
|
.replace("Jagex", config.operator)
|
|
if (insn.cst != cst) {
|
|
names++
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
override fun postTransform(classPath: ClassPath) {
|
|
logger.info { "Replaced $names operator and game names" }
|
|
}
|
|
|
|
private companion object {
|
|
private val logger = InlineLogger()
|
|
}
|
|
}
|
|
|