Closed filloax closed 4 weeks ago
Here's the correct usage:
class Test {
// other methods...
@EventBusSubscriber(bus=EventBusSubscriber.Bus.MOD)
companion object {
@SubscribeEvent
fun onGameStart(event: FMLCommonSetupEvent) {
println("Test print please ignore")
}
}
}
KFF treats the companion object the same as any other object
declaration, so all you need to do is annotate the companion object. No need to use @JvmStatic, KFF will use the object instance.
For instance, let's say I have a
ModNetworking
class where I want to subscribe to the `RegisterPayloadHandlersEvent' statically, as the class is instanced elsewhere (example: ServiceLoader) so I cannot make it an object. Do I place @EventBusSubscriber on the class, and @SubscribeEvent on a @JvmStatic method in the companion object?