Skip to content

Commit

Permalink
Fix spread not working with non-object targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Pikachu920 committed Oct 26, 2024
1 parent c476d16 commit 75e2e74
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/ch/njol/skript/effects/EffSpread.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionList;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.registrations.Classes;
import ch.njol.skript.registrations.DefaultClasses;
import ch.njol.skript.util.ClassInfoReference;
import ch.njol.skript.util.LiteralUtils;
Expand Down Expand Up @@ -53,9 +54,13 @@ public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean is
Skript.error("The spread target must be an 'and' list, not an 'or' list");
return false;
}
Expression<?> convertedObjectsToSpread = objectsToSpread.getConvertedExpression(spreadTarget.getReturnType());
if (convertedObjectsToSpread != null)
objectsToSpread = convertedObjectsToSpread;
ClassInfoReference spreadType = new ClassInfoReference(objectsToSpread.getReturnType(), Kleenean.FALSE);
if (!listChildrenCanBeSet(spreadTarget, spreadType)) {
Skript.error("All expressions in the spread target list must be settable");
String friendlySpreadType = Classes.toString(spreadType.getClassInfo());
Skript.error("All expressions in the spread target list must be settable to at least one " + friendlySpreadType);
return false;
}
return LiteralUtils.canInitSafely(objectsToSpread, spreadTarget);
Expand Down

0 comments on commit 75e2e74

Please sign in to comment.