Skip to content

Commit

Permalink
Properly check for UnparsedLiterals in Shuffle and Sort expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
FranKusmiruk committed Jul 11, 2018
1 parent cba6552 commit e521140
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.skript.registrations.Classes;
import ch.njol.skript.util.LiteralUtils;
import ch.njol.util.Kleenean;

@Name("Shuffled List")
Expand All @@ -56,8 +56,8 @@ public class ExprShuffledList extends SimpleExpression<Object> {
@SuppressWarnings({"null", "unchecked"})
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
list = (Expression<Object>) exprs[0];
return true;
list = LiteralUtils.defendExpression(exprs[0]);
return LiteralUtils.canInitSafely(list);
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/ch/njol/skript/expressions/ExprSortedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.skript.registrations.Classes;
import ch.njol.skript.util.LiteralUtils;
import ch.njol.util.Kleenean;

@Name("Sorted List")
Expand All @@ -57,8 +58,8 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
Skript.error("List of type " + Classes.toString(type) + " does not support sorting.");
return false;
}
list = (Expression<Object>) exprs[0];
return true;
list = LiteralUtils.defendExpression(exprs[0]);
return LiteralUtils.canInitSafely(list);
}

@Override
Expand Down

0 comments on commit e521140

Please sign in to comment.