Class EventSignalBuilder<T>
java.lang.Object
me.tamkungz.signals.velocity.event.EventSignalBuilder<T>
- Type Parameters:
T- Velocity event type
Fluent options (post order) for listening to one Velocity event type.
Pick the order, then either call signal() or connect a listener directly.
-
Constructor Summary
ConstructorsConstructorDescriptionEventSignalBuilder(EventSignalSource source, Class<T> eventType) Creates a builder; preferEventSignalSource.on(Class). -
Method Summary
Modifier and TypeMethodDescriptionme.tamkungz.signals.connection.ConnectionConnects a listener to the signal for the chosen order.me.tamkungz.signals.connection.ConnectionConnects a listener and tracks it in a group.me.tamkungz.signals.connection.ConnectionConnects a listener that only receives the events a predicate accepts.me.tamkungz.signals.connection.ConnectionconnectIf(me.tamkungz.signals.connection.ConnectionGroup group, Predicate<T> predicate, Consumer<T> listener) Connects a filtered listener and tracks it in a group.early()Same asorder(PostOrder.EARLY).first()Same asorder(PostOrder.FIRST).last()Same asorder(PostOrder.LAST).late()Same asorder(PostOrder.LATE).normal()Same asorder(PostOrder.NORMAL).me.tamkungz.signals.connection.ConnectionConnects a listener that is disconnected after its first event.me.tamkungz.signals.connection.ConnectionConnects a one-shot listener and tracks it in a group.order(com.velocitypowered.api.event.PostOrder order) Sets the order the underlying Velocity handler runs in; the default isPostOrder.NORMAL.me.tamkungz.signals.Signal<T> signal()Returns the signal for the chosen order, registering the Velocity handler on first use.
-
Constructor Details
-
EventSignalBuilder
Creates a builder; preferEventSignalSource.on(Class).- Parameters:
source- where the signal comes fromeventType- Velocity event type
-
-
Method Details
-
order
Sets the order the underlying Velocity handler runs in; the default isPostOrder.NORMAL.- Parameters:
order- Velocity post order- Returns:
- this builder
-
first
Same asorder(PostOrder.FIRST).- Returns:
- this builder
-
early
Same asorder(PostOrder.EARLY).- Returns:
- this builder
-
normal
Same asorder(PostOrder.NORMAL).- Returns:
- this builder
-
late
Same asorder(PostOrder.LATE).- Returns:
- this builder
-
last
Same asorder(PostOrder.LAST).- Returns:
- this builder
-
signal
Returns the signal for the chosen order, registering the Velocity handler on first use.- Returns:
- the signal for this event type and order
-
connect
Connects a listener to the signal for the chosen order.- Parameters:
listener- listener to call for every event- Returns:
- the connection for this listener
-
connect
public me.tamkungz.signals.connection.Connection connect(me.tamkungz.signals.connection.ConnectionGroup group, Consumer<T> listener) Connects a listener and tracks it in a group.- Parameters:
group- group that will disconnect the listenerlistener- listener to call for every event- Returns:
- the connection for this listener
-
connectIf
public me.tamkungz.signals.connection.Connection connectIf(Predicate<T> predicate, Consumer<T> listener) Connects a listener that only receives the events a predicate accepts.- Parameters:
predicate- decides which events reach the listenerlistener- listener to call for accepted events- Returns:
- the connection for this listener
-
connectIf
public me.tamkungz.signals.connection.Connection connectIf(me.tamkungz.signals.connection.ConnectionGroup group, Predicate<T> predicate, Consumer<T> listener) Connects a filtered listener and tracks it in a group.- Parameters:
group- group that will disconnect the listenerpredicate- decides which events reach the listenerlistener- listener to call for accepted events- Returns:
- the connection for this listener
-
once
Connects a listener that is disconnected after its first event.- Parameters:
listener- listener to call at most once- Returns:
- the connection for this listener
-
once
public me.tamkungz.signals.connection.Connection once(me.tamkungz.signals.connection.ConnectionGroup group, Consumer<T> listener) Connects a one-shot listener and tracks it in a group.- Parameters:
group- group that will disconnect the listenerlistener- listener to call at most once- Returns:
- the connection for this listener
-