Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderscoreTud committed Aug 11, 2024
1 parent ff6c45b commit a091a6c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/ch/njol/skript/sections/SecConditional.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,27 @@ public boolean init(Expression<?>[] exprs,
if (!multiline || type == ConditionalType.THEN)
loadCode(sectionNode);

// Get the execution intent of the entire conditional chain.
if (type == ConditionalType.ELSE) {
List<SecConditional> conditionals = getPrecedingConditionals(triggerItems);
conditionals.add(0, this);
for (SecConditional conditional : conditionals) {
// Continue if the current conditional doesn't have executable code (the 'if' section of a multiline).
if (conditional.multiline && conditional.type != ConditionalType.THEN)
continue;

// If the current conditional doesn't have an execution intent,
// then there is a possibility of the chain not stopping the execution.
// Therefore, we can't assume anything about the intention of the chain,
// so we just set it to null and break out of the loop.
ExecutionIntent triggerIntent = conditional.triggerExecutionIntent();
if (triggerIntent == null) {
executionIntent = null;
break;
}

// If the current trigger's execution intent has a lower value than the chain's execution intent,
// then set the chain's intent to the trigger's
if (executionIntent == null || triggerIntent.compareTo(executionIntent) < 0)
executionIntent = triggerIntent;
}
Expand Down

0 comments on commit a091a6c

Please sign in to comment.