Class SequentialTrigger<X extends BaseEvent>
java.lang.Object
gg.xp.xivsupport.events.triggers.seq.SequentialTrigger<X>
- Type Parameters:
X
- The event type. Should usually just be 'BaseEvent'.
- All Implemented Interfaces:
EventHandler<X>
,TypedEventHandler<X>
"Sequential Triggers" allow for a sequence of events to be collected interactively within a block of code.
This massively simplifies the code for complex mechanic triggers, as the code for the entire sequence of events
can live in one sequential trigger, rather than needing multiple "collector" triggers and having the logic spread
out.
It also simplifies cleanup, since all of your state can be kept as local variables rather than class fields.
-
Constructor Summary
ConstructorDescriptionSequentialTrigger
(int timeoutMs, Class<X> type, Predicate<X> startOn, BiConsumer<X, SequentialTriggerController<X>> trigger) -
Method Summary
Modifier and TypeMethodDescriptionvoid
feed
(EventContext ctx, X event) Feed an event into the sequential triggervoid
getType()
void
handle
(EventContext context, X event) boolean
isActive()
setConcurrency
(SequentialTriggerConcurrencyMode concurrency) Sets the concurrency policy.void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface gg.xp.reevent.events.EventHandler
getOrder
-
Constructor Details
-
SequentialTrigger
public SequentialTrigger(int timeoutMs, Class<X> type, Predicate<X> startOn, BiConsumer<X, SequentialTriggerController<X>> trigger)
-
-
Method Details
-
feed
Feed an event into the sequential trigger- Parameters:
ctx
- The usual event contextevent
- The usual event
-
forceExpire
public void forceExpire() -
stopSilently
public void stopSilently() -
handle
- Specified by:
handle
in interfaceEventHandler<X extends BaseEvent>
-
getType
- Specified by:
getType
in interfaceTypedEventHandler<X extends BaseEvent>
-
isActive
public boolean isActive() -
setConcurrency
Sets the concurrency policy. SeeSequentialTriggerConcurrencyMode
. Should be set prior to any actual use of the trigger.- Parameters:
concurrency
- The new concurrency policy.- Returns:
- This (builder pattern)
- See Also:
-