Skip to content
Merged
Show file tree
Hide file tree
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: 9 additions & 7 deletions src/main/java/ch/njol/skript/ScriptLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ public static ArrayList<TriggerItem> loadItems(SectionNode node) {
if (!SkriptParser.validateLine(expr))
continue;

TriggerItem item;
TriggerItem item = null;
if (subNode instanceof SimpleNode) {
long start = System.currentTimeMillis();
item = Statement.parse(expr, items, "Can't understand this condition/effect: " + expr);
Expand All @@ -982,21 +982,21 @@ public static ArrayList<TriggerItem> loadItems(SectionNode node) {
Skript.debug(SkriptColor.replaceColorChar(parser.getIndentation() + item.toString(null, true)));

items.add(item);
} else if (subNode instanceof SectionNode) {
} else if (subNode instanceof SectionNode subSection) {
TypeHints.enterScope(); // Begin conditional type hints

RetainingLogHandler handler = SkriptLogger.startRetainingLog();
find_section:
try {
item = Section.parse(expr, "Can't understand this section: " + expr, (SectionNode) subNode, items);
item = Section.parse(expr, "Can't understand this section: " + expr, subSection, items);
if (item != null)
break find_section;

// back up the failure log
RetainingLogHandler backup = handler.backup();
handler.clear();

item = Statement.parse(expr, "Can't understand this condition/effect: " + expr, (SectionNode) subNode, items);
item = Statement.parse(expr, "Can't understand this condition/effect: " + expr, subSection, items);

if (item != null)
break find_section;
Expand All @@ -1013,12 +1013,14 @@ public static ArrayList<TriggerItem> loadItems(SectionNode node) {
}
continue;
} finally {
RetainingLogHandler afterParse = handler.backup();
handler.clear();
handler.printLog();
if (item != null && (Skript.debug() || subNode.debug()))
Skript.debug(SkriptColor.replaceColorChar(parser.getIndentation() + item.toString(null, true)));
afterParse.printLog();
Comment thread
Absolutionism marked this conversation as resolved.
}

if (Skript.debug() || subNode.debug())
Skript.debug(SkriptColor.replaceColorChar(parser.getIndentation() + item.toString(null, true)));

items.add(item);

// Destroy these conditional type hints
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/ch/njol/skript/sections/SecConditional.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import ch.njol.skript.patterns.PatternCompiler;
import ch.njol.skript.patterns.SkriptPattern;
import ch.njol.skript.util.Patterns;
import ch.njol.skript.util.SkriptColor;
import ch.njol.util.Kleenean;
import com.google.common.collect.Iterables;
import org.bukkit.event.Event;
Expand Down Expand Up @@ -203,6 +204,17 @@ public boolean init(Expression<?>[] exprs,
if (conditionals.isEmpty())
return false;

/*
This allows the embedded multilined conditions to be properly debugged.
Debugs are caught within the RetainingLogHandler in ScriptLoader#loadItems
Which will be printed after the debugged section (e.g 'if all')
*/
if ((Skript.debug() || sectionNode.debug()) && conditionals.size() > 1) {
String indentation = getParser().getIndentation() + " ";
Comment thread
Absolutionism marked this conversation as resolved.
for (Conditional<?> condition : conditionals)
Skript.debug(indentation + SkriptColor.replaceColorChar(condition.toString(null, true)));
Comment thread
Absolutionism marked this conversation as resolved.
}

conditional = Conditional.compound(ifAny ? Operator.OR : Operator.AND, conditionals);
}

Expand Down