Class 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
  • 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)
      Specified by:
      init in class Section
    • walk

      protected @Nullable TriggerItem walk(org.bukkit.event.Event e)
      Description copied from class: TriggerItem
      Executes 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:
      walk in class TriggerSection
      Returns:
      The next item to run or null to stop execution
    • toString

      public String toString(@Nullable org.bukkit.event.Event e, boolean debug)
      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

      public @Nullable Object getCurrent(org.bukkit.event.Event e)
    • getLoopedExpression

      public Expression<?> getLoopedExpression()
    • setNext

      public SecLoop setNext(@Nullable TriggerItem next)
      Overrides:
      setNext in class TriggerSection
    • getActualNext

      public @Nullable TriggerItem getActualNext()
    • exit

      public void exit(org.bukkit.event.Event event)