Skip to content

Commit 48f931a

Browse files
Fix Improperly Typed Array in ExprXOf (#7268)
1 parent aa71764 commit 48f931a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/main/java/ch/njol/skript/expressions/ExprXOf.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import org.bukkit.inventory.ItemStack;
3737
import org.jetbrains.annotations.Nullable;
3838

39+
import java.lang.reflect.Array;
40+
3941
@Name("X of Item")
4042
@Description("An expression to be able to use a certain amount of items where the amount can be any expression. Please note that this expression is not stable and might be replaced in the future.")
4143
@Examples("give level of player of pickaxes to the player")
@@ -62,7 +64,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
6264
protected Object[] get(Event e, Object[] source) {
6365
Number a = amount.getSingle(e);
6466
if (a == null)
65-
return new Object[0];
67+
return (Object[]) Array.newInstance(getReturnType(), 0);
6668

6769
return get(source, o -> {
6870
if (o instanceof ItemStack) {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test "null of x incorrect type":
2+
# would cause an exception
3+
spawn {_null} of pig above {_null}

0 commit comments

Comments
 (0)