diff --git a/src/main/java/net/minestom/server/event/EventNode.java b/src/main/java/net/minestom/server/event/EventNode.java index 5f2c3c781..d02464009 100644 --- a/src/main/java/net/minestom/server/event/EventNode.java +++ b/src/main/java/net/minestom/server/event/EventNode.java @@ -10,12 +10,12 @@ import java.util.function.Predicate; public interface EventNode { - static EventNode create(@NotNull Class type) { + static EventNode type(@NotNull Class type) { return new EventNodeImpl<>(type); } - static EventNode create() { - return create(Event.class); + static EventNode all() { + return type(Event.class); } static EventNodeConditional conditional(@NotNull Class type, diff --git a/src/test/java/demo/PlayerInit.java b/src/test/java/demo/PlayerInit.java index 0a763acbf..012964aca 100644 --- a/src/test/java/demo/PlayerInit.java +++ b/src/test/java/demo/PlayerInit.java @@ -137,16 +137,21 @@ public class PlayerInit { // EVENT REGISTERING - var node = EventNode.create(PlayerEvent.class); + var node = EventNode.type(PlayerEvent.class); node.addListener(EventListener.of(PlayerTickEvent.class) .handler(playerTickEvent -> System.out.println("Player tick!")) .expirationCount(2) .build()); - var empty = EventNode.create(); + var empty = EventNode.all(); empty.addListener(PlayerMoveEvent.class, (event) -> { }); + var map = EventNode.list(PlayerEvent.class, Player.class, PlayerEvent::getPlayer); + map.addListener(PlayerMoveEvent.class, playerMoveEvent -> { + System.out.println("move"); + }); + GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler(); globalEventHandler.addEventCallback(EntityAttackEvent.class, event -> { final Entity source = event.getEntity();