Events
All events live in io.github.robie.projectone.api.event and are fired on the
thread that owns the affected region.
| Event | Cancellable | Fired when |
|---|---|---|
ProjectOnePreCountEvent | Yes | Before a player's count changes |
ProjectOneCountEvent | No | After the count has changed |
ProjectOneReloadEvent | No | After configuration reloads |
The Pre / past-tense split is worth copying: a cancellable event before the
change and an informational one after it removes the ambiguity of "can I still
stop this?".
Listening
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public final class CountListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPreCount(ProjectOnePreCountEvent event) {
if (event.getNewCount() > 100) {
event.setCancelled(true);
}
}
}
Register it in onEnable:
getServer().getPluginManager().registerEvents(new CountListener(), this);
Priorities
Use MONITOR only to observe, never to change anything — by then other plugins
have decided the outcome. Set ignoreCancelled = true unless you specifically
want to see cancelled events.
Threading
Listeners run on the region thread that owns the event's location. Do not block:
no database queries, no HTTP calls, no Thread.sleep. Hand work off with the
async scheduler and come back to the region thread to apply results.
Bukkit.isPrimaryThread() is not a useful check on Folia. If your listener
needs to touch a different region than the event's, schedule to that region
explicitly.