Package net.minestom.server.event
Interface EventFilter<E extends Event,H>
- Type Parameters:
E
- The event type to filterH
- The handler type to filter on.
public interface EventFilter<E extends Event,H>
Represents a filter for a specific
Event
type.
The handler represents a "target" of the event. This can be used to create filters for all events of a specific type using information about the target.
For example, the target of a PlayerEvent
is a Player
so
you could create a player event filter which checks if the target player
is in creative mode.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final EventFilter
<Event, ?> static final EventFilter
<BlockEvent, Block> static final EventFilter
<EntityEvent, Entity> static final EventFilter
<InstanceEvent, Instance> static final EventFilter
<InventoryEvent, Inventory> static final EventFilter
<ItemEvent, ItemStack> static final EventFilter
<PlayerEvent, Player> -
Method Summary
Modifier and TypeMethodDescriptiondefault H
castHandler
(@NotNull Object event) The event type to filter on.static <E extends Event,
H>
EventFilter<E, H> from
(@NotNull Class<E> eventType, @Nullable Class<H> handlerType, @Nullable Function<E, H> handlerGetter) getHandler
(E event) Gets the handler for the given event instance, or null if the event type has no handler.The type returned bygetHandler(Event)
.
-
Field Details
-
ALL
-
ENTITY
-
PLAYER
-
ITEM
-
INSTANCE
-
INVENTORY
-
BLOCK
-
-
Method Details
-
from
static <E extends Event,H> EventFilter<E,H> from(@NotNull @NotNull Class<E> eventType, @Nullable @Nullable Class<H> handlerType, @Nullable @Nullable Function<E, H> handlerGetter) -
getHandler
Gets the handler for the given event instance, or null if the event type has no handler.- Parameters:
event
- The event instance- Returns:
- The handler, if it exists for the given event
-
castHandler
-
eventType
The event type to filter on.- Returns:
- The event type.
-
handlerType
The type returned bygetHandler(Event)
.- Returns:
- the handler type, null if not any
-