Remove EventNodeList.java

This commit is contained in:
TheMode 2021-06-03 03:39:37 +02:00
parent 3727f3f954
commit 493c397efe
3 changed files with 8 additions and 38 deletions

View File

@ -39,10 +39,6 @@ public class EventNode<T extends Event> {
return conditional(filter, (e, h) -> predicate.test(h));
}
public static <E extends Event, H> EventNodeList<E, H> list(@NotNull EventFilter<E, H> filter) {
return new EventNodeList<>(filter);
}
private volatile String name = "unknown";
private final Map<Class<? extends T>, List<EventListener<T>>> listenerMap = new ConcurrentHashMap<>();

View File

@ -1,29 +0,0 @@
package net.minestom.server.event;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class EventNodeList<T extends Event, H> extends EventNode<T> {
private final List<H> entries = new CopyOnWriteArrayList<>();
protected EventNodeList(EventFilter<T, H> filter) {
super(filter);
}
@Override
protected boolean condition(@NotNull T event) {
final var eventHandler = filter.getHandler(event);
return entries.contains(eventHandler);
}
public void addEntry(@NotNull H handler) {
this.entries.add(handler);
}
public void removeEntry(@NotNull H handler) {
this.entries.remove(handler);
}
}

View File

@ -146,9 +146,16 @@ public class PlayerInit {
node.setName("node");
node.addListener(EventListener.builder(PlayerTickEvent.class)
.handler(playerTickEvent -> System.out.println("Player tick!"))
.expirationCount(2)
.expirationCount(50)
.build());
empty.addChild(node);
node.call(new PlayerTickEvent(null));
empty.call(new PlayerTickEvent(null));
empty.removeChild(node);
node.call(new PlayerTickEvent(null));
empty.call(new PlayerTickEvent(null));
/*
* Map a node to a single element
*
@ -162,10 +169,6 @@ public class PlayerInit {
conditional.addListener(EventListener.of(PlayerMoveEvent.class, (event) ->
System.out.println("creative player moved")));
var list = EventNode.list(EventFilter.PLAYER);
list.addListener(EventListener.of(PlayerMoveEvent.class, event ->
System.out.println("move")));
GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
globalEventHandler.addEventCallback(EntityAttackEvent.class, event -> {
final Entity source = event.getEntity();