From c48c195a3ad1251496016f912d83b11dc1673ea5 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Sat, 21 Sep 2024 08:25:30 -0400 Subject: [PATCH 01/17] Create CondIsDivisibleBy.java --- .../skript/conditions/CondIsDivisibleBy.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java new file mode 100644 index 00000000000..fdbb50ba0e4 --- /dev/null +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -0,0 +1,54 @@ +package ch.njol.skript.conditions; + +import ch.njol.skript.Skript; +import ch.njol.skript.lang.Condition; +import ch.njol.skript.lang.Expression; +import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Kleenean; +import org.bukkit.event.Event; +import org.jetbrains.annotations.Nullable; + +public class CondIsDivisibleBy extends Condition { + + static { + Skript.registerCondition(CondIsDivisibleBy.class, + "%number% is divisible by %number%", + "%number% can be divisible by %number%"); + } + + @SuppressWarnings("null") + private Expression num1; + @SuppressWarnings("null") + private Expression num2; + + @Override + public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { + num1 = (Expression) exprs[0]; + num2 = (Expression) exprs[1]; + return true; + } + + @Override + public boolean check(Event event) { + Number number1 = num1.getSingle(event); + Number number2 = num2.getSingle(event); + + if (number1 == null || number2 == null) { + return false; // Prevent NullPointerException + } + + double divisor = number2.doubleValue(); + + if (divisor == 0) { + return false; // Avoid division by zero + } + + return number1.doubleValue() % divisor == 0; + } + + @Override + public String toString(@Nullable Event event, boolean debug) { + return "is divisible by " + num1.toString(event, debug) + num2.toString(event, debug); + } + +} From 8afc2a543dd4db04e3bb8fb36907c1dcc242917c Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Sat, 21 Sep 2024 08:44:06 -0400 Subject: [PATCH 02/17] requested changes + adds tests --- .../njol/skript/conditions/CondIsDivisibleBy.java | 13 ++++++++++--- .../tests/syntaxes/conditions/CondIsDivisibleBy.sk | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index fdbb50ba0e4..0ec53e92135 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -1,6 +1,10 @@ package ch.njol.skript.conditions; import ch.njol.skript.Skript; +import ch.njol.skript.doc.Description; +import ch.njol.skript.doc.Examples; +import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.Since; import ch.njol.skript.lang.Condition; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; @@ -8,12 +12,15 @@ import org.bukkit.event.Event; import org.jetbrains.annotations.Nullable; +@Name("Divisible By") +@Description("Check if a number is divisible by another number.") +@Examples("5 is divisible by 5") +@Since("INSERT VERSION") public class CondIsDivisibleBy extends Condition { static { Skript.registerCondition(CondIsDivisibleBy.class, - "%number% is divisible by %number%", - "%number% can be divisible by %number%"); + "%number% (is|can be) (divisible|divided) by %number%"); } @SuppressWarnings("null") @@ -48,7 +55,7 @@ public boolean check(Event event) { @Override public String toString(@Nullable Event event, boolean debug) { - return "is divisible by " + num1.toString(event, debug) + num2.toString(event, debug); + return num1.toString(event, debug) + " is divisible by " + num2.toString(event, debug); } } diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk new file mode 100644 index 00000000000..010e27f956e --- /dev/null +++ b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk @@ -0,0 +1,3 @@ +test "is divisible": + assert 5 can be divided by 5 with "5 can be divided by 5!" + assert 5 can be divided by 10 to fail with "5 cannot be divided by 10!" \ No newline at end of file From 6c641134ef0e318b0129a12886aac31bf35937d7 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Sat, 21 Sep 2024 09:05:47 -0400 Subject: [PATCH 03/17] requested changes --- .../java/ch/njol/skript/conditions/CondIsDivisibleBy.java | 8 ++++++-- .../skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index 0ec53e92135..e8835763d62 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -14,13 +14,17 @@ @Name("Divisible By") @Description("Check if a number is divisible by another number.") -@Examples("5 is divisible by 5") +@Examples({"if 5 is divisible by 5:", + "if 1964903306 is divisible by 982451653:", + "if 11 cannot be divided by 10:", + "if 10007 cannnot be divided by 10007:"}) @Since("INSERT VERSION") public class CondIsDivisibleBy extends Condition { static { Skript.registerCondition(CondIsDivisibleBy.class, - "%number% (is|can be) (divisible|divided) by %number%"); + "%number% (is|can be) (divisible|divided) by %number%", + "%number% (isn't|is not|can[ ]not be) (divisible|divided) by %number%"); } @SuppressWarnings("null") diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk index 010e27f956e..97b72087fd9 100644 --- a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk +++ b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk @@ -1,3 +1,7 @@ test "is divisible": assert 5 can be divided by 5 with "5 can be divided by 5!" - assert 5 can be divided by 10 to fail with "5 cannot be divided by 10!" \ No newline at end of file + assert 5 can not be divided by 10 to fail with "5 cannot be divided by 10!" + assert 5 isn't divisible by 0 to fail with "nothing can be divided by 0!" + assert 1964903306 is divisible by 982451653 with "1964903306 is divisible by 982451653!" + set {_none} to ("" parsed as int) + assert {_none} is divisible by 10 to fail with "you cannot divide by !" From c4a981f1a26a5ed7337afb1b77048b04443138a3 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Sat, 21 Sep 2024 12:25:21 -0400 Subject: [PATCH 04/17] requested changes --- .../skript/conditions/CondIsDivisibleBy.java | 31 +++++++++---------- .../syntaxes/conditions/CondIsDivisibleBy.sk | 4 +-- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index e8835763d62..de03ec71cea 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -8,6 +8,7 @@ import ch.njol.skript.lang.Condition; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; +import ch.njol.util.Checker; import ch.njol.util.Kleenean; import org.bukkit.event.Event; import org.jetbrains.annotations.Nullable; @@ -23,8 +24,10 @@ public class CondIsDivisibleBy extends Condition { static { Skript.registerCondition(CondIsDivisibleBy.class, - "%number% (is|can be) (divisible|divided) by %number%", - "%number% (isn't|is not|can[ ]not be) (divisible|divided) by %number%"); + "%numbers% (is|are) divisible by %number%", + "%numbers% (isn't|is not|aren't|are not) divisible by %number%", + "%numbers% can be [evenly] divided by %number%", + "%numbers% (can't|cannot|can not) be [evenly] divided by %number%"); } @SuppressWarnings("null") @@ -36,25 +39,21 @@ public class CondIsDivisibleBy extends Condition { public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { num1 = (Expression) exprs[0]; num2 = (Expression) exprs[1]; + setNegated(matchedPattern == 1 || matchedPattern == 3); return true; } @Override - public boolean check(Event event) { - Number number1 = num1.getSingle(event); + public boolean check(final Event event) { Number number2 = num2.getSingle(event); - - if (number1 == null || number2 == null) { - return false; // Prevent NullPointerException - } - - double divisor = number2.doubleValue(); - - if (divisor == 0) { - return false; // Avoid division by zero - } - - return number1.doubleValue() % divisor == 0; + return num1.check(event, new Checker() { + @Override + public boolean check(Number number1) { + double divided = number1.doubleValue(); + double divisor = number2 != null ? number2.doubleValue() : 0; + return divided % divisor == 0; + } + }, isNegated()); } @Override diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk index 97b72087fd9..eab23611f5a 100644 --- a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk +++ b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk @@ -1,7 +1,7 @@ test "is divisible": assert 5 can be divided by 5 with "5 can be divided by 5!" - assert 5 can not be divided by 10 to fail with "5 cannot be divided by 10!" - assert 5 isn't divisible by 0 to fail with "nothing can be divided by 0!" + assert 5 can not be divided by 10 with "5 cannot be divided by 10!" + assert 5 isn't divisible by 0 with "nothing can be divided by 0!" assert 1964903306 is divisible by 982451653 with "1964903306 is divisible by 982451653!" set {_none} to ("" parsed as int) assert {_none} is divisible by 10 to fail with "you cannot divide by !" From 3b678fff50bc1220e77cc385e138dfd76d5af7d5 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Sat, 21 Sep 2024 16:35:36 -0400 Subject: [PATCH 05/17] requested changes --- .../skript/conditions/CondIsDivisibleBy.java | 20 +++++++++---------- .../syntaxes/conditions/CondIsDivisibleBy.sk | 1 - 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index de03ec71cea..61168d4763a 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -31,26 +31,26 @@ public class CondIsDivisibleBy extends Condition { } @SuppressWarnings("null") - private Expression num1; + private Expression divisorExpression; @SuppressWarnings("null") - private Expression num2; + private Expression dividedExpression; @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { - num1 = (Expression) exprs[0]; - num2 = (Expression) exprs[1]; + divisorExpression = (Expression) exprs[0]; + dividedExpression = (Expression) exprs[1]; setNegated(matchedPattern == 1 || matchedPattern == 3); return true; } @Override public boolean check(final Event event) { - Number number2 = num2.getSingle(event); - return num1.check(event, new Checker() { + Number number2 = dividedExpression.getSingle(event); + return divisorExpression.check(event, new Checker() { @Override - public boolean check(Number number1) { - double divided = number1.doubleValue(); - double divisor = number2 != null ? number2.doubleValue() : 0; + public boolean check(Number number) { + double divided = number.doubleValue(); + double divisor = number2 != null ? number2.doubleValue() : null; return divided % divisor == 0; } }, isNegated()); @@ -58,7 +58,7 @@ public boolean check(Number number1) { @Override public String toString(@Nullable Event event, boolean debug) { - return num1.toString(event, debug) + " is divisible by " + num2.toString(event, debug); + return divisorExpression.toString(event, debug) + " is divisible by " + dividedExpression.toString(event, debug); } } diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk index eab23611f5a..db10ee4dc93 100644 --- a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk +++ b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk @@ -3,5 +3,4 @@ test "is divisible": assert 5 can not be divided by 10 with "5 cannot be divided by 10!" assert 5 isn't divisible by 0 with "nothing can be divided by 0!" assert 1964903306 is divisible by 982451653 with "1964903306 is divisible by 982451653!" - set {_none} to ("" parsed as int) assert {_none} is divisible by 10 to fail with "you cannot divide by !" From 2b8f53c8a27a31853be5f21a8738f9cc380b06ac Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Sat, 21 Sep 2024 16:44:35 -0400 Subject: [PATCH 06/17] Update CondIsDivisibleBy.java --- .../ch/njol/skript/conditions/CondIsDivisibleBy.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index 61168d4763a..cd9858ef32e 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -15,10 +15,10 @@ @Name("Divisible By") @Description("Check if a number is divisible by another number.") -@Examples({"if 5 is divisible by 5:", - "if 1964903306 is divisible by 982451653:", - "if 11 cannot be divided by 10:", - "if 10007 cannnot be divided by 10007:"}) +@Examples({ + "if 5 is divisible by 5:", + "if 11 cannot be divided by 10:", +}) @Since("INSERT VERSION") public class CondIsDivisibleBy extends Condition { @@ -44,7 +44,7 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye } @Override - public boolean check(final Event event) { + public boolean check(Event event) { Number number2 = dividedExpression.getSingle(event); return divisorExpression.check(event, new Checker() { @Override From 0fbf3b3a6b9dca139d9321dcdd93bb5c512c557c Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Sat, 21 Sep 2024 17:46:34 -0400 Subject: [PATCH 07/17] requested changes --- .../java/ch/njol/skript/conditions/CondIsDivisibleBy.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index cd9858ef32e..5145ef347ea 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -45,12 +45,12 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye @Override public boolean check(Event event) { - Number number2 = dividedExpression.getSingle(event); + Number divisorNumber = dividedExpression.getSingle(event); return divisorExpression.check(event, new Checker() { @Override - public boolean check(Number number) { - double divided = number.doubleValue(); - double divisor = number2 != null ? number2.doubleValue() : null; + public boolean check(Number dividedNumber) { + double divided = dividedNumber.doubleValue(); + double divisor = divisorNumber != null ? divisorNumber.doubleValue() : null; return divided % divisor == 0; } }, isNegated()); From 4876fd9b1d767f5b6d3990c5303a4a0ecb5d3776 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Sat, 21 Sep 2024 22:24:42 -0400 Subject: [PATCH 08/17] requested changes --- src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index 5145ef347ea..cdee76e5d28 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -26,7 +26,7 @@ public class CondIsDivisibleBy extends Condition { Skript.registerCondition(CondIsDivisibleBy.class, "%numbers% (is|are) divisible by %number%", "%numbers% (isn't|is not|aren't|are not) divisible by %number%", - "%numbers% can be [evenly] divided by %number%", + "%numbers% can be evenly divided by %number%", "%numbers% (can't|cannot|can not) be [evenly] divided by %number%"); } From e5ae6f275d32507d41ca62c60b1a0de77f16c831 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:17:38 -0400 Subject: [PATCH 09/17] requested changes + oops --- .../ch/njol/skript/conditions/CondIsDivisibleBy.java | 10 +++++----- .../tests/syntaxes/conditions/CondIsDivisibleBy.sk | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index cdee76e5d28..6ef59842014 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -27,25 +27,25 @@ public class CondIsDivisibleBy extends Condition { "%numbers% (is|are) divisible by %number%", "%numbers% (isn't|is not|aren't|are not) divisible by %number%", "%numbers% can be evenly divided by %number%", - "%numbers% (can't|cannot|can not) be [evenly] divided by %number%"); + "%numbers% (can't|cannot|can not) be evenly divided by %number%"); } @SuppressWarnings("null") private Expression divisorExpression; @SuppressWarnings("null") - private Expression dividedExpression; + private Expression dividendExpression; @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { divisorExpression = (Expression) exprs[0]; - dividedExpression = (Expression) exprs[1]; + dividendExpression = (Expression) exprs[1]; setNegated(matchedPattern == 1 || matchedPattern == 3); return true; } @Override public boolean check(Event event) { - Number divisorNumber = dividedExpression.getSingle(event); + Number divisorNumber = dividendExpression.getSingle(event); return divisorExpression.check(event, new Checker() { @Override public boolean check(Number dividedNumber) { @@ -58,7 +58,7 @@ public boolean check(Number dividedNumber) { @Override public String toString(@Nullable Event event, boolean debug) { - return divisorExpression.toString(event, debug) + " is divisible by " + dividedExpression.toString(event, debug); + return divisorExpression.toString(event, debug) + " is divisible by " + dividendExpression.toString(event, debug); } } diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk index db10ee4dc93..db61db2657c 100644 --- a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk +++ b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk @@ -1,6 +1,6 @@ test "is divisible": - assert 5 can be divided by 5 with "5 can be divided by 5!" - assert 5 can not be divided by 10 with "5 cannot be divided by 10!" + assert 5 can be evenly divided by 5 with "5 can be divided by 5!" + assert 5 can not be evenly divided by 10 with "5 cannot be divided by 10!" assert 5 isn't divisible by 0 with "nothing can be divided by 0!" assert 1964903306 is divisible by 982451653 with "1964903306 is divisible by 982451653!" assert {_none} is divisible by 10 to fail with "you cannot divide by !" From fbcc7015ce8f6c0b16c5d3ae622578f4568e9d58 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Mon, 23 Sep 2024 20:01:52 -0400 Subject: [PATCH 10/17] requested changes --- .../ch/njol/skript/conditions/CondIsDivisibleBy.java | 12 ++++++------ .../tests/syntaxes/conditions/CondIsDivisibleBy.sk | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index 6ef59842014..9921ca688ef 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -24,8 +24,8 @@ public class CondIsDivisibleBy extends Condition { static { Skript.registerCondition(CondIsDivisibleBy.class, - "%numbers% (is|are) divisible by %number%", - "%numbers% (isn't|is not|aren't|are not) divisible by %number%", + "%numbers% (is|are) evenly divisible by %number%", + "%numbers% (isn't|is not|aren't|are not) evenly divisible by %number%", "%numbers% can be evenly divided by %number%", "%numbers% (can't|cannot|can not) be evenly divided by %number%"); } @@ -45,13 +45,13 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye @Override public boolean check(Event event) { - Number divisorNumber = dividendExpression.getSingle(event); + Number divisorNumber = divisorExpression.getSingle(event); return divisorExpression.check(event, new Checker() { @Override - public boolean check(Number dividedNumber) { - double divided = dividedNumber.doubleValue(); + public boolean check(Number dividendNumber) { + double dividend = dividendNumber.doubleValue(); double divisor = divisorNumber != null ? divisorNumber.doubleValue() : null; - return divided % divisor == 0; + return dividend % divisor == 0; } }, isNegated()); } diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk index db61db2657c..c8880a15d61 100644 --- a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk +++ b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk @@ -1,6 +1,6 @@ test "is divisible": assert 5 can be evenly divided by 5 with "5 can be divided by 5!" assert 5 can not be evenly divided by 10 with "5 cannot be divided by 10!" - assert 5 isn't divisible by 0 with "nothing can be divided by 0!" - assert 1964903306 is divisible by 982451653 with "1964903306 is divisible by 982451653!" - assert {_none} is divisible by 10 to fail with "you cannot divide by !" + assert 5 isn't evenly divisible by 0 with "nothing can be divided by 0!" + assert 1964903306 is evenly divisible by 982451653 with "1964903306 is divisible by 982451653!" + assert {_none} is evenly divisible by 10 to fail with "you cannot divide by !" From 531541bff3b82e77e6ecc9b6c33e331d500fd152 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Tue, 24 Sep 2024 19:13:13 -0400 Subject: [PATCH 11/17] requested changes + fixes tests --- .../njol/skript/conditions/CondIsDivisibleBy.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index 9921ca688ef..b2b6a470fa9 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -29,16 +29,15 @@ public class CondIsDivisibleBy extends Condition { "%numbers% can be evenly divided by %number%", "%numbers% (can't|cannot|can not) be evenly divided by %number%"); } - - @SuppressWarnings("null") - private Expression divisorExpression; @SuppressWarnings("null") private Expression dividendExpression; + @SuppressWarnings("null") + private Expression divisorExpression; @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { - divisorExpression = (Expression) exprs[0]; - dividendExpression = (Expression) exprs[1]; + dividendExpression = (Expression) exprs[0]; + divisorExpression = (Expression) exprs[1]; setNegated(matchedPattern == 1 || matchedPattern == 3); return true; } @@ -46,11 +45,11 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye @Override public boolean check(Event event) { Number divisorNumber = divisorExpression.getSingle(event); - return divisorExpression.check(event, new Checker() { + return dividendExpression.check(event, new Checker() { @Override public boolean check(Number dividendNumber) { double dividend = dividendNumber.doubleValue(); - double divisor = divisorNumber != null ? divisorNumber.doubleValue() : null; + double divisor = divisorNumber.doubleValue(); return dividend % divisor == 0; } }, isNegated()); From 4fa368df0964a08e471eeef1a2ef163791200569 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Tue, 24 Sep 2024 20:28:07 -0400 Subject: [PATCH 12/17] fixes documentation --- .../java/ch/njol/skript/conditions/CondIsDivisibleBy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index b2b6a470fa9..c4250fc55b0 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -16,8 +16,8 @@ @Name("Divisible By") @Description("Check if a number is divisible by another number.") @Examples({ - "if 5 is divisible by 5:", - "if 11 cannot be divided by 10:", + "if 5 is evenly divisible by 5:", + "if 11 cannot be evenly divided by 10:", }) @Since("INSERT VERSION") public class CondIsDivisibleBy extends Condition { From 2252547e81173b9abca8a87105f9b1614084b639 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Tue, 24 Sep 2024 20:34:59 -0400 Subject: [PATCH 13/17] makes "evenly" optional --- .../java/ch/njol/skript/conditions/CondIsDivisibleBy.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index c4250fc55b0..cebde851de8 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -24,10 +24,10 @@ public class CondIsDivisibleBy extends Condition { static { Skript.registerCondition(CondIsDivisibleBy.class, - "%numbers% (is|are) evenly divisible by %number%", - "%numbers% (isn't|is not|aren't|are not) evenly divisible by %number%", - "%numbers% can be evenly divided by %number%", - "%numbers% (can't|cannot|can not) be evenly divided by %number%"); + "%numbers% (is|are) [evenly] divisible by %number%", + "%numbers% (isn't|is not|aren't|are not) [evenly] divisible by %number%", + "%numbers% can be [evenly] divided by %number%", + "%numbers% (can't|cannot|can not) be [evenly] divided by %number%"); } @SuppressWarnings("null") private Expression dividendExpression; From c083ee2c417ac965798e642cbe8c27cb954dbb0f Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Tue, 24 Sep 2024 20:57:25 -0400 Subject: [PATCH 14/17] makes evenly required again --- .../java/ch/njol/skript/conditions/CondIsDivisibleBy.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index cebde851de8..c4250fc55b0 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -24,10 +24,10 @@ public class CondIsDivisibleBy extends Condition { static { Skript.registerCondition(CondIsDivisibleBy.class, - "%numbers% (is|are) [evenly] divisible by %number%", - "%numbers% (isn't|is not|aren't|are not) [evenly] divisible by %number%", - "%numbers% can be [evenly] divided by %number%", - "%numbers% (can't|cannot|can not) be [evenly] divided by %number%"); + "%numbers% (is|are) evenly divisible by %number%", + "%numbers% (isn't|is not|aren't|are not) evenly divisible by %number%", + "%numbers% can be evenly divided by %number%", + "%numbers% (can't|cannot|can not) be evenly divided by %number%"); } @SuppressWarnings("null") private Expression dividendExpression; From 15fa4e5036250045347e4eb4f85a9c6c1eedf49a Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Thu, 26 Sep 2024 20:02:00 -0400 Subject: [PATCH 15/17] requested changes + minor syntax update --- .../java/ch/njol/skript/conditions/CondIsDivisibleBy.java | 8 ++++---- .../skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index c4250fc55b0..b5446b1a610 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -13,8 +13,8 @@ import org.bukkit.event.Event; import org.jetbrains.annotations.Nullable; -@Name("Divisible By") -@Description("Check if a number is divisible by another number.") +@Name("Is Evenly Divisible By") +@Description("Check if a number is evenly divisible by another number.") @Examples({ "if 5 is evenly divisible by 5:", "if 11 cannot be evenly divided by 10:", @@ -27,7 +27,7 @@ public class CondIsDivisibleBy extends Condition { "%numbers% (is|are) evenly divisible by %number%", "%numbers% (isn't|is not|aren't|are not) evenly divisible by %number%", "%numbers% can be evenly divided by %number%", - "%numbers% (can't|cannot|can not) be evenly divided by %number%"); + "%numbers% (can't|can[ ]not) be evenly divided by %number%"); } @SuppressWarnings("null") private Expression dividendExpression; @@ -57,7 +57,7 @@ public boolean check(Number dividendNumber) { @Override public String toString(@Nullable Event event, boolean debug) { - return divisorExpression.toString(event, debug) + " is divisible by " + dividendExpression.toString(event, debug); + return dividendExpression.toString(event, debug) + " is " + (isNegated() ? "not " : "") + "evenly divisible by" + divisorExpression.toString(event, debug); } } diff --git a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk index c8880a15d61..ca4bf8e5f9d 100644 --- a/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk +++ b/src/test/skript/tests/syntaxes/conditions/CondIsDivisibleBy.sk @@ -4,3 +4,5 @@ test "is divisible": assert 5 isn't evenly divisible by 0 with "nothing can be divided by 0!" assert 1964903306 is evenly divisible by 982451653 with "1964903306 is divisible by 982451653!" assert {_none} is evenly divisible by 10 to fail with "you cannot divide by !" + assert 5, 10, 15 can be evenly divided by 5 with "5, 10, and 15 can be evenly divided by 5!" + assert 3, 5, 7 cannot be evenly divided by 2 with "3, 5, and 7 cannot be evenly divided by 2!" From e006bbea9897eef4a84a9a759803480ef66fddd4 Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Thu, 26 Sep 2024 21:33:47 -0400 Subject: [PATCH 16/17] Update CondIsDivisibleBy.java --- .../njol/skript/conditions/CondIsDivisibleBy.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index b5446b1a610..c1cb4137970 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -30,22 +30,22 @@ public class CondIsDivisibleBy extends Condition { "%numbers% (can't|can[ ]not) be evenly divided by %number%"); } @SuppressWarnings("null") - private Expression dividendExpression; + private Expression dividend; @SuppressWarnings("null") - private Expression divisorExpression; + private Expression divisor; @Override public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { - dividendExpression = (Expression) exprs[0]; - divisorExpression = (Expression) exprs[1]; + dividend = (Expression) exprs[0]; + divisor = (Expression) exprs[1]; setNegated(matchedPattern == 1 || matchedPattern == 3); return true; } @Override public boolean check(Event event) { - Number divisorNumber = divisorExpression.getSingle(event); - return dividendExpression.check(event, new Checker() { + Number divisorNumber = divisor.getSingle(event); + return dividend.check(event, new Checker() { @Override public boolean check(Number dividendNumber) { double dividend = dividendNumber.doubleValue(); @@ -57,7 +57,8 @@ public boolean check(Number dividendNumber) { @Override public String toString(@Nullable Event event, boolean debug) { - return dividendExpression.toString(event, debug) + " is " + (isNegated() ? "not " : "") + "evenly divisible by" + divisorExpression.toString(event, debug); + return dividend.toString(event, debug) + " is " + (isNegated() ? "not " : "") + + "evenly divisible by" + divisor.toString(event, debug); } } From 430e211419e7e22558c523fcb34974c92f069ffd Mon Sep 17 00:00:00 2001 From: EquipableMC <66171067+EquipableMC@users.noreply.github.com> Date: Fri, 27 Sep 2024 16:54:07 -0400 Subject: [PATCH 17/17] requested changes --- src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java index c1cb4137970..7717f3fa2a8 100644 --- a/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java +++ b/src/main/java/ch/njol/skript/conditions/CondIsDivisibleBy.java @@ -58,7 +58,7 @@ public boolean check(Number dividendNumber) { @Override public String toString(@Nullable Event event, boolean debug) { return dividend.toString(event, debug) + " is " + (isNegated() ? "not " : "") - + "evenly divisible by" + divisor.toString(event, debug); + + "evenly divisible by " + divisor.toString(event, debug); } }