public interface ProtocolSubscriptionBuilder extends SubscriptionBuilder<com.comphenix.protocol.events.PacketEvent>
ProtocolSubscriptions.DEFAULT_EXCEPTION_CONSUMER| Modifier and Type | Method and Description |
|---|---|
default ProtocolSubscription |
biHandler(BiConsumer<ProtocolSubscription,? super com.comphenix.protocol.events.PacketEvent> handler)
Builds and registers the Handler.
|
ProtocolSubscriptionBuilder |
exceptionConsumer(BiConsumer<? super com.comphenix.protocol.events.PacketEvent,Throwable> consumer)
Sets the exception consumer for the handler.
|
default ProtocolSubscriptionBuilder |
expireAfter(long maxCalls)
Sets the number of calls until the handler will automatically be unregistered
|
default ProtocolSubscriptionBuilder |
expireAfter(long duration,
TimeUnit unit)
Sets the expiry time on the handler
|
ProtocolSubscriptionBuilder |
expireIf(BiPredicate<ProtocolSubscription,com.comphenix.protocol.events.PacketEvent> predicate,
ExpiryTestStage... testPoints)
Add a expiry predicate.
|
default ProtocolSubscriptionBuilder |
expireIf(Predicate<com.comphenix.protocol.events.PacketEvent> predicate)
Add a expiry predicate.
|
ProtocolSubscriptionBuilder |
filter(Predicate<com.comphenix.protocol.events.PacketEvent> predicate)
Adds a filter to the handler.
|
default ProtocolSubscription |
handler(Consumer<? super com.comphenix.protocol.events.PacketEvent> handler)
Builds and registers the Handler.
|
ProtocolHandlerList |
handlers()
Return the handler list builder to append handlers for the event.
|
static ProtocolSubscriptionBuilder |
newBuilder(com.comphenix.protocol.events.ListenerPriority priority,
com.comphenix.protocol.PacketType... packets)
Makes a HandlerBuilder for the given packets
|
static ProtocolSubscriptionBuilder |
newBuilder(com.comphenix.protocol.PacketType... packets)
Makes a HandlerBuilder for the given packets
|
@Nonnull static ProtocolSubscriptionBuilder newBuilder(@Nonnull com.comphenix.protocol.PacketType... packets)
packets - the packets to handleProtocolSubscriptionBuilder to construct the event handler@Nonnull static ProtocolSubscriptionBuilder newBuilder(@Nonnull com.comphenix.protocol.events.ListenerPriority priority, @Nonnull com.comphenix.protocol.PacketType... packets)
priority - the priority to listen atpackets - the packets to handleProtocolSubscriptionBuilder to construct the event handler@Nonnull default ProtocolSubscriptionBuilder expireIf(@Nonnull Predicate<com.comphenix.protocol.events.PacketEvent> predicate)
SubscriptionBuilderexpireIf in interface SubscriptionBuilder<com.comphenix.protocol.events.PacketEvent>predicate - the expiry test@Nonnull default ProtocolSubscriptionBuilder expireAfter(long duration, @Nonnull TimeUnit unit)
SubscriptionBuilderexpireAfter in interface SubscriptionBuilder<com.comphenix.protocol.events.PacketEvent>duration - the duration until expiryunit - the unit for the duration@Nonnull default ProtocolSubscriptionBuilder expireAfter(long maxCalls)
SubscriptionBuilderThe call counter is only incremented if the event call passes all filters and if the handler completes without throwing an exception.
expireAfter in interface SubscriptionBuilder<com.comphenix.protocol.events.PacketEvent>maxCalls - the number of times the handler will be called until being unregistered.@Nonnull ProtocolSubscriptionBuilder filter(@Nonnull Predicate<com.comphenix.protocol.events.PacketEvent> predicate)
SubscriptionBuilderAn event will only be handled if it passes all filters. Filters are evaluated in the order they are registered.
filter in interface SubscriptionBuilder<com.comphenix.protocol.events.PacketEvent>predicate - the filter@Nonnull ProtocolSubscriptionBuilder expireIf(@Nonnull BiPredicate<ProtocolSubscription,com.comphenix.protocol.events.PacketEvent> predicate, @Nonnull ExpiryTestStage... testPoints)
predicate - the expiry testtestPoints - when to test the expiry predicate@Nonnull ProtocolSubscriptionBuilder exceptionConsumer(@Nonnull BiConsumer<? super com.comphenix.protocol.events.PacketEvent,Throwable> consumer)
If an exception is thrown in the handler, it is passed to this consumer to be swallowed.
consumer - the consumerNullPointerException - if the consumer is null@Nonnull ProtocolHandlerList handlers()
@Nonnull default ProtocolSubscription handler(@Nonnull Consumer<? super com.comphenix.protocol.events.PacketEvent> handler)
handler - the consumer responsible for handling the event.ProtocolSubscription instance.NullPointerException - if the handler is null@Nonnull default ProtocolSubscription biHandler(@Nonnull BiConsumer<ProtocolSubscription,? super com.comphenix.protocol.events.PacketEvent> handler)
handler - the bi-consumer responsible for handling the event.ProtocolSubscription instance.NullPointerException - if the handler is nullCopyright © 2022. All rights reserved.