File tree Expand file tree Collapse file tree
src/main/java/com/abilityapi/sequenceapi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,24 +133,38 @@ public boolean applyAfter(final SequenceContext sequenceContext) {
133133
134134 final long current = System .currentTimeMillis ();
135135
136- if (!(this .lastTime + ((action .getDelay () / 20 ) * 1000 ) > current )) {
137- if (!action .apply (sequenceContext )) {
138- return this .fail (action , sequenceContext );
139- }
136+ // 1. Fail the action if it is being executed before the delay.
140137
141- this .index ++;
138+ if (this .lastTime + ((action .getDelay () / 20 ) * 1000 ) > current ) {
139+ return false ;
140+ }
142141
143- iterator . remove ();
142+ // 2. Fail the action if it being executed after the expire.
144143
145- if (! iterator . hasNext () ) {
146- if ( this .index == this . actionsSize ) this . state = State . FINISHED ;
147- }
144+ if ( this . lastTime + (( action . getExpire () / 20 ) * 1000 ) < current ) {
145+ return this .fail ( action , sequenceContext ) ;
146+ }
148147
149- return this .succeed (action , sequenceContext );
148+ // 3. Run the action conditions and fail if they do not pass.
149+
150+ if (!action .apply (sequenceContext )) {
151+ return this .fail (action , sequenceContext );
150152 }
153+
154+ // 4. Succeed the action, remove it, increment the index and set finish if there are no more actions left.
155+
156+ this .index ++;
157+
158+ iterator .remove ();
159+
160+ if (!iterator .hasNext ()) {
161+ if (this .index == this .actionsSize ) this .state = State .FINISHED ;
162+ }
163+
164+ return this .succeed (action , sequenceContext );
151165 }
152166
153- return false ;
167+ return true ;
154168 }
155169
156170 /**
You can’t perform that action at this time.
0 commit comments