Class ExpressionSection

All Implemented Interfaces:
Debuggable, SyntaxElement

@Internal public class ExpressionSection extends Section
A dummy trigger item representing the 'section' aspect of a SectionExpression. This is not a parsed or registered syntax in itself, and can be used for getting access to the parse-time features of a section syntax (e.g. loading body code).

This is not safe to be used during runtime, since it is not a part of the trigger item tree.

See Also:
  • Field Details

    • expression

      protected final ch.njol.skript.expressions.base.SectionExpression<?> expression
  • Constructor Details

    • ExpressionSection

      public ExpressionSection(ch.njol.skript.expressions.base.SectionExpression<?> expression)
  • Method Details

    • init

      public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult)
      Description copied from class: Section
      This method should not be overridden unless you know what you are doing!
      Specified by:
      init in interface SyntaxElement
      Overrides:
      init in class Section
      Parameters:
      expressions - all %expr%s included in the matching pattern in the order they appear in the pattern. If an optional value was left out, it will still be included in this list holding the default value of the desired type, which usually depends on the event.
      matchedPattern - The index of the pattern which matched
      isDelayed - Whether this expression is used after a delay or not (i.e. if the event has already passed when this expression will be called)
      parseResult - Additional information about the match.
      Returns:
      Whether this expression was initialised successfully. An error should be printed prior to returning false to specify the cause.
      See Also:
    • init

      public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult, @Nullable @Nullable SectionNode sectionNode, List<TriggerItem> triggerItems)
      Specified by:
      init in class Section
    • walk

      @Nullable protected @Nullable TriggerItem walk(org.bukkit.event.Event event)
      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
      Parameters:
      event - The event
      Returns:
      The next item to run or null to stop execution
    • toString

      public String toString(@Nullable @Nullable org.bukkit.event.Event event, boolean debug)
      Parameters:
      event - The event to get information from. 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
    • getAsExpression

      public ch.njol.skript.expressions.base.SectionExpression<?> getAsExpression()
    • loadCode

      public void loadCode(SectionNode sectionNode)
      Description copied from class: Section
      Loads the code in the given SectionNode, appropriately modifying ParserInstance.getCurrentSections().
      This method itself does not modify ParserInstance.getHasDelayBefore() (although the loaded code may change it), the calling code must deal with this.
      Overrides:
      loadCode in class Section
    • loadOptionalCode

      public void loadOptionalCode(SectionNode sectionNode)
      Description copied from class: Section
      Loads the code using Section.loadCode(SectionNode).
      This method also adjusts ParserInstance.getHasDelayBefore() to expect the code to be called zero or more times. This is done by setting hasDelayBefore to Kleenean.UNKNOWN if the loaded section has a possible or definite delay in it.
      Overrides:
      loadOptionalCode in class Section
    • runSection

      public boolean runSection(org.bukkit.event.Event event)
    • setTriggerItems

      public void setTriggerItems(List<TriggerItem> items)
      Description copied from class: TriggerSection
      Remember to add this section to ParserInstance.getCurrentSections() before parsing child elements!
       ScriptLoader.currentSections.add(this);
       setTriggerItems(ScriptLoader.loadItems(node));
       ScriptLoader.currentSections.remove(ScriptLoader.currentSections.size() - 1);
       
      Overrides:
      setTriggerItems in class TriggerSection
    • loadCodeTask

      public Trigger loadCodeTask(SectionNode sectionNode, String name, @Nullable @Nullable Runnable afterLoading, Class<? extends org.bukkit.event.Event>... events)