Raywire

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.

Features

Prerequisites

Using Raywire in Your Mod

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.

Example Usage

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))

Dependencies

Contributing

Contributions are welcome! Please open issues or pull requests on the GitHub repository.

License

Raywire is licensed under the MIT License. See the LICENSE file for details.