mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-12-05 03:03:31 +00:00
34 lines
734 B
Java
34 lines
734 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() throws IllegalAccessException {
|
||
|
if(!(this instanceof Cancellable))
|
||
|
throw new IllegalAccessException("Event is not cancellable.");
|
||
|
this.cancelled = true;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Pushes this event to all listeners.
|
||
|
*/
|
||
|
public void call() {
|
||
|
Grasscutter.getPluginManager().invokeEvent(this);
|
||
|
}
|
||
|
}
|