Package net.okocraft.box.api.util
Class SubscribedListenerHolder
java.lang.Object
net.okocraft.box.api.util.SubscribedListenerHolder
A utility class for holding
SubscribedListener
s.
This can be used after BoxAPI
is initialized.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(@NotNull SubscribedListener<net.kyori.adventure.key.Key, ? extends BoxEvent, Priority> listener) Adds aSubscribedListener
.void
addAll
(@NotNull List<SubscribedListener<net.kyori.adventure.key.Key, ? extends BoxEvent, Priority>> listeners) Adds theSubscribedListener
s.@NotNull @UnmodifiableView List
<SubscribedListener<net.kyori.adventure.key.Key, ? extends BoxEvent, Priority>> Gets theSubscribedListener
s this instance holds.void
subscribeAll
(@NotNull UnaryOperator<ListenerSubscriber.BulkSubscriber<net.kyori.adventure.key.Key, BoxEvent, Priority>> operator) Subscribes listeners toBoxAPI.getListenerSubscriber()
usingListenerSubscriber.BulkSubscriber
and holdsSubscribedListener
s it returns.void
UnsubscribesSubscribedListener
s 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 theSubscribedListener
s.- Parameters:
listeners
- theSubscribedListener
s
-
getListeners
@Contract(pure=true) @NotNull public @NotNull @UnmodifiableView List<SubscribedListener<net.kyori.adventure.key.Key,? extends BoxEvent, getListeners()Priority>> Gets theSubscribedListener
s this instance holds.- Returns:
- the
SubscribedListener
s 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.BulkSubscriber
and holdsSubscribedListener
s it returns.- Parameters:
operator
- theUnaryOperator
to modifyListenerSubscriber.BulkSubscriber
-
unsubscribeAll
public void unsubscribeAll()UnsubscribesSubscribedListener
s this instance holds.
-