mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Rename EventListener#eventType
This commit is contained in:
parent
044849b5ac
commit
46d2542d59
@ -19,7 +19,7 @@ import java.util.function.Predicate;
|
|||||||
*/
|
*/
|
||||||
public interface EventListener<T extends Event> {
|
public interface EventListener<T extends Event> {
|
||||||
|
|
||||||
@NotNull Class<T> getEventType();
|
@NotNull Class<T> eventType();
|
||||||
|
|
||||||
@NotNull Result run(@NotNull T event);
|
@NotNull Result run(@NotNull T event);
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ public interface EventListener<T extends Event> {
|
|||||||
final var handler = this.handler;
|
final var handler = this.handler;
|
||||||
return new EventListener<>() {
|
return new EventListener<>() {
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Class<T> getEventType() {
|
public @NotNull Class<T> eventType() {
|
||||||
return eventType;
|
return eventType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
@Override
|
@Override
|
||||||
public @NotNull EventNode<T> addListener(@NotNull EventListener<? extends T> listener) {
|
public @NotNull EventNode<T> addListener(@NotNull EventListener<? extends T> listener) {
|
||||||
synchronized (GLOBAL_CHILD_LOCK) {
|
synchronized (GLOBAL_CHILD_LOCK) {
|
||||||
final var eventType = listener.getEventType();
|
final var eventType = listener.eventType();
|
||||||
var entry = getEntry(eventType);
|
var entry = getEntry(eventType);
|
||||||
entry.listeners.add((EventListener<T>) listener);
|
entry.listeners.add((EventListener<T>) listener);
|
||||||
propagateEvent(eventType);
|
propagateEvent(eventType);
|
||||||
@ -183,7 +183,7 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
|
|||||||
@Override
|
@Override
|
||||||
public @NotNull EventNode<T> removeListener(@NotNull EventListener<? extends T> listener) {
|
public @NotNull EventNode<T> removeListener(@NotNull EventListener<? extends T> listener) {
|
||||||
synchronized (GLOBAL_CHILD_LOCK) {
|
synchronized (GLOBAL_CHILD_LOCK) {
|
||||||
final var eventType = listener.getEventType();
|
final var eventType = listener.eventType();
|
||||||
var entry = listenerMap.get(eventType);
|
var entry = listenerMap.get(eventType);
|
||||||
if (entry == null) return this;
|
if (entry == null) return this;
|
||||||
var listeners = entry.listeners;
|
var listeners = entry.listeners;
|
||||||
|
Loading…
Reference in New Issue
Block a user