Skip to content

Commit 0c7b077

Browse files
committed
ExpressionList - fix not being able to delete more than 1 var at a time
1 parent 826c262 commit 0c7b077

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/main/java/io/github/syst3ms/skriptparser/lang/ExpressionList.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.syst3ms.skriptparser.lang;
22

33
import io.github.syst3ms.skriptparser.parsing.ParseContext;
4+
import io.github.syst3ms.skriptparser.types.changers.ChangeMode;
45
import io.github.syst3ms.skriptparser.util.ClassUtils;
56
import org.jetbrains.annotations.Contract;
67
import org.jetbrains.annotations.Nullable;
@@ -209,4 +210,25 @@ public Expression<?> getSource() {
209210
return source != null ? source : this;
210211
}
211212

213+
@Override
214+
public Optional<Class<?>[]> acceptsChange(ChangeMode mode) {
215+
// Check if all expressions in the list accept this change mode
216+
for (var expr : expressions) {
217+
if (expr.acceptsChange(mode).isEmpty()) {
218+
return Optional.empty();
219+
}
220+
}
221+
// If all expressions accept the change, return the accepted types from the first expression
222+
// (assuming all expressions have compatible types)
223+
return expressions[0].acceptsChange(mode);
224+
}
225+
226+
@Override
227+
public void change(TriggerContext ctx, ChangeMode mode, Object[] changeWith) throws UnsupportedOperationException {
228+
// Apply the change to all expressions in the list
229+
for (var expr : expressions) {
230+
expr.change(ctx, mode, changeWith);
231+
}
232+
}
233+
212234
}

0 commit comments

Comments
 (0)