Skip to content

Create a PaperMC Event Listener with Reedwork in 5 Minutes

By the end of this tutorial, you will have a working PaperMC event listener that automatically gets discovered and registered by Reedwork.

First, add Reedwork to your Paper plugin project.


Reedwork uses package scanning to discover annotated components such as event listeners.

Start by creating your main plugin class:

FiveMinuteEventListener.java
package dev.reedworkmc.examples.fiveminuteeventlistener;
import dev.reedworkmc.reedwork.Reedwork;
import org.bukkit.plugin.java.JavaPlugin;
public final class FiveMinuteEventListener extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
Reedwork.create(this).scan("dev.reedworkmc.examples.fiveminuteeventlistener");
}
}

This creates a Reedwork instance for your plugin and scans the specified package for Reedwork components.

Because the event listener is located inside this package, Reedwork automatically discovers it.

For example:

  • Directorysrc/main/java/
    • Directorydev.reedworkmc.examples.fiveminuteeventlistener
      • FiveMinuteEventListener.java

You do not need to manually register the listener with Bukkit.


Create an events package.

Create PlayerJoinServerEventListener:

  • Directorysrc/main/java/
    • Directorydev.reedworkmc.examples.fiveminuteeventlistener
      • Directoryevents
        • PlayerJoinServerEventListener.java
      • FiveMinuteEventListener.java
PlayerJoinServerEventListener.java
package dev.reedworkmc.examples.fiveminuteeventlistener.events;
import dev.reedworkmc.reedwork.annotation.EventListener;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
@EventListener
public class PlayerJoinServerEventListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
player.sendMessage(Component.text("Hello Reedwork!"));
}
}

There are two important annotations here.

@EventListener

This tells Reedwork that the class should be automatically discovered and registered as a Bukkit event listener.

The class still uses the normal Bukkit Listener interface.

@EventHandler

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
// Handling here
}

This is the standard Bukkit event handler annotation.

Reedwork does not replace Bukkit’s event system. It only handles discovery and registration.

When a player joins, the event method is executed:

Player player = event.getPlayer();
player.sendMessage(Component.text("Hello Reedwork!"));

Build your plugin:

Terminal window
mvn clean package

Copy the resulting JAR from target/ into the plugins/ directory of your Paper server.

Start the server.

Reedwork will scan:

dev.reedworkmc.examples.fiveminuteeventlistener

and automatically discover PlayerJoinServerEventListener.

Join the server.

The joining player receives:

Hello Reedwork!

That’s it — you have created a PaperMC event listener with Reedwork without manually registering it.

In just a few minutes, you learned how to:

Add Reedwork to a PaperMC plugin Initialize Reedwork with Reedwork.create(this) Scan your plugin package

Let Reedwork automatically discover and register listeners

  • Install Reedwork in a PaperMC plugin
  • Initialize Reedwork with Reedwork.create(this)
  • Scan your plugin package
  • Create an event listener with @EventListener
  • Use Bukkit’s standard @EventHandler
  • Let Reedwork automatically discover and register the command

Now that you have created your first event listener, explore what else Reedwork can do.

Check out the event documentation for more advanced features, or continue with: