-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
457 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...upport/src/main/java/gg/xp/xivsupport/events/triggers/support/AnyPlayerStatusAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...upport/src/main/java/gg/xp/xivsupport/events/triggers/support/AnyPlayerStatusCallout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.