Package net.okocraft.box.api.util
Class SubscribedListenerHolder
java.lang.Object
net.okocraft.box.api.util.SubscribedListenerHolder
A utility class for holding
SubscribedListeners.
This can be used after BoxAPI is initialized.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(@NotNull SubscribedListener<net.kyori.adventure.key.Key, ? extends BoxEvent, Priority> listener) Adds aSubscribedListener.voidaddAll(@NotNull List<SubscribedListener<net.kyori.adventure.key.Key, ? extends BoxEvent, Priority>> listeners) Adds theSubscribedListeners.@NotNull @UnmodifiableView List<SubscribedListener<net.kyori.adventure.key.Key, ? extends BoxEvent, Priority>> Gets theSubscribedListeners this instance holds.voidsubscribeAll(@NotNull UnaryOperator<ListenerSubscriber.BulkSubscriber<net.kyori.adventure.key.Key, BoxEvent, Priority>> operator) Subscribes listeners toBoxAPI.getListenerSubscriber()usingListenerSubscriber.BulkSubscriberand holdsSubscribedListeners it returns.voidUnsubscribesSubscribedListeners this instance holds.
-
Constructor Details
-
SubscribedListenerHolder
public SubscribedListenerHolder()
-
-
Method Details
-
add
public void add(@NotNull @NotNull SubscribedListener<net.kyori.adventure.key.Key, ? extends BoxEvent, Priority> listener) Adds aSubscribedListener.- Parameters:
listener- aSubscribedListener
-
addAll
public void addAll(@NotNull @NotNull List<SubscribedListener<net.kyori.adventure.key.Key, ? extends BoxEvent, Priority>> listeners) Adds theSubscribedListeners.- Parameters:
listeners- theSubscribedListeners
-
getListeners
@Contract(pure=true) @NotNull public @NotNull @UnmodifiableView List<SubscribedListener<net.kyori.adventure.key.Key,? extends BoxEvent, getListeners()Priority>> Gets theSubscribedListeners this instance holds.- Returns:
- the
SubscribedListeners this instance holds
-
subscribeAll
public void subscribeAll(@NotNull @NotNull UnaryOperator<ListenerSubscriber.BulkSubscriber<net.kyori.adventure.key.Key, BoxEvent, Priority>> operator) Subscribes listeners toBoxAPI.getListenerSubscriber()usingListenerSubscriber.BulkSubscriberand holdsSubscribedListeners it returns.- Parameters:
operator- theUnaryOperatorto modifyListenerSubscriber.BulkSubscriber
-
unsubscribeAll
public void unsubscribeAll()UnsubscribesSubscribedListeners this instance holds.
-