summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-08-17 18:26:10 +0200
committer zaaarf <zaaarf@proton.me>2023-08-17 18:26:10 +0200
commit8123655b9ad1d831779797467e0e23afd52b90d0 (patch)
treefe49509825b7ad86390bf30fac7e94e28dd96906 /src
feat: initial basic api implementation
will probably change severely as i write this
Diffstat (limited to 'src')
-rw-r--r--src/main/java/ftbsc/geb/api/IEvent.java9
-rw-r--r--src/main/java/ftbsc/geb/api/IListener.java5
-rw-r--r--src/main/java/ftbsc/geb/api/annotations/Event.java8
-rw-r--r--src/main/java/ftbsc/geb/api/annotations/Listen.java14
4 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/geb/api/IEvent.java b/src/main/java/ftbsc/geb/api/IEvent.java
new file mode 100644
index 0000000..d0c4815
--- /dev/null
+++ b/src/main/java/ftbsc/geb/api/IEvent.java
@@ -0,0 +1,9 @@
+package ftbsc.geb.api;
+
+public interface IEvent {
+ default boolean isCanceled() {
+ return false;
+ }
+
+ void dispatch();
+}
diff --git a/src/main/java/ftbsc/geb/api/IListener.java b/src/main/java/ftbsc/geb/api/IListener.java
new file mode 100644
index 0000000..9691342
--- /dev/null
+++ b/src/main/java/ftbsc/geb/api/IListener.java
@@ -0,0 +1,5 @@
+package ftbsc.geb.api;
+
+public interface IListener {
+ boolean active();
+}
diff --git a/src/main/java/ftbsc/geb/api/annotations/Event.java b/src/main/java/ftbsc/geb/api/annotations/Event.java
new file mode 100644
index 0000000..780f361
--- /dev/null
+++ b/src/main/java/ftbsc/geb/api/annotations/Event.java
@@ -0,0 +1,8 @@
+package ftbsc.geb.api.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+public @interface Event {
+}
diff --git a/src/main/java/ftbsc/geb/api/annotations/Listen.java b/src/main/java/ftbsc/geb/api/annotations/Listen.java
new file mode 100644
index 0000000..f8398ed
--- /dev/null
+++ b/src/main/java/ftbsc/geb/api/annotations/Listen.java
@@ -0,0 +1,14 @@
+package ftbsc.geb.api.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+/**
+ * Marks the method as a listener.
+ * Its parent must implement the {@link ftbsc.geb.api.IListener} interface.
+ * The method should only take a single input value, an event.
+ */
+@Target(ElementType.METHOD)
+public @interface Listen {
+ int priority() default 0;
+}