Skip to content

Commit

Permalink
EX1 triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
xpdota committed Jul 6, 2024
1 parent 27138cd commit ee66ece
Show file tree
Hide file tree
Showing 6 changed files with 457 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public <P extends Predicate<? super Y>, Y> Map<P, List<Y>> groupEvents(int limit
* @param limit Number of events
* @param timeoutMs Timeout in ms to wait for events
* @param eventClass Class of event
* @param exclusive false if you would like an event to be allowed to match multiple filters, rather than movingn
* @param exclusive false if you would like an event to be allowed to match multiple filters, rather than moving
* on to the next event after a single match.
* @param collectors The list of collectors.
* @param <Y> The type of event.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package gg.xp.xivsupport.events.triggers.support;

import gg.xp.reevent.events.EventContext;
import gg.xp.reevent.events.TypedEventHandler;
import gg.xp.reevent.scan.FeedHandlerChildInfo;
import gg.xp.reevent.scan.FeedHelperAdapter;
import gg.xp.reevent.scan.ScanMe;
import gg.xp.xivsupport.callouts.ModifiableCallout;
import gg.xp.xivsupport.events.actlines.events.BuffApplied;
import gg.xp.xivsupport.events.triggers.util.RepeatSuppressor;

import java.time.Duration;

@ScanMe
public class AnyPlayerStatusAdapter implements FeedHelperAdapter<AnyPlayerStatusCallout, BuffApplied, ModifiableCallout<BuffApplied>> {

@Override
public Class<BuffApplied> eventType() {
return BuffApplied.class;
}

@Override
public TypedEventHandler<BuffApplied> makeHandler(FeedHandlerChildInfo<AnyPlayerStatusCallout, ModifiableCallout<BuffApplied>> info) {
long[] castIds = info.getAnnotation().value();
long suppMs = info.getAnnotation().suppressMs();
RepeatSuppressor supp;
if (suppMs >= 0) {
supp = new RepeatSuppressor(Duration.ofMillis(suppMs));
}
else {
supp = RepeatSuppressor.noOp();
}
return new TypedEventHandler<>() {
@Override
public Class<? extends BuffApplied> getType() {
return BuffApplied.class;
}

@Override
public void handle(EventContext context, BuffApplied event) {
if (event.buffIdMatches(castIds)) {
if (supp.check(event)) {
context.accept(info.getHandlerFieldValue().getModified(event));
}
}
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package gg.xp.xivsupport.events.triggers.support;

import gg.xp.reevent.scan.FeedHelper;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
* Callout adapter for local player gaining a buff
*/
@FeedHelper(PlayerStatusAdapter.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface AnyPlayerStatusCallout {
/**
* @return Which status IDs to trigger on
*/
long[] value();

long suppressMs() default 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public Class<? extends BuffApplied> getType() {
public void handle(EventContext context, BuffApplied event) {
if (event.getTarget().isThePlayer() && event.buffIdMatches(castIds)) {
context.accept(info.getHandlerFieldValue().getModified(event));
return;
}
}
};
Expand Down
Loading

0 comments on commit ee66ece

Please sign in to comment.