Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
erenkarakal committed Feb 28, 2025
1 parent 37e5309 commit d66ed03
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/ch/njol/skript/effects/EffParse.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,30 +78,32 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
@SuppressWarnings("unchecked")
protected void execute(Event event) {
Parser<?> parser = classInfo.getParser();
assert parser != null;
assert parser != null; // checked in init()
ExprParseError.clearErrors();

ParseLogHandler parseLogHandler = new ParseLogHandler().start();
try {
if (toParse instanceof ExpressionList<String> toParseExpressions) {
for (int i = 0; i < toParseExpressions.getAllExpressions().size(); i++) {
Expression<String> expression = (Expression<String>) toParseExpressions.getAllExpressions().get(i);
expression.changeInPlace(event, (stringToParse) -> {
expression.changeInPlace(event, stringToParse -> {
Object parsed = parser.parse(stringToParse, ParseContext.PARSE);
if (parsed == null) {
ExprParseError.addError(stringToParse + " could not be parsed as " + classInfo.getName().withIndefiniteArticle());
parseLogHandler.clearError();
return tryTo ? stringToParse : null;
}
return tryTo ? stringToParse : parsed;
return parsed;
});
}
} else {
toParse.changeInPlace(event, (stringToParse) -> {
toParse.changeInPlace(event, stringToParse -> {
Object parsed = parser.parse(stringToParse, ParseContext.PARSE);
if (parsed == null) {
ExprParseError.addError(stringToParse + " could not be parsed as " + classInfo.getName().withIndefiniteArticle());
return tryTo ? stringToParse : null;
}
return tryTo ? stringToParse : parsed;
return parsed;
});
}
} finally {
Expand Down

0 comments on commit d66ed03

Please sign in to comment.