Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/main/java/ch/njol/skript/lang/Statement.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,23 @@ public abstract class Statement extends TriggerItem implements SyntaxElement {
var iterator = Skript.instance().syntaxRegistry().syntaxes(org.skriptlang.skript.registration.SyntaxRegistry.STATEMENT).iterator();
Section.SectionContext sectionContext = ParserInstance.get().getData(Section.SectionContext.class);
if (node != null) {
var wrappedIterator = new Iterator<>() {
@Override
public boolean hasNext() {
return iterator.hasNext();
}

@Override
public org.skriptlang.skript.registration.SyntaxInfo<? extends Statement> next() {
// it is possible that the section would have been claimed during the attempt to parse the previous info
// as a result, we need to "unclaim" it
sectionContext.owner = null;
return iterator.next();
}
};
statement = sectionContext.modify(node, items, () -> {
//noinspection unchecked,rawtypes
Statement parsed = (Statement) SkriptParser.parse(input, (Iterator) iterator, defaultError);
Statement parsed = (Statement) SkriptParser.parse(input, (Iterator) wrappedIterator, defaultError);
if (parsed != null && !sectionContext.claimed()) {
Skript.error("The line '" + input + "' is a valid statement but cannot function as a section (:) because there is no syntax in the line to manage it.");
return null;
Expand Down