Ask or search…
Comment on page

Event API


PlotSquared uses the Guava EventBus to register listeners and dispatch events.

Event List

Check the Javadoc of PlotSquared events.

Getting an instance

import org.bukkit.Bukkit;
public class MyPlotPlugin extends JavaPlugin {
public static MyPlotPlugin THIS;
public void onEnable() {
MyPlotPlugin.THIS = this;
if (Bukkit.getPluginManager().getPlugin("PlotSquared") != null) {
// Do something

Registering a Listener

Registering a listener is super easy. Add the @Subscribe (from the package) annotation to any methods that are listening to events, register the class with the EventBus through PlotAPI#registerListener(Class) and you're done! One example:
public class P2Listener {
// if you like the dependency-injection-like approach:
public P2Listener(PlotAPI api) {
// less OOP, but if you want to make things easy:
public P2Listener() {
PlotAPI api = new PlotAPI();
// A method handling a PlayerEnterPlotEvent
public void onPlayerEnterPlot(PlayerEnterPlotEvent e) {
//do stuff