Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codcar triggers, various improvements #573

Merged
merged 7 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public JailSolver(PersistenceProvider persistence, XivState state) {

@Override
public boolean enabled(EventContext context) {
// return true;
return overrideZoneLock.get() || context.getStateInfo().get(XivState.class).zoneIs(0x309L);
return overrideZoneLock.get() || state.dutyIs(KnownDuty.UWU);
}

@HandleEvents
Expand Down Expand Up @@ -145,8 +144,7 @@ public void jailedPlayerDied(EventContext context, EntityKilledEvent event) {
@HandleEvents
public void handleJailCast(EventContext context, AbilityUsedEvent event) {
// Check ability ID - we only care about these two
long id = event.getAbility().getId();
if (id != 0x2B6B && id != 0x2B6C) {
if (!event.abilityIdMatches(0x2B6B, 0x2B6C)) {
return;
}
XivCombatant target = event.getTarget();
Expand Down
Loading
Loading