Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AIOOB with ExprVectorXYZ when used with non-vectors #6387

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/java/ch/njol/skript/expressions/ExprVectorXYZ.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
public class ExprVectorXYZ extends SimplePropertyExpression<Vector, Number> {

static {
register(ExprVectorXYZ.class, Number.class, "[vector] (0¦x|1¦y|2¦z) [component[s]]", "vectors");
// TODO: Combine with ExprCoordinates for 2.9
register(ExprVectorXYZ.class, Number.class, "[vector] (0:x|1:y|2:z) [component[s]]", "vectors");
}

private final static Character[] axes = new Character[] {'x', 'y', 'z'};
Expand Down Expand Up @@ -84,6 +85,8 @@ public Class<?>[] acceptChange(ChangeMode mode) {
public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
assert delta != null;
Vector[] vectors = getExpr().getArray(event);
if (vectors.length == 0)
return;
double deltaValue = ((Number) delta[0]).doubleValue();
switch (mode) {
case REMOVE:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test "x component of block":
set {_a} to block at location(0, 0, 0)
add 1 to x of {_a} # should not throw exception
Loading