Class SectionValue<S extends ArgumentSection, T>
java.lang.Object
io.github.syst3ms.skriptparser.lang.lambda.SectionValue<S,T>
- Type Parameters:
S- the type of the section from which to retrieve argumentsT- the return value of the expression
- All Implemented Interfaces:
Expression<T>, SyntaxElement
- Direct Known Subclasses:
ExprLoopValue, ExprSingleParameter
public abstract class SectionValue<S extends ArgumentSection, T>
extends Object
implements Expression<T>
An expression that is tied to a given
ArgumentSection, and acts as a way to retrieve
the arguments passed through an Expression.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract T[]getSectionValues(S section, TriggerContext ctx) Returns the values of thisSectionValue, akin to the output ofExpression.getValues(TriggerContext), given the linked section and theTriggerContext.Returns the selector function for thisSectionValue.T[]getValues(TriggerContext ctx) Retrieves all values of this Expression, accounting for possible modifiers.booleaninit(Expression<?>[] expressions, int matchedPattern, ParseContext parseContext) Initializes this SyntaxElement before being used.booleanpostInitialize(S section, ParseContext parseContext) This method is run after the section linked to thisSectionValueis identified, and should be used to make some additional verifications/setup operations on the linkedArgumentSectionthat was identified.abstract booleanpreInitialize(Expression<?>[] expressions, int matchedPattern, ParseContext parseContext) This method is run before the section linked to thisSectionValueis identified, and should be used to initialize fields and other class data using the usual parameters of theSyntaxElement.init(Expression[], int, ParseContext)function.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Expression
acceptsChange, acceptsChange, acceptsChange, change, check, check, convertExpression, getArray, getReturnType, getSingle, getSource, isAndList, isLoopOf, isSingle, iterator, setAndList, streamMethods inherited from interface SyntaxElement
toString
-
Constructor Details
-
SectionValue
public SectionValue()
-
-
Method Details
-
init
Description copied from interface:SyntaxElementInitializes this SyntaxElement before being used. This method is always called before all the others in an extending class, the only exception beingCodeSection.loadSection(FileSection, ParserState, SkriptLogger).- Specified by:
initin interfaceSyntaxElement- Parameters:
expressions- an array of expressions representing all the expressions that are being passed to this syntax element. As opposed to Skript, elements of this array can't benull.matchedPattern- the index of the pattern that was successfully matched. It corresponds to the order of the syntaxes in registrationparseContext- an object containing additional information about the parsing of this syntax element, like regex matches and parse marks- Returns:
trueif the syntax element was initialized successfully,falseotherwise.- See Also:
-
getValues
Description copied from interface:ExpressionRetrieves all values of this Expression, accounting for possible modifiers. This means that if this is an or-list, it will choose a random value to return.- Specified by:
getValuesin interfaceExpression<S extends ArgumentSection>- Parameters:
ctx- the event- Returns:
- an array of the values
- See Also:
-
preInitialize
public abstract boolean preInitialize(Expression<?>[] expressions, int matchedPattern, ParseContext parseContext) This method is run before the section linked to thisSectionValueis identified, and should be used to initialize fields and other class data using the usual parameters of theSyntaxElement.init(Expression[], int, ParseContext)function.- Parameters:
expressions- an array of expressions representing all the expressions that are being passed to thisSectionValue. As opposed to Skript, elements of this array can't benull.matchedPattern- the index of the pattern that was successfully matched. It corresponds to the order of the syntaxes in registrationparseContext- an object containing additional information about the parsing of thisSectionValue, like regex matches and parse marks- Returns:
trueif theSectionValuewas pre-initialized successfully,falseotherwise.- See Also:
-
postInitialize
This method is run after the section linked to thisSectionValueis identified, and should be used to make some additional verifications/setup operations on the linkedArgumentSectionthat was identified. By default, this function always returnstruewith no added operations.- Parameters:
section- the section that was identified as corresponding to thisSectionValueparseContext- the parse context used previously- Returns:
trueif theSectionValuewas post-initialized successfully,falseotherwise.
-
getSelectorFunction
Returns the selector function for thisSectionValue. This function is supplied with a list of all the sections of the type described bygetSectionClass(), and returns an Optional describing the section that thisSectionValueshould 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.- Returns:
- the selector function for this
SectionValue.
-
getSectionValues
Returns the values of thisSectionValue, akin to the output ofExpression.getValues(TriggerContext), given the linked section and theTriggerContext.- Parameters:
section- the linked sectionctx- theTriggerContext- Returns:
- the values of this
SectionValue
-
getSectionClass
- Returns:
- the class of the
ArgumentSectionthisSectionValueis linked to.
-