A small Reactive API with RxJava for Minecraft Paper Plugins.
When you want to return something back in the Minecraft Thread
public void test(Plugin plugin) {
Flowable.just("").subscribeOn(RxPaper.io(plugin)).subscribe();
}
When you want to listen an Event
public void test(Plugin plugin) {
RxPaper.event(plugin, PlayerJoinEvent.class).map(PlayerEvent::getPlayer).subscribe(player -> player.sendMessage("Hello"));
RxPaper.event(plugin, PlayerJoinEvent.class, new EventSettings(EventPriority.MONITOR, false)).map(PlayerEvent::getPlayer).subscribe(player -> player.sendMessage("Hello later"));
}
When you want to listen a Command
public void test(Plugin plugin) {
RxPaper.command(plugin, "test").subscribe(command -> command.commandSender().sendMessage("This is a command"));
}
repositories {
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/newspicel/rxjava")
}
}
dependencies {
implementation("dev.newspicel.rxpaper:rxpaper:1.0")
}
repositories {
maven {
url 'https://maven.pkg.github.com/newspicel/rxjava'
}
}
dependencies {
implementation 'dev.newspicel.rxpaper:rxpaper:1.0'
}
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/newspicel/rxjava</url>
</repository>
<dependency>
<groupId>dev.newspicel.rxpaper</groupId>
<artifactId>rxpaper</artifactId>
<version>1.0</version>
</dependency>