From f4826007256edf37411ca198f3dda4546929cd34 Mon Sep 17 00:00:00 2001
From: sovdee <10354869+sovdeeth@users.noreply.github.com>
Date: Mon, 9 Sep 2024 11:10:33 -0400
Subject: [PATCH 1/5] fix exponent capping at long max value (#7060)
---
.../java/ch/njol/skript/classes/data/DefaultOperations.java | 6 +-----
src/test/skript/tests/regressions/7059-exponent overflow.sk | 2 ++
2 files changed, 3 insertions(+), 5 deletions(-)
create mode 100644 src/test/skript/tests/regressions/7059-exponent overflow.sk
diff --git a/src/main/java/ch/njol/skript/classes/data/DefaultOperations.java b/src/main/java/ch/njol/skript/classes/data/DefaultOperations.java
index 860c7ee1030..1588d31ece8 100644
--- a/src/main/java/ch/njol/skript/classes/data/DefaultOperations.java
+++ b/src/main/java/ch/njol/skript/classes/data/DefaultOperations.java
@@ -47,11 +47,7 @@ public class DefaultOperations {
return left.doubleValue() * right.doubleValue();
});
Arithmetics.registerOperation(Operator.DIVISION, Number.class, (left, right) -> left.doubleValue() / right.doubleValue());
- Arithmetics.registerOperation(Operator.EXPONENTIATION, Number.class, (left, right) -> {
- if (Utils.isInteger(left, right) && right.longValue() >= 0)
- return (long) Math.pow(left.longValue(), right.longValue());
- return Math.pow(left.doubleValue(), right.doubleValue());
- });
+ Arithmetics.registerOperation(Operator.EXPONENTIATION, Number.class, (left, right) -> Math.pow(left.doubleValue(), right.doubleValue()));
Arithmetics.registerDifference(Number.class, (left, right) -> {
if (Utils.isInteger(left, right))
return Math.abs(left.longValue() - right.longValue());
diff --git a/src/test/skript/tests/regressions/7059-exponent overflow.sk b/src/test/skript/tests/regressions/7059-exponent overflow.sk
new file mode 100644
index 00000000000..16579aee95b
--- /dev/null
+++ b/src/test/skript/tests/regressions/7059-exponent overflow.sk
@@ -0,0 +1,2 @@
+test "overflow exponents":
+ assert 10 ^ 25 is 10000000000000000000000000 with "exponentiation was unexpectedly capped"
From 86742a9680b2b1940a4a4c29ff68a7e72f31a085 Mon Sep 17 00:00:00 2001
From: Efy <35348263+Efnilite@users.noreply.github.com>
Date: Thu, 12 Sep 2024 22:39:28 +0200
Subject: [PATCH 2/5] Fix events in StructParse (#7067)
* init commit
* update name
* fixes
* update
* update
* uhh
* uhh
* should be good now
* remove return false from load
---
.../njol/skript/test/runner/StructParse.java | 45 +++++++++----------
.../pull-7067-events in structs.sk | 8 ++++
2 files changed, 28 insertions(+), 25 deletions(-)
create mode 100644 src/test/skript/tests/regressions/pull-7067-events in structs.sk
diff --git a/src/main/java/ch/njol/skript/test/runner/StructParse.java b/src/main/java/ch/njol/skript/test/runner/StructParse.java
index 3bf0e2d75f5..3a4312a6806 100644
--- a/src/main/java/ch/njol/skript/test/runner/StructParse.java
+++ b/src/main/java/ch/njol/skript/test/runner/StructParse.java
@@ -1,26 +1,7 @@
-/**
- * This file is part of Skript.
- *
- * Skript is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Skript is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Skript. If not, see .
- *
- * Copyright Peter Güttinger, SkriptLang team and contributors
- */
package ch.njol.skript.test.runner;
import ch.njol.skript.ScriptLoader;
import ch.njol.skript.Skript;
-import ch.njol.skript.classes.Changer;
import ch.njol.skript.classes.Changer.ChangeMode;
import ch.njol.skript.classes.Changer.ChangerUtils;
import ch.njol.skript.config.Node;
@@ -30,6 +11,8 @@
import ch.njol.skript.doc.NoDoc;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.Literal;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.lang.parser.ParserInstance;
import ch.njol.skript.lang.util.ContextlessEvent;
import ch.njol.skript.log.LogEntry;
import ch.njol.skript.log.RetainingLogHandler;
@@ -42,9 +25,6 @@
import org.skriptlang.skript.lang.entry.util.ExpressionEntryData;
import org.skriptlang.skript.lang.structure.Structure;
-import static ch.njol.skript.lang.SkriptParser.ParseResult;
-
-
@Name("Parse Structure")
@Description("Parses the code inside this structure as a structure and use 'parse logs' to grab any logs from it.")
@NoDoc
@@ -54,7 +34,7 @@ public class StructParse extends Structure {
Skript.registerStructure(StructParse.class, "parse");
}
- private static EntryValidator validator = EntryValidator.builder()
+ private static final EntryValidator validator = EntryValidator.builder()
.addEntryData(new ExpressionEntryData<>("results", null, false, Object.class))
.addSection("code", false)
.build();
@@ -64,26 +44,33 @@ public class StructParse extends Structure {
private Expression> resultsExpression;
@Override
- public boolean init(Literal>[] args, int matchedPattern, ParseResult parseResult, EntryContainer entryContainer) {
+ public boolean init(Literal>[] args, int matchedPattern,
+ ParseResult parseResult, EntryContainer entryContainer) {
SectionNode parseStructureSectionNode = entryContainer.getSource();
Class extends Event>[] originalEvents = getParser().getCurrentEvents();
getParser().setCurrentEvent("parse", ContextlessEvent.class);
EntryContainer validatedEntries = validator.validate(parseStructureSectionNode);
getParser().setCurrentEvents(originalEvents);
+
if (validatedEntries == null) {
Skript.error("A parse structure must have a result entry and a code section");
return false;
}
+
Expression> maybeResultsExpression = (Expression>) validatedEntries.get("results", false);
if (!ChangerUtils.acceptsChange(maybeResultsExpression, ChangeMode.SET, String[].class)) {
Skript.error(maybeResultsExpression.toString(null, false) + " cannot be set to strings");
+ return false;
}
+
SectionNode codeSectionNode = (SectionNode) validatedEntries.get("code", false);
Node maybeStructureSectionNodeToParse = Iterables.getFirst(codeSectionNode, null);
if (Iterables.size(codeSectionNode) != 1 || !(maybeStructureSectionNodeToParse instanceof SectionNode)) {
Skript.error("The code section must contain a single section to parse as a structure");
+ return false;
}
+
resultsExpression = maybeResultsExpression;
structureSectionNodeToParse = (SectionNode) maybeStructureSectionNodeToParse;
return true;
@@ -100,7 +87,15 @@ public boolean load() {
try (RetainingLogHandler handler = SkriptLogger.startRetainingLog()) {
String structureSectionNodeKey = ScriptLoader.replaceOptions(structureSectionNodeToParse.getKey());
String error = "Can't understand this structure: " + structureSectionNodeKey;
- Structure.parse(structureSectionNodeKey, structureSectionNodeToParse, error);
+ Structure structure = Structure.parse(structureSectionNodeKey, structureSectionNodeToParse, error);
+
+ getParser().setCurrentStructure(structure);
+ if (structure != null && structure.preLoad() && structure.load()) {
+ structure.postLoad();
+ }
+
+ getParser().setCurrentStructure(null);
+
logs = handler.getLog().stream()
.map(LogEntry::getMessage)
.toArray(String[]::new);
diff --git a/src/test/skript/tests/regressions/pull-7067-events in structs.sk b/src/test/skript/tests/regressions/pull-7067-events in structs.sk
new file mode 100644
index 00000000000..3c8939d04e5
--- /dev/null
+++ b/src/test/skript/tests/regressions/pull-7067-events in structs.sk
@@ -0,0 +1,8 @@
+parse:
+ results: {StructEvent::parse::*}
+ code:
+ on script load:
+ stop
+
+test "events in structs":
+ assert {StructEvent::parse::*} is not set with "using event in struct caused an error"
From 96dce83818b7785a666d267745f0e454ae9405b9 Mon Sep 17 00:00:00 2001
From: Sparky200
Date: Tue, 17 Sep 2024 07:14:40 -0500
Subject: [PATCH 3/5] Fix NPE caused by unregistered ClassInfo (#7085)
---
src/main/java/ch/njol/skript/lang/SkriptParser.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/main/java/ch/njol/skript/lang/SkriptParser.java b/src/main/java/ch/njol/skript/lang/SkriptParser.java
index c8d9b551a69..cefa92b2549 100644
--- a/src/main/java/ch/njol/skript/lang/SkriptParser.java
+++ b/src/main/java/ch/njol/skript/lang/SkriptParser.java
@@ -1181,7 +1181,15 @@ public static String notOfType(Class>... types) {
}
Class> c = types[i];
assert c != null;
- message.append(Classes.getSuperClassInfo(c).getName().withIndefiniteArticle());
+ ClassInfo> classInfo = Classes.getSuperClassInfo(c);
+ // if there's a registered class info,
+ if (classInfo != null) {
+ // use the article,
+ message.append(classInfo.getName().withIndefiniteArticle());
+ } else {
+ // otherwise fallback to class name
+ message.append(c.getName());
+ }
}
return message.toString();
}
From c11551faa7d690e61990ddbebe80ddd2c118ed8f Mon Sep 17 00:00:00 2001
From: Efy <35348263+Efnilite@users.noreply.github.com>
Date: Sat, 21 Sep 2024 21:52:29 +0200
Subject: [PATCH 4/5] Fix missing "and" warnings (#7036)
* init commit innit
* updates
* removed comma for only lists of two
* Remove changes from feature branch.
---------
Co-authored-by: Moderocky
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
---
.../pull-6586-effhealth item mutation.sk | 2 +-
.../tests/syntaxes/conditions/CondCompare.sk | 14 +++++++-------
.../tests/syntaxes/expressions/ExprRepeat.sk | 6 +++---
.../tests/syntaxes/expressions/ExprStringCase.sk | 2 +-
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/test/skript/tests/regressions/pull-6586-effhealth item mutation.sk b/src/test/skript/tests/regressions/pull-6586-effhealth item mutation.sk
index aa70a29ceda..a048155c588 100644
--- a/src/test/skript/tests/regressions/pull-6586-effhealth item mutation.sk
+++ b/src/test/skript/tests/regressions/pull-6586-effhealth item mutation.sk
@@ -9,6 +9,6 @@ test "EffHealth item mutation fix":
set {_item1} to diamond sword with damage 100
set {_item2} to diamond with damage 10
- repair {_item1}, {_item2}
+ repair {_item1} and {_item2}
assert {_item1} is diamond sword with damage 0 with "{_item1} was incorrectly repaired"
assert {_item2} is diamond with "{_item2} was no longer a diamond"
diff --git a/src/test/skript/tests/syntaxes/conditions/CondCompare.sk b/src/test/skript/tests/syntaxes/conditions/CondCompare.sk
index a182b0f4923..3f63431b737 100644
--- a/src/test/skript/tests/syntaxes/conditions/CondCompare.sk
+++ b/src/test/skript/tests/syntaxes/conditions/CondCompare.sk
@@ -6,14 +6,14 @@ test "compare":
assert 1 is greater than or equal to 0 and 1 with "Number is not greater than or equal to two smaller/equal numbers"
assert 1 is less than or equal to 1 and 2 with "Number is not smaller than or equal to two greater/equal numbers"
- assert 1, 2 is 1, 2 with "direct list comparison of equal numbers failed"
- assert 1, 2, 3 is not 1, 2 with "direct list comparison of non-equal numbers succeeded"
- assert 1, 2 is 1, 2, or 3 with "comparison between AND list of numbers and OR list of superset of numbers failed"
- assert 1, 2, 3 is 1 or 2 to fail with "comparison between AND list of numbers and OR list of subset of numbers succeeded"
+ assert 1 and 2 is 1 and 2 with "direct list comparison of equal numbers failed"
+ assert 1, 2, and 3 is not 1 and 2 with "direct list comparison of non-equal numbers succeeded"
+ assert 1 and 2 is 1, 2, or 3 with "comparison between AND list of numbers and OR list of superset of numbers failed"
+ assert 1, 2, and 3 is 1 or 2 to fail with "comparison between AND list of numbers and OR list of subset of numbers succeeded"
- assert 1, 2, 3 is greater than -1, -2, -3 with "Numbers are not larger than smaller numbers"
- assert 1, 2, 3 is less than 5, 6, 7 with "Numbers are not smaller than larger numbers"
- assert 1, 2, 3 is between -1, 1 and 3, 3.5 with "Numbers are not between smaller/equal numbers and larger/equal numbers"
+ assert 1, 2, and 3 is greater than -1, -2, and -3 with "Numbers are not larger than smaller numbers"
+ assert 1, 2, and 3 is less than 5, 6, and 7 with "Numbers are not smaller than larger numbers"
+ assert 1, 2, and 3 is between (-1 and 1) and (3 and 3.5) with "Numbers are not between smaller/equal numbers and larger/equal numbers"
assert 10 is between 5 and 15 with "Number isn't between smaller and larger"
assert 10 is between 9 and 11 with "Number isn't between smaller and larger"
diff --git a/src/test/skript/tests/syntaxes/expressions/ExprRepeat.sk b/src/test/skript/tests/syntaxes/expressions/ExprRepeat.sk
index fc2cbac598b..96dd6a1c100 100644
--- a/src/test/skript/tests/syntaxes/expressions/ExprRepeat.sk
+++ b/src/test/skript/tests/syntaxes/expressions/ExprRepeat.sk
@@ -43,7 +43,7 @@ test "repeat expression":
then:
assert false is true with "ExprRepeat Multi - 1) 'aa' and 'b' repeated 3 times is not 'aaaaaa' and 'bbb'"
- set {_strings::*} to "aa", "b"
+ set {_strings::*} to "aa" and "b"
set {_strings::*} to {_strings::*} repeated {_repeat} times
if any:
{_strings::1} is not "aaaaaa"
@@ -51,7 +51,7 @@ test "repeat expression":
then:
assert false is true with "ExprRepeat Multi - 2) 'aa' and 'b' repeated 3 times is not 'aaaaaa' and 'bbb'"
- set {_strings::*} to "aa", "b"
+ set {_strings::*} to "aa" and "b"
set {_strings::*} to {_strings::*} repeated 3 times
if any:
{_strings::1} is not "aaaaaa"
@@ -59,7 +59,7 @@ test "repeat expression":
then:
assert false is true with "ExprRepeat Multi - 3) 'aa' and 'b' repeated 3 times is not 'aaaaaa' and 'bbb'"
- set {_strings::*} to "aa", "b" repeated {_repeat} times
+ set {_strings::*} to "aa" and "b" repeated {_repeat} times
if any:
{_strings::1} is not "aaaaaa"
{_strings::2} is not "bbb"
diff --git a/src/test/skript/tests/syntaxes/expressions/ExprStringCase.sk b/src/test/skript/tests/syntaxes/expressions/ExprStringCase.sk
index acca046bad5..593cb9578b0 100644
--- a/src/test/skript/tests/syntaxes/expressions/ExprStringCase.sk
+++ b/src/test/skript/tests/syntaxes/expressions/ExprStringCase.sk
@@ -1,7 +1,7 @@
test "string cases":
assert caseEquals("Oops!" in lowercase, "oops!") is true with "lowercase failed"
assert caseEquals("Oops!" in uppercase, "OOPS!") is true with "uppercase failed"
- assert caseEquals(capitalised "Oops!", "OOPS!") is true with "capitalised failed"
+ assert caseEquals((capitalised "Oops!"), "OOPS!") is true with "capitalised failed"
assert caseEquals("hellO i'm steve!" in proper case, "HellO I'm Steve!") is true with "lenient proper case failed"
assert caseEquals("hellO i'm steve!" in strict proper case, "Hello I'm Steve!") is true with "strict proper case failed"
assert caseEquals("spAwn neW boSs ()" in camel case, "spAwnNeWBoSs()") is true with "lenient camel case failed"
From 3e3f0a9d77e4e2655162ee2cb8beff11b1f31cdf Mon Sep 17 00:00:00 2001
From: sovdee <10354869+sovdeeth@users.noreply.github.com>
Date: Sat, 21 Sep 2024 17:55:48 -0400
Subject: [PATCH 5/5] bstats - Fix trying to compare enum value to string value
for verbosity and event priority (#7027)
* Fix trying to compare enum value to string value for verbosity and event priority
* wrong polarity for var/command case sensitivity
---
.../org/skriptlang/skript/bukkit/SkriptMetrics.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/skriptlang/skript/bukkit/SkriptMetrics.java b/src/main/java/org/skriptlang/skript/bukkit/SkriptMetrics.java
index e57c4ec7700..4fa2865378c 100644
--- a/src/main/java/org/skriptlang/skript/bukkit/SkriptMetrics.java
+++ b/src/main/java/org/skriptlang/skript/bukkit/SkriptMetrics.java
@@ -120,12 +120,14 @@ public static void setupMetrics(Metrics metrics) {
metrics.addCustomChart(new DrilldownPie("drilldownLogVerbosity", () -> {
String verbosity = SkriptConfig.verbosity.value().name().toLowerCase(Locale.ENGLISH).replace('_', ' ');
- return isDefaultMap(verbosity, SkriptConfig.verbosity.defaultValue());
+ String defaultValue = SkriptConfig.verbosity.defaultValue().name().toLowerCase(Locale.ENGLISH).replace('_', ' ');
+ return isDefaultMap(verbosity, defaultValue);
}));
metrics.addCustomChart(new DrilldownPie("drilldownPluginPriority", () -> {
String priority = SkriptConfig.defaultEventPriority.value().name().toLowerCase(Locale.ENGLISH).replace('_', ' ');
- return isDefaultMap(priority, SkriptConfig.defaultEventPriority.defaultValue());
+ String defaultValue = SkriptConfig.defaultEventPriority.defaultValue().name().toLowerCase(Locale.ENGLISH).replace('_', ' ');
+ return isDefaultMap(priority, defaultValue);
}));
metrics.addCustomChart(new SimplePie("cancelledByDefault", () ->
SkriptConfig.listenCancelledByDefault.value().toString()
@@ -143,10 +145,10 @@ public static void setupMetrics(Metrics metrics) {
SkriptConfig.caseSensitive.value().toString()
));
metrics.addCustomChart(new SimplePie("caseSensitiveVariables", () ->
- SkriptConfig.caseInsensitiveVariables.value().toString()
+ String.valueOf(!SkriptConfig.caseInsensitiveVariables.value())
));
metrics.addCustomChart(new SimplePie("caseSensitiveCommands", () ->
- SkriptConfig.caseInsensitiveCommands.value().toString()
+ String.valueOf(!SkriptConfig.caseInsensitiveCommands.value())
));
metrics.addCustomChart(new SimplePie("disableSaveWarnings", () ->