Start adding implementation
This commit is contained in:
parent
5872c2f913
commit
b7c272ca09
5 changed files with 73 additions and 3 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -22,3 +22,8 @@
|
|||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
|
||||
.gradle
|
||||
|
||||
build
|
11
src/main/java/dev/zontreck/eventsbus/Cancellable.java
Normal file
11
src/main/java/dev/zontreck/eventsbus/Cancellable.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package dev.zontreck.eventsbus;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(value = ElementType.TYPE)
|
||||
public @interface Cancellable {
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
9
src/main/java/dev/zontreck/eventsbus/Priority.java
Normal file
9
src/main/java/dev/zontreck/eventsbus/Priority.java
Normal file
|
@ -0,0 +1,9 @@
|
|||
package dev.zontreck.eventsbus;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
public @interface Priority {
|
||||
public PriorityLevel Level = PriorityLevel.LOW;
|
||||
}
|
15
src/main/java/dev/zontreck/eventsbus/PriorityLevel.java
Normal file
15
src/main/java/dev/zontreck/eventsbus/PriorityLevel.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package dev.zontreck.eventsbus;
|
||||
|
||||
/**
|
||||
* Event priority level.
|
||||
*
|
||||
* The higher the priority, the sooner it gets executed. High is executed after
|
||||
* Highest.
|
||||
*/
|
||||
public enum PriorityLevel {
|
||||
HIGHEST,
|
||||
HIGH,
|
||||
MEDIUM,
|
||||
LOW,
|
||||
LOWEST
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue