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 01/18] 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 02/18] 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 03/18] 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 04/18] 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 05/18] 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", () ->
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 06/18] 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}
From 6dadbf078d366384eafd1e8099fb060e8ca69a38 Mon Sep 17 00:00:00 2001
From: mugu
Date: Sun, 22 Sep 2024 03:05:16 +0200
Subject: [PATCH 07/18] Update config.sk (#7052)
Co-authored-by: Moderocky
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
---
src/main/resources/config.sk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/resources/config.sk b/src/main/resources/config.sk
index eb0b295c288..2d7b5ee197f 100644
--- a/src/main/resources/config.sk
+++ b/src/main/resources/config.sk
@@ -31,7 +31,7 @@
# ==== General Options ====
language: english
-# Which language to use. Currently English, German, Korean, French, Polish, Russian, Japanese, Simplified Chinese and Turkish
+# Which language to use. Currently English, German, Korean, French, Polish, Russian, Japanese, Simplified Chinese, Turkish and Dutch
# are included in the download, but custom languages can be created as well. Use the name in lowercase and no spaces as the value.
# Please note that not everything can be translated yet, i.e. parts of Skript will still be english if you use another language.
# If you want to translate Skript to your language please read the readme.txt located in the /lang/ folder in the jar
From 0a8bac337676ff9e63da685da8ca98a2f597c953 Mon Sep 17 00:00:00 2001
From: Efy <35348263+Efnilite@users.noreply.github.com>
Date: Sun, 22 Sep 2024 03:22:02 +0200
Subject: [PATCH 08/18] Fix ExprHoverList's remove (#7056)
* init commit
* remove pattern matching >:(
---------
Co-authored-by: Moderocky
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
---
.../ch/njol/skript/expressions/ExprHoverList.java | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/main/java/ch/njol/skript/expressions/ExprHoverList.java b/src/main/java/ch/njol/skript/expressions/ExprHoverList.java
index a3b58b6b9d3..835319f3449 100644
--- a/src/main/java/ch/njol/skript/expressions/ExprHoverList.java
+++ b/src/main/java/ch/njol/skript/expressions/ExprHoverList.java
@@ -104,7 +104,7 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
if (HAS_NEW_LISTED_PLAYER_INFO) {
List values = new ArrayList<>();
- if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET) {
+ if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET && mode != ChangeMode.REMOVE) {
for (Object object : delta) {
if (object instanceof Player) {
Player player = (Player) object;
@@ -124,7 +124,9 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
sample.addAll(values);
break;
case REMOVE:
- sample.removeAll(values);
+ for (Object value : delta) {
+ sample.removeIf(profile -> profile.name().equals(value));
+ }
break;
case DELETE:
case RESET:
@@ -135,7 +137,7 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
}
List values = new ArrayList<>();
- if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET) {
+ if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET && mode != ChangeMode.REMOVE) {
for (Object object : delta) {
if (object instanceof Player) {
Player player = (Player) object;
@@ -150,13 +152,14 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
switch (mode) {
case SET:
sample.clear();
- sample.addAll(values);
- break;
+ // $FALL-THROUGH$
case ADD:
sample.addAll(values);
break;
case REMOVE:
- sample.removeAll(values);
+ for (Object value : delta) {
+ sample.removeIf(profile -> profile.getName() != null && profile.getName().equals(value));
+ }
break;
case DELETE:
case RESET:
From 19985d98d1974a2c6de2b4e9476691b0129881e3 Mon Sep 17 00:00:00 2001
From: Efy <35348263+Efnilite@users.noreply.github.com>
Date: Sun, 22 Sep 2024 04:49:17 +0200
Subject: [PATCH 09/18] Update ExprTime (#7082)
* init commit
* update imports
* magic number
* space
* fixes
* up
* imports
* fix for registerDefault
* fix breaking changes
---------
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
---
.../ch/njol/skript/expressions/ExprTime.java | 153 +++++++++---------
.../tests/regressions/7081-time of worlds.sk | 29 ++++
2 files changed, 102 insertions(+), 80 deletions(-)
create mode 100644 src/test/skript/tests/regressions/7081-time of worlds.sk
diff --git a/src/main/java/ch/njol/skript/expressions/ExprTime.java b/src/main/java/ch/njol/skript/expressions/ExprTime.java
index 4e769f6656d..e2199e18a80 100644
--- a/src/main/java/ch/njol/skript/expressions/ExprTime.java
+++ b/src/main/java/ch/njol/skript/expressions/ExprTime.java
@@ -1,27 +1,5 @@
-/**
- * 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.expressions;
-import org.bukkit.World;
-import org.bukkit.event.Event;
-import org.jetbrains.annotations.Nullable;
-
import ch.njol.skript.Skript;
import ch.njol.skript.classes.Changer.ChangeMode;
import ch.njol.skript.doc.Description;
@@ -32,42 +10,51 @@
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
-import ch.njol.skript.registrations.Classes;
-import ch.njol.skript.util.Getter;
import ch.njol.skript.util.Time;
import ch.njol.skript.util.Timeperiod;
import ch.njol.skript.util.Timespan;
import ch.njol.util.Kleenean;
import ch.njol.util.coll.CollectionUtils;
+import org.bukkit.World;
+import org.bukkit.event.Event;
+import org.jetbrains.annotations.Nullable;
-/**
- * @author Peter Güttinger
- */
@Name("Time")
-@Description("The time of a world.")
-@Examples({"time in world is between 18:00 and 6:00:",
- " broadcast \"It's night-time, watch out for monsters!\""})
+@Description({
+ "The time of a world.",
+ "Use the \"minecraft timespan\" syntax to change the time according " +
+ "to Minecraft's time intervals.",
+ "Since Minecraft uses discrete intervals for time (ticks), " +
+ "changing the time by real-world minutes or real-world seconds only changes it approximately.",
+ "Removing an amount of time from a world's time will move the clock forward a day."
+})
+@Examples({
+ "set time of world \"world\" to 2:00",
+ "add 2 minecraft hours to time of world \"world\"",
+ "add 54 real seconds to time of world \"world\" # approximately 1 minecraft hour"
+})
@Since("1.0")
public class ExprTime extends PropertyExpression {
+
+ // 18000 is the offset to allow for using "add 2:00" without going to a new day
+ // and causing unexpected behaviour
+ private static final int TIME_TO_TIMESPAN_OFFSET = 18000;
+
static {
- Skript.registerExpression(ExprTime.class, Time.class, ExpressionType.PROPERTY, "[the] time[s] [([with]in|of) %worlds%]", "%worlds%'[s] time[s]");
+ Skript.registerExpression(ExprTime.class, Time.class, ExpressionType.PROPERTY,
+ "[the] time[s] [([with]in|of) %worlds%]", "%worlds%'[s] time[s]");
}
-
- @SuppressWarnings({"unchecked", "null"})
+
+ @SuppressWarnings("unchecked")
@Override
- public boolean init(final Expression>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
- setExpr((Expression) exprs[0]);
+ public boolean init(Expression>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
+ setExpr((Expression) expressions[0]);
return true;
}
-
+
@Override
- protected Time[] get(final Event e, final World[] source) {
- return get(source, new Getter