Skip to content

Commit df5ece0

Browse files
committed
ExprContextValue - fix not being to get
1 parent ee0fb18 commit df5ece0

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/main/java/io/github/syst3ms/skriptparser/expressions/ExprContextValue.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,13 @@ public T[] getValues(TriggerContext ctx) {
122122

123123
@Override
124124
public Optional<Class<?>[]> acceptsChange(ChangeMode mode) {
125-
if (mode == ChangeMode.SET && this.info.canBeSet()) return Optional.of(new Class<?>[]{getReturnType()});
125+
if (mode == ChangeMode.SET && this.info.canBeSet()) {
126+
if (this.info.getListSetterFunction() != null) {
127+
return Optional.of(new Class<?>[]{getReturnType().arrayType()});
128+
} else {
129+
return Optional.of(new Class<?>[]{getReturnType()});
130+
}
131+
}
126132
return Optional.empty();
127133
}
128134

@@ -134,7 +140,9 @@ public void change(TriggerContext ctx, ChangeMode changeMode, Object[] changeWit
134140
if (this.info.isSingle()) {
135141
this.info.getSingleSetterFunction().accept((C) ctx, (T) changeWith[0]);
136142
} else {
137-
this.info.getListSetterFunction().accept((C) ctx, (T[]) changeWith);
143+
T[] o = (T[])Array.newInstance(getReturnType(), changeWith.length);
144+
System.arraycopy(changeWith, 0, o, 0, changeWith.length);
145+
this.info.getListSetterFunction().accept((C) ctx, o);
138146
}
139147
}
140148

0 commit comments

Comments
 (0)