Skip to content

Commit f318442

Browse files
authored
Fix Section parsing NPE (#4353)
1 parent 13dd0f1 commit f318442

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/main/java/ch/njol/skript/lang/EffectSection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
5656
SectionContext sectionContext = getParser().getData(SectionContext.class);
5757
//noinspection ConstantConditions - For an EffectSection, it may be null
5858
hasSection = sectionContext.sectionNode != null;
59-
return init(exprs, matchedPattern, isDelayed, parseResult, sectionContext.sectionNode, sectionContext.triggerItems);
59+
60+
return super.init(exprs, matchedPattern, isDelayed, parseResult);
6061
}
6162

6263
@Override

src/main/java/ch/njol/skript/lang/Section.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,17 @@ public abstract class Section extends TriggerSection implements SyntaxElement {
6565
@Override
6666
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
6767
SectionContext sectionContext = getParser().getData(SectionContext.class);
68-
return init(exprs, matchedPattern, isDelayed, parseResult, sectionContext.sectionNode, sectionContext.triggerItems);
68+
SectionNode sectionNode = sectionContext.sectionNode;
69+
List<TriggerItem> triggerItems = sectionContext.triggerItems;
70+
71+
boolean result = init(exprs, matchedPattern, isDelayed, parseResult, sectionNode, triggerItems);
72+
73+
// Revert any possible changes to the SectionContext caused by the init method,
74+
// see https://github.com/SkriptLang/Skript/pull/4353
75+
sectionContext.sectionNode = sectionNode;
76+
sectionContext.triggerItems = triggerItems;
77+
78+
return result;
6979
}
7080

7181
public abstract boolean init(Expression<?>[] exprs,

0 commit comments

Comments
 (0)