Skip to content

Commit

Permalink
ExprSets - fix return issue (#7327)
Browse files Browse the repository at this point in the history
* ExprSets - fix return issue

* 7327 - add regression test

* ExprSets - get rid of ArrayList, eww

---------

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
  • Loading branch information
ShaneBeee and Efnilite authored Dec 30, 2024
1 parent 48d0bbe commit b78db1d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/ch/njol/skript/expressions/ExprSets.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ch.njol.skript.expressions;

import java.lang.reflect.Array;
import java.util.Iterator;
import java.util.List;
import java.util.function.Supplier;

import org.bukkit.event.Event;
Expand Down Expand Up @@ -61,8 +63,8 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye

@Override
protected Object[] get(Event event) {
Iterator<?> iterator = supplier.get();
return Lists.newArrayList(iterator).toArray(new Object[0]);
List<?> objects = Lists.newArrayList(supplier.get());
return objects.toArray((Object[]) Array.newInstance(classInfo.getC(), objects.size()));
}

@Override
Expand Down
10 changes: 10 additions & 0 deletions src/test/skript/tests/regressions/7327-expr-sets-return.sk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
test "ExprSets class return failure":

set {_i} to diamond sword with item flag all item flags
assert {_i} is set with "Item with all item flags should be set"

set {_i::*} to 1 of all itemtypes
assert {_i::*} is set with "X of set of all itemtypes should be set"

# You're a lone wolf, Just want to make sure you don't error
set custom model data of all itemtypes to 10

0 comments on commit b78db1d

Please sign in to comment.