Fix event calling & canceling

This commit is contained in:
KingRainbow44 2023-05-26 23:26:49 -04:00
parent 9d4cb733e2
commit d1f774892c
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -14,10 +14,12 @@ public abstract class Event {
/** Cancels the event if possible. */
public void cancel() {
if (this instanceof Cancellable) this.cancelled = true;
else throw new UnsupportedOperationException("Event is not cancellable.");
}
/** Pushes this event to all listeners. */
public void call() {
Grasscutter.getPluginManager().invokeEvent(this);
var pluginManager = Grasscutter.getPluginManager();
if (pluginManager != null) pluginManager.invokeEvent(this);
}
}