Skip to content

Commit

Permalink
CAR and other stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
xpdota committed Dec 27, 2024
1 parent 0245d8d commit 406e7b3
Show file tree
Hide file tree
Showing 17 changed files with 580 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@
import gg.xp.reevent.scan.FeedHelperAdapter;
import gg.xp.reevent.scan.ScanMe;
import gg.xp.xivsupport.callouts.ModifiableCallout;
import gg.xp.xivsupport.callouts.RawModifiedCallout;
import gg.xp.xivsupport.events.actlines.events.BuffApplied;
import gg.xp.xivsupport.events.state.combatstate.CastTracker;
import gg.xp.xivsupport.events.state.combatstate.StatusEffectCurrentStatus;
import gg.xp.xivsupport.events.state.combatstate.StatusEffectRepository;

import java.util.Optional;

@ScanMe
public class PlayerStatusAdapter implements FeedHelperAdapter<PlayerStatusCallout, BuffApplied, ModifiableCallout<BuffApplied>> {

private final StatusEffectRepository buffs;

public PlayerStatusAdapter(StatusEffectRepository buffs) {
this.buffs = buffs;
}

@Override
public Class<BuffApplied> eventType() {
return BuffApplied.class;
Expand All @@ -19,6 +31,7 @@ public Class<BuffApplied> eventType() {
@Override
public TypedEventHandler<BuffApplied> makeHandler(FeedHandlerChildInfo<PlayerStatusCallout, ModifiableCallout<BuffApplied>> info) {
long[] castIds = info.getAnnotation().value();
PlayerStatusCallout ann = info.getAnnotation();
return new TypedEventHandler<>() {
@Override
public Class<? extends BuffApplied> getType() {
Expand All @@ -28,7 +41,14 @@ public Class<? extends BuffApplied> getType() {
@Override
public void handle(EventContext context, BuffApplied event) {
if (event.getTarget().isThePlayer() && event.buffIdMatches(castIds)) {
context.accept(info.getHandlerFieldValue().getModified(event));
RawModifiedCallout<BuffApplied> modified = info.getHandlerFieldValue().getModified(event);
if (ann.cancellable()) {
modified.addExpiryCondition(() -> {
StatusEffectCurrentStatus cs = buffs.statusOf(event);
return cs != StatusEffectCurrentStatus.ACTIVE;
});
}
context.accept(modified);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@
* @return Which status IDs to trigger on
*/
long[] value();

/**
* @return Whether the callout should be removed if the buff is removed. A buff being replaced/refreshed
* counts as being removed.
*/
boolean cancellable() default false;

}
Loading

0 comments on commit 406e7b3

Please sign in to comment.