Raywire is an event library for Better Than Adventure (BTA), designed to provide a flexible and efficient event-driven system for BTA mod developers.
Written in Kotlin, Raywire makes it easy to create, subscribe to, and manage custom events within your BTA mods.
Add Raywire as a dependency in your mod's build.gradle.kts:
dependencies {
modImplementation("com.github.Apollointhehouse:Raywire:<version>")
}
Replace <version> with the latest Raywire release.
Create an event listener in Kotlin:
class Foo {
@EventHandler
fun onTick(event: TickEvent.Post) {
println("Tick event!")
}
@EventHandler
fun onFooEvent(event: FooEvent) {
println("Foo event with bar: ${event.bar}")
}
}
Create an event:
class FooEvent(val bar: String) : Event
Create an event bus:
val bus = Bus()
Or use the global bus:
val bus = Raywire.globalBus
Then subscribe the listener:
bus.subscribe(Foo())
Post an event:
bus.post(FooEvent(bar))
Contributions are welcome! Please open issues or pull requests on the GitHub repository.
Raywire is licensed under the MIT License. See the LICENSE file for details.