Skip to content

Commit

Permalink
Revert "Implement changes from SkriptLang/Skript#4175"
Browse files Browse the repository at this point in the history
This reverts commit efe23dd.
  • Loading branch information
harryirl committed May 26, 2022
1 parent 3e83cb4 commit 8182a65
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions src/main/java/ch/njol/skript/sections/SecConditional.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public boolean init(Expression<?>[] exprs,

// Change event if using 'parse if'
if (parseIf) {
//noinspection unchecked
parser.setCurrentEvents(new Class[]{SkriptParseEvent.class});
parser.setCurrentEventName("parse");
parser.setCurrentSkriptEvent(null);
Expand Down Expand Up @@ -126,8 +125,8 @@ public boolean init(Expression<?>[] exprs,
if (type == ConditionalType.ELSE) {
// In an else section, ...
if (hasDelayAfter.isTrue()
&& lastIf.hasDelayAfter.isTrue()
&& getElseIfs(triggerItems).stream().map(SecConditional::getHasDelayAfter).allMatch(Kleenean::isTrue)) {
&& lastIf.hasDelayAfter.isTrue()
&& getElseIfs(triggerItems).stream().map(SecConditional::getHasDelayAfter).allMatch(Kleenean::isTrue)) {
// ... if the if section, all else-if sections and the else section have definite delays,
// mark delayed as TRUE.
getParser().setHasDelayBefore(Kleenean.TRUE);
Expand All @@ -146,39 +145,25 @@ && getElseIfs(triggerItems).stream().map(SecConditional::getHasDelayAfter).allMa
return true;
}

@Override
@Nullable
public TriggerItem getNext() {
return getSkippedNext();
}

@Nullable
public TriggerItem getNormalNext() {
return super.getNext();
}

@Nullable
@Override
protected TriggerItem walk(Event e) {
if (parseIf && !parseIfPassed) {
return getNormalNext();
return getNext();
} else if (type == ConditionalType.ELSE || parseIf || condition.check(e)) {
TriggerItem skippedNext = getSkippedNext();
setNext(skippedNext);

if (last != null)
last.setNext(skippedNext);
return first != null ? first : skippedNext;
last.setNext(getSkippedNext());
return first != null ? first : getSkippedNext();
} else {
return getNormalNext();
return getNext();
}
}

@Nullable
private TriggerItem getSkippedNext() {
TriggerItem next = getNormalNext();
TriggerItem next = getNext();
while (next instanceof SecConditional && ((SecConditional) next).type != ConditionalType.IF)
next = ((SecConditional) next).getNormalNext();
next = next.getNext();
return next;
}

Expand Down

0 comments on commit 8182a65

Please sign in to comment.