Fix conditional factory not actually having a condition

This commit is contained in:
TheMode 2021-06-02 11:26:36 +02:00
parent 5d1b742934
commit 12c620df7a
2 changed files with 5 additions and 5 deletions

View File

@ -29,15 +29,15 @@ public class EventNode<T extends Event> {
return EMPTY;
}
public static <E extends Event> EventNode<E> create(@NotNull Class<E> type) {
return new EventNode<>(type);
}
public static <E extends Event> EventNode<E> conditional(@NotNull Class<E> type,
@NotNull Predicate<E> predicate) {
return new EventNodeConditional<>(type, predicate);
}
public static <E extends Event> EventNode<E> conditional(@NotNull Class<E> eventType) {
return conditional(eventType, t -> true);
}
protected boolean condition(@NotNull T event) {
return true;
}

View File

@ -137,7 +137,7 @@ public class PlayerInit {
// EVENT REGISTERING
var node = EventNode.conditional(PlayerEvent.class);
var node = EventNode.create(PlayerEvent.class);
node.addListener(EventListener.of(PlayerTickEvent.class)
.handler(playerTickEvent -> System.out.println("Player tick!"))
.build());