Class ExprLoopValue

java.lang.Object
io.github.syst3ms.skriptparser.lang.lambda.SectionValue<SecLoop,Object>
io.github.syst3ms.skriptparser.expressions.ExprLoopValue
All Implemented Interfaces:
Expression<Object>, SyntaxElement

public class ExprLoopValue extends SectionValue<SecLoop,Object>
The currently looped value.
Since:
ALPHA
  • Constructor Details

    • ExprLoopValue

      public ExprLoopValue()
  • Method Details

    • preInitialize

      public boolean preInitialize(Expression<?>[] expressions, int matchedPattern, ParseContext parseContext)
      Description copied from class: SectionValue
      This method is run before the section linked to this SectionValue is identified, and should be used to initialize fields and other class data using the usual parameters of the SyntaxElement.init(Expression[], int, ParseContext) function.
      Specified by:
      preInitialize in class SectionValue<SecLoop,Object>
      Parameters:
      expressions - an array of expressions representing all the expressions that are being passed to this SectionValue. As opposed to Skript, elements of this array can't be null.
      matchedPattern - the index of the pattern that was successfully matched. It corresponds to the order of the syntaxes in registration
      parseContext - an object containing additional information about the parsing of this SectionValue, like regex matches and parse marks
      Returns:
      true if the SectionValue was pre-initialized successfully, false otherwise.
      See Also:
    • getSelectorFunction

      public Function<? super List<? extends SecLoop>, Optional<? extends SecLoop>> getSelectorFunction()
      Description copied from class: SectionValue
      Returns the selector function for this SectionValue. This function is supplied with a list of all the sections of the type described by SectionValue.getSectionClass(), and returns an Optional describing the section that this SectionValue should be linked to, or an empty Optional if no matching section was found. This is useful for targeting a specific section out of multiple surrounding ones based on criteria specific to the implementation. By default, this always picks the first matching function (i.e the innermost one), if there is one.
      Overrides:
      getSelectorFunction in class SectionValue<SecLoop,Object>
      Returns:
      the selector function for this SectionValue.
    • convertExpression

      public <R> Optional<? extends Expression<R>> convertExpression(Class<R> to)
      Description copied from interface: Expression
      Converts this expression from it's current type (T) to another type, using converters.
      Type Parameters:
      R - the type to convert this Expression to
      Parameters:
      to - the class of the type to convert this Expression to
      Returns:
      a converted Expression, or null if it couldn't be converted
    • getReturnType

      public Class<?> getReturnType()
      Returns:
      the return type of this expression. By default, this is defined on registration, but, like Expression.isSingle(), can be overriden.
    • getSectionValues

      public Object[] getSectionValues(SecLoop loop, TriggerContext ctx)
      Description copied from class: SectionValue
      Returns the values of this SectionValue, akin to the output of Expression.getValues(TriggerContext), given the linked section and the TriggerContext.
      Specified by:
      getSectionValues in class SectionValue<SecLoop,Object>
      Parameters:
      loop - the linked section
      ctx - the TriggerContext
      Returns:
      the values of this SectionValue
    • getSectionClass

      public Class<? extends SecLoop> getSectionClass()
      Specified by:
      getSectionClass in class SectionValue<SecLoop,Object>
      Returns:
      the class of the ArgumentSection this SectionValue is linked to.
    • toString

      public String toString(TriggerContext ctx, boolean debug)
      Parameters:
      ctx - the event
      debug - whether to show additional information or not
      Returns:
      a String that should aim to resemble what is written in the script as closely as possible