Repository navigation
Patching with Kotlin
Lukas22041 edited this page Aug 28, 2026
·
6 revisions
Kotlin is another programming language that some people use in place of Java for making Starsector mods. For those that do, PatchLib works essentially the same as it does within Java code.
The main difference is that Kotlin handles statics slightly differently, so you have to make some adjustments.
@Patch(target = ClassMatch(subtype = BaseHullMod::class))
object KotlinPatch {
@JvmStatic
@After(target = MethodMatch(methodName = "addPostDescriptionSection"))
fun afterPostDescriptionSection(context: AfterContext) {
var tooltip = context.getArg(0) as TooltipMakerAPI
tooltip.addPara("Description added by PatchLib!", 0f,
Misc.getHighlightColor(), Misc.getHighlightColor())
}
}Instead of using a normal class, you want to use object, as the functions have to be static. Alternatively, a companion object block also works. Every patch handler method also requires the @JvmStatic annotation so PatchLib can read the method.
Also note that in Kotlin, nested annotations (i.e. MethodMatch) do not have an @ in front of them.

- Home
- Introduction to Patchlib
- Patch Types
- Working with obfuscated code
- Example Patches
- Other utilities
- Patching with Kotlin
- Developer Documentation