diff --git a/api/src/main/java/dev/xhyrom/lighteco/api/event/EventBus.java b/api/src/main/java/dev/xhyrom/lighteco/api/event/EventBus.java new file mode 100644 index 0000000..401c9a3 --- /dev/null +++ b/api/src/main/java/dev/xhyrom/lighteco/api/event/EventBus.java @@ -0,0 +1,11 @@ +package dev.xhyrom.lighteco.api.event; + +import org.checkerframework.checker.nullness.qual.NonNull; + +import java.util.function.Consumer; + +public interface EventBus { + @NonNull EventSubscription subscribe(@NonNull Class eventClass, @NonNull Consumer subscriber); + + @NonNull EventSubscription subscribe(Object plugin, @NonNull Class eventClass, @NonNull Consumer subscriber); +} diff --git a/api/src/main/java/dev/xhyrom/lighteco/api/event/EventSubscription.java b/api/src/main/java/dev/xhyrom/lighteco/api/event/EventSubscription.java new file mode 100644 index 0000000..b530040 --- /dev/null +++ b/api/src/main/java/dev/xhyrom/lighteco/api/event/EventSubscription.java @@ -0,0 +1,13 @@ +package dev.xhyrom.lighteco.api.event; + +import org.checkerframework.checker.nullness.qual.NonNull; + +import java.util.function.Consumer; + +public interface EventSubscription extends AutoCloseable { + @NonNull Class getEventClass(); + + boolean isActive(); + + @NonNull Consumer getHandler(); +} diff --git a/api/src/main/java/dev/xhyrom/lighteco/api/event/LightEcoEvent.java b/api/src/main/java/dev/xhyrom/lighteco/api/event/LightEcoEvent.java new file mode 100644 index 0000000..e3ab9c3 --- /dev/null +++ b/api/src/main/java/dev/xhyrom/lighteco/api/event/LightEcoEvent.java @@ -0,0 +1,10 @@ +package dev.xhyrom.lighteco.api.event; + +import dev.xhyrom.lighteco.api.LightEco; +import org.checkerframework.checker.nullness.qual.NonNull; + +public interface LightEcoEvent { + @NonNull LightEco getLightEco(); + + @NonNull Class getEventClass(); +} diff --git a/api/src/main/java/dev/xhyrom/lighteco/api/event/currency/CurrencyRegisterEvent.java b/api/src/main/java/dev/xhyrom/lighteco/api/event/currency/CurrencyRegisterEvent.java new file mode 100644 index 0000000..fcdf5fd --- /dev/null +++ b/api/src/main/java/dev/xhyrom/lighteco/api/event/currency/CurrencyRegisterEvent.java @@ -0,0 +1,11 @@ +package dev.xhyrom.lighteco.api.event.currency; + +import dev.xhyrom.lighteco.api.event.LightEcoEvent; +import dev.xhyrom.lighteco.api.event.util.Position; +import dev.xhyrom.lighteco.api.model.currency.Currency; +import org.checkerframework.checker.nullness.qual.NonNull; + +public interface CurrencyRegisterEvent extends LightEcoEvent { + @Position(0) + @NonNull Currency getCurrency(); +} diff --git a/api/src/main/java/dev/xhyrom/lighteco/api/event/util/Position.java b/api/src/main/java/dev/xhyrom/lighteco/api/event/util/Position.java new file mode 100644 index 0000000..2f43124 --- /dev/null +++ b/api/src/main/java/dev/xhyrom/lighteco/api/event/util/Position.java @@ -0,0 +1,21 @@ +package dev.xhyrom.lighteco.api.event.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Represents the position (index) of a parameter within an event. + * Used for information purposes only. + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.SOURCE) +public @interface Position { + /** + * Represents the position (index) of a parameter. + * + * @return the position (index) + */ + int value(); +}