Start adding implementation

This commit is contained in:
Zontreck 2023-10-12 13:31:27 -07:00
parent 5872c2f913
commit b7c272ca09
5 changed files with 73 additions and 3 deletions

View file

@ -1,7 +1,37 @@
package dev.zontreck.eventsbus;
public class Event {
private boolean cancelled = false;
public class Event
{
/**
* Checks if the event can be cancelled.
*
* @see Cancellable
* @return True if the cancellation annotation is present.
*/
public boolean IsCancellable() {
Class<?> Current = this.getClass();
return Current.isAnnotationPresent(Cancellable.class);
}
/**
* Checks if the event is cancelled.
*
* @return False if the event cannot be cancelled, or returns the current status
* for the event.
*/
public boolean isCancelled() {
if (!IsCancellable())
return false;
return cancelled;
}
/**
* Sets the cancelled status for the event
*
* @param cancel Whether the event should be marked as cancelled or not.
*/
public void setCancelled(boolean cancel) {
cancelled = cancel;
}
}