diff --git a/src/main/java/ch/njol/skript/sections/SecFor.java b/src/main/java/ch/njol/skript/sections/SecFor.java
index e2b506e866d..3ea5bfd15d5 100644
--- a/src/main/java/ch/njol/skript/sections/SecFor.java
+++ b/src/main/java/ch/njol/skript/sections/SecFor.java
@@ -1,19 +1,19 @@
/**
- * 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
+ * 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.sections;
@@ -31,35 +31,36 @@
import ch.njol.skript.lang.TriggerItem;
import ch.njol.skript.lang.Variable;
import ch.njol.skript.lang.util.ContainerExpression;
+import ch.njol.skript.registrations.Feature;
import ch.njol.skript.util.Container;
import ch.njol.skript.util.Container.ContainerType;
import ch.njol.skript.util.LiteralUtils;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.Nullable;
-import org.skriptlang.skript.lang.experiment.Feature;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@Name("For Each Loop (Experimental)")
-@Description({
- "A specialised loop section run for each element in a list.",
- "Unlike the basic loop, this is designed for extracting the key & value from pairs.",
- "The loop element's key/index and value can be stored in a variable for convenience."
-})
+@Description("""
+ A specialised loop section run for each element in a list.
+ Unlike the basic loop, this is designed for extracting the key & value from pairs.
+ The loop element's key/index and value can be stored in a variable for convenience.
+
+ When looping a simple (non-indexed) set of values, e.g. all players, the index will be the loop counter number."""
+)
@Examples({
"for each {_player} in players:",
"\tsend \"Hello %{_player}%!\" to {_player}",
"",
- "for each {_item} in {list of items::*}:",
+ "loop {_item} in {list of items::*}:",
"\tbroadcast {_item}'s name",
"",
"for each key {_index} in {list of items::*}:",
"\tbroadcast {_index}",
"",
- "for each key {_index} and value {_value} in {list of items::*}:",
+ "loop key {_index} and value {_value} in {list of items::*}:",
"\tbroadcast \"%{_index}% = %{_value}%\"",
"",
"for each {_index} = {_value} in {my list::*}:",
@@ -70,10 +71,10 @@ public class SecFor extends SecLoop {
static {
Skript.registerSection(SecFor.class,
- "for [each] [value] %~object% in %objects%",
- "for [each] (key|index) %~object% in %objects%",
- "for [each] [key|index] %~object% (=|and) [value] %~object% in %objects%"
- );
+ "(for [each]|loop) [value] %~object% in %objects%",
+ "(for [each]|loop) (key|index) %~object% in %objects%",
+ "(for [each]|loop) [key|index] %~object% (=|and) [value] %~object% in %objects%"
+ );
}
private @Nullable Expression> keyStore, valueStore;
@@ -86,7 +87,7 @@ public boolean init(Expression>[] exprs,
ParseResult parseResult,
SectionNode sectionNode,
List