Package ch.njol.skript.sections
Class SecLoop
java.lang.Object
ch.njol.skript.lang.TriggerItem
ch.njol.skript.lang.TriggerSection
ch.njol.skript.lang.Section
ch.njol.skript.sections.SecLoop
- All Implemented Interfaces:
Debuggable,SyntaxElement
@Name("Loop")
@Description({"Loop sections repeat their code with multiple values.","","A loop will loop through all elements of the given expression, e.g. all players, worlds, items, etc. The conditions & effects inside the loop will be executed for every of those elements, which can be accessed with \u2018loop-<what>\u2019, e.g. <code>send \"hello\" to loop-player</code>. When a condition inside a loop is not fulfilled the loop will start over with the next element of the loop. You can however use <code>stop loop</code> to exit the loop completely and resume code execution after the end of the loop.","","<b>Loopable Values</b>","All <a href=\"/expressions.html\">expressions</a> that represent more than one value, e.g. \u2018all players\u2019, \u2018worlds\u2019, etc., as well as list variables, can be looped. You can also use a list of expressions, e.g. <code>loop the victim and the attacker</code>, to execute the same code for only a few values.","","<b>List Variables</b>","When looping list variables, you can also use <code>loop-index</code> in addition to <code>loop-value</code> inside the loop. <code>loop-value</code> is the value of the currently looped variable, and <code>loop-index</code> is the last part of the variable\'s name (the part where the list variable has its asterisk *)."})
@Examples({"loop all players:","\tsend \"Hello %loop-player%!\" to loop-player","","loop items in player\'s inventory:","\tif loop-item is dirt:","\t\tset loop-item to air","","loop 10 times:","\tsend title \"%11 - loop-value%\" and subtitle \"seconds left until the game begins\" to player for 1 second # 10, 9, 8 etc.","\twait 1 second","","loop {Coins::*}:","\tset {Coins::%loop-index%} to loop-value + 5 # Same as \"add 5 to {Coins::%loop-index%}\" where loop-index is the uuid of the player and loop-value is the actually coins value such as 200"})
@Since("1.0")
public class SecLoop
extends Section
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.njol.skript.lang.Section
Section.SectionContext -
Field Summary
Fields inherited from class ch.njol.skript.lang.TriggerSection
first, lastFields inherited from class ch.njol.skript.lang.TriggerItem
parent -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexit(org.bukkit.event.Event event) @Nullable TriggerItem@Nullable ObjectgetCurrent(org.bukkit.event.Event e) Expression<?>booleaninit(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult, SectionNode sectionNode, List<TriggerItem> triggerItems) setNext(@Nullable TriggerItem next) toString(@Nullable org.bukkit.event.Event e, boolean debug) protected @Nullable TriggerItemwalk(org.bukkit.event.Event e) Executes this item and returns the next item to run.Methods inherited from class ch.njol.skript.lang.Section
init, loadCode, loadCode, loadCode, loadOptionalCode, parseMethods inherited from class ch.njol.skript.lang.TriggerSection
run, setParent, setTriggerItems, walkMethods inherited from class ch.njol.skript.lang.TriggerItem
debug, getIndentation, getNext, getParent, getTrigger, toString, walkMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.njol.skript.lang.SyntaxElement
getParser
-
Constructor Details
-
SecLoop
public SecLoop()
-
-
Method Details
-
init
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult, SectionNode sectionNode, List<TriggerItem> triggerItems) -
walk
Description copied from class:TriggerItemExecutes this item and returns the next item to run.Overriding classes must call
TriggerItem.debug(Event, boolean). If this method is overridden,TriggerItem.run(Event)is not used anymore and can be ignored.- Specified by:
walkin classTriggerSection- Returns:
- The next item to run or null to stop execution
-
toString
- Parameters:
e- The event to get information to. This is always null if debug == false.debug- If true this should print more information, if false this should print what is shown to the end user- Returns:
- String representation of this object
-
getCurrent
-
getLoopedExpression
-
setNext
- Overrides:
setNextin classTriggerSection
-
getActualNext
-
exit
public void exit(org.bukkit.event.Event event)
-