@@ -111,7 +111,7 @@ public boolean init(Expression<?>[] exprs,
111111 * set {_uh oh} to true
112112 */
113113 SecConditional precedingConditional = getPrecedingConditional (triggerItems , null );
114- if (precedingConditional == null || !precedingConditional .multiline ) {
114+ if (precedingConditional == null || !precedingConditional .multiline || precedingConditional . type == ConditionalType . THEN ) {
115115 Skript .error ("'then' has to placed just after a multiline 'if' or 'else if' section" );
116116 return false ;
117117 }
@@ -123,8 +123,6 @@ public boolean init(Expression<?>[] exprs,
123123 Skript .error ("'else if' has to be placed just after another 'if' or 'else if' section" );
124124 } else if (type == ConditionalType .ELSE ) {
125125 Skript .error ("'else' has to be placed just after another 'if' or 'else if' section" );
126- } else if (type == ConditionalType .THEN ) {
127- Skript .error ("'then' has to placed just after a multiline 'if' or 'else if' section" );
128126 }
129127 return false ;
130128 }
@@ -386,27 +384,28 @@ private static List<SecConditional> getPrecedingConditionals(List<TriggerItem> t
386384 TriggerItem triggerItem = triggerItems .get (i );
387385 if (!(triggerItem instanceof SecConditional conditional ))
388386 break ;
389- if (conditional .type == ConditionalType .ELSE )
390- // if the conditional is an else, break because it belongs to a different condition and ends
391- // this one
392- break ;
393387 conditionals .add (conditional );
388+ if (conditional .type == ConditionalType .IF )
389+ // if the conditional is an if, break because it is the root of our conditional
390+ break ;
394391 }
395392 return conditionals ;
396393 }
397394
398- private static @ Nullable Kleenean getPrecedingShouldDelayAfter (List <TriggerItem > triggerItems ) {
395+ private @ Nullable Kleenean getPrecedingShouldDelayAfter (List <TriggerItem > triggerItems ) {
396+ if (this .type == ConditionalType .IF )
397+ // this is the head, meaning there is no preceding conditional
398+ return null ;
399399 // loop through the triggerItems in reverse order so that we find the most recent items first
400400 for (int i = triggerItems .size () - 1 ; i >= 0 ; i --) {
401401 TriggerItem triggerItem = triggerItems .get (i );
402- if (!(triggerItem instanceof SecConditional conditional ))
402+ if (!(triggerItem instanceof SecConditional precedingSecConditional ))
403403 break ;
404- if (conditional .type == ConditionalType .ELSE )
405- // if the conditional is an else, break because it belongs to a different condition and ends
406- // this one
404+ if (precedingSecConditional .shouldDelayAfter != null )
405+ return precedingSecConditional .shouldDelayAfter ;
406+ if (precedingSecConditional .type == ConditionalType .IF )
407+ // this is the head of the conditional, meaning the search failed
407408 break ;
408- if (conditional .shouldDelayAfter != null )
409- return conditional .shouldDelayAfter ;
410409 }
411410 return null ;
412411 }
0 commit comments