Skip to content

Commit

Permalink
Fix Improperly Typed Array in ExprXOf (#7268)
Browse files Browse the repository at this point in the history
  • Loading branch information
APickledWalrus authored Dec 17, 2024
1 parent aa71764 commit 48f931a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/ch/njol/skript/expressions/ExprXOf.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;

import java.lang.reflect.Array;

@Name("X of Item")
@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.")
@Examples("give level of player of pickaxes to the player")
Expand All @@ -62,7 +64,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
protected Object[] get(Event e, Object[] source) {
Number a = amount.getSingle(e);
if (a == null)
return new Object[0];
return (Object[]) Array.newInstance(getReturnType(), 0);

return get(source, o -> {
if (o instanceof ItemStack) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test "null of x incorrect type":
# would cause an exception
spawn {_null} of pig above {_null}

0 comments on commit 48f931a

Please sign in to comment.