From acf4bc767ac016f34b54c3020cff00ebf82b886f Mon Sep 17 00:00:00 2001 From: TenFont Date: Thu, 5 Sep 2024 20:05:22 +0500 Subject: [PATCH 1/2] Return isNegated() instead of false if check is invalid --- src/main/java/ch/njol/skript/conditions/CondIsWithin.java | 4 ++-- src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk | 1 + 2 files changed, 3 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..ac4a463d464 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} From cd2c07821cd5098f475c43497f0490d9a2713e9c Mon Sep 17 00:00:00 2001 From: TenFont Date: Thu, 5 Sep 2024 20:22:32 +0500 Subject: [PATCH 2/2] Add test for <1.17 as well --- src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk b/src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk index ac4a463d464..757bfa49633 100644 --- a/src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk +++ b/src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk @@ -38,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}