diff --git a/src/main/java/net/minestom/server/event/EventFilter.java b/src/main/java/net/minestom/server/event/EventFilter.java index c6f591109..2ece64c1d 100644 --- a/src/main/java/net/minestom/server/event/EventFilter.java +++ b/src/main/java/net/minestom/server/event/EventFilter.java @@ -13,7 +13,7 @@ import java.util.function.Function; public interface EventFilter { - EventFilter ALL = from(Event.class); + EventFilter ALL = from(Event.class); EventFilter ENTITY = from(EntityEvent.class, Entity.class, EntityEvent::getEntity); EventFilter PLAYER = from(PlayerEvent.class, Player.class, PlayerEvent::getPlayer); EventFilter ITEM = from(ItemEvent.class, ItemStack.class, ItemEvent::getItemStack); @@ -21,12 +21,12 @@ public interface EventFilter { EventFilter INVENTORY = from(InventoryEvent.class, Inventory.class, InventoryEvent::getInventory); static EventFilter from(@NotNull Class eventType, - @NotNull Class handlerType, - @NotNull Function handlerGetter) { + @Nullable Class handlerType, + @Nullable Function handlerGetter) { return new EventFilter<>() { @Override public @Nullable H getHandler(@NotNull E event) { - return handlerGetter.apply(event); + return handlerGetter != null ? handlerGetter.apply(event) : null; } @Override @@ -37,17 +37,7 @@ public interface EventFilter { } static EventFilter from(@NotNull Class type) { - return new EventFilter<>() { - @Override - public @Nullable H getHandler(@NotNull E event) { - return null; - } - - @Override - public @NotNull Class getEventType() { - return type; - } - }; + return from(type, null, null); } @Nullable H getHandler(@NotNull E event);