mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:12:54 +08:00
Fix event calling & canceling
This commit is contained in:
parent
9d4cb733e2
commit
d1f774892c
@ -14,10 +14,12 @@ public abstract class Event {
|
|||||||
/** Cancels the event if possible. */
|
/** Cancels the event if possible. */
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
if (this instanceof Cancellable) this.cancelled = true;
|
if (this instanceof Cancellable) this.cancelled = true;
|
||||||
|
else throw new UnsupportedOperationException("Event is not cancellable.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Pushes this event to all listeners. */
|
/** Pushes this event to all listeners. */
|
||||||
public void call() {
|
public void call() {
|
||||||
Grasscutter.getPluginManager().invokeEvent(this);
|
var pluginManager = Grasscutter.getPluginManager();
|
||||||
|
if (pluginManager != null) pluginManager.invokeEvent(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user