mirror of
https://github.com/xHyroM/lighteco.git
synced 2024-11-22 06:51:05 +01:00
feat(api): add some basic event interfaces
This commit is contained in:
parent
7b6db1b887
commit
7913bbe8e6
5 changed files with 66 additions and 0 deletions
|
@ -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 {
|
||||||
|
<T extends LightEcoEvent> @NonNull EventSubscription<T> subscribe(@NonNull Class<T> eventClass, @NonNull Consumer<? super T> subscriber);
|
||||||
|
|
||||||
|
<T extends LightEcoEvent> @NonNull EventSubscription<T> subscribe(Object plugin, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> subscriber);
|
||||||
|
}
|
|
@ -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<T extends LightEcoEvent> extends AutoCloseable {
|
||||||
|
@NonNull Class<T> getEventClass();
|
||||||
|
|
||||||
|
boolean isActive();
|
||||||
|
|
||||||
|
@NonNull Consumer<? super T> getHandler();
|
||||||
|
}
|
|
@ -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<? extends LightEcoEvent> getEventClass();
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
Loading…
Reference in a new issue