mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 08:56:04 +01:00
26 lines
732 B
Java
26 lines
732 B
Java
package emu.grasscutter.server.event;
|
|
|
|
import emu.grasscutter.Grasscutter;
|
|
|
|
/** A generic server event. */
|
|
public abstract class Event {
|
|
private boolean cancelled = false;
|
|
|
|
/** Return the cancelled state of the event. */
|
|
public boolean isCanceled() {
|
|
return this.cancelled;
|
|
}
|
|
|
|
/** 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() {
|
|
var pluginManager = Grasscutter.getPluginManager();
|
|
if (pluginManager != null) pluginManager.invokeEvent(this);
|
|
}
|
|
}
|