diff --git a/src/main/java/net/minestom/server/event/EventNode.java b/src/main/java/net/minestom/server/event/EventNode.java index abfa260b9..f8bf90e3c 100644 --- a/src/main/java/net/minestom/server/event/EventNode.java +++ b/src/main/java/net/minestom/server/event/EventNode.java @@ -39,10 +39,6 @@ public class EventNode { return conditional(filter, (e, h) -> predicate.test(h)); } - public static EventNodeList list(@NotNull EventFilter filter) { - return new EventNodeList<>(filter); - } - private volatile String name = "unknown"; private final Map, List>> listenerMap = new ConcurrentHashMap<>(); diff --git a/src/main/java/net/minestom/server/event/EventNodeList.java b/src/main/java/net/minestom/server/event/EventNodeList.java deleted file mode 100644 index 378203976..000000000 --- a/src/main/java/net/minestom/server/event/EventNodeList.java +++ /dev/null @@ -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 extends EventNode { - - private final List entries = new CopyOnWriteArrayList<>(); - - protected EventNodeList(EventFilter 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); - } -} diff --git a/src/test/java/demo/PlayerInit.java b/src/test/java/demo/PlayerInit.java index 96f6c9bd6..44e6da961 100644 --- a/src/test/java/demo/PlayerInit.java +++ b/src/test/java/demo/PlayerInit.java @@ -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();