From 98013299019f9f7a32e3ab615e4a3a62ece4b95c Mon Sep 17 00:00:00 2001 From: TenFont <83959297+TenFont@users.noreply.github.com> Date: Sun, 22 Sep 2024 05:32:43 +0500 Subject: [PATCH] Return isNegative() and not false, if CondIsWithin is invalid (#7038) * Return isNegated() instead of false if check is invalid * Add test for <1.17 as well --------- Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> --- src/main/java/ch/njol/skript/conditions/CondIsWithin.java | 4 ++-- src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsWithin.java b/src/main/java/ch/njol/skript/conditions/CondIsWithin.java index e6b88ed710a..7ec25401ae8 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsWithin.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsWithin.java @@ -103,7 +103,7 @@ public boolean check(Event event) { Location one = loc1.getSingle(event); Location two = loc2.getSingle(event); if (one == null || two == null || one.getWorld() != two.getWorld()) - return false; + return isNegated(); AABB box = new AABB(one, two); return locsToCheck.check(event, box::contains, isNegated()); } @@ -111,7 +111,7 @@ public boolean check(Event event) { // else, within an entity/block/chunk/world Object area = this.area.getSingle(event); if (area == null) - return false; + return isNegated(); // Entities if (area instanceof Entity) { diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk b/src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk index b432c72f0ff..757bfa49633 100644 --- a/src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk +++ b/src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk @@ -4,6 +4,7 @@ test "within condition" when running minecraft "1.17": set {_loc2} to location(20, 20, 20, "world") assert location(10, 10, 10, "world") is within {_loc1} and {_loc2} with "failed within two locs" assert location(10, -10, 10, "world") is not within {_loc1} and {_loc2} with "failed within two locs" + assert location(0, 0, 0, "world") is not within {_none} and {_none} with "failed within two locs" # chunks set {_chunk1} to chunk at {_loc1} @@ -37,6 +38,7 @@ test "within condition" when running below minecraft "1.17": set {_loc2} to location(20, 20, 20, "world") assert location(10, 10, 10, "world") is within {_loc1} and {_loc2} with "failed within two locs" assert location(10, -10, 10, "world") is not within {_loc1} and {_loc2} with "failed within two locs" + assert location(0, 0, 0, "world") is not within {_none} and {_none} with "failed within two locs" # chunks set {_chunk1} to chunk at {_loc1}