mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-31 04:13:51 -07:00
Add a call helper to Event
Reduces diff in Server patches
This commit is contained in:
@@ -35,6 +35,22 @@ public abstract class Event {
|
||||
this.async = isAsync;
|
||||
}
|
||||
|
||||
// Paper start
|
||||
/**
|
||||
* Calls the event and tests if cancelled.
|
||||
*
|
||||
* @return false if event was cancelled, if cancellable. otherwise true.
|
||||
*/
|
||||
public boolean callEvent() {
|
||||
org.bukkit.Bukkit.getPluginManager().callEvent(this);
|
||||
if (this instanceof Cancellable) {
|
||||
return !((Cancellable) this).isCancelled();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
* Convenience method for providing a user-friendly identifier. By
|
||||
* default, it is the event's class's {@linkplain Class#getSimpleName()
|
||||
|
Reference in New Issue
Block a user