Package ch.njol.skript.lang
Class LiteralList<T>
java.lang.Object
ch.njol.skript.lang.ExpressionList<T>
ch.njol.skript.lang.LiteralList<T>
- All Implemented Interfaces:
Debuggable
,Expression<T>
,Literal<T>
,Loopable<T>
,Simplifiable<Expression<? extends T>>
,SyntaxElement
A list of literals. Can contain
UnparsedLiteral
s.-
Field Summary
Fields inherited from class ch.njol.skript.lang.ExpressionList
and, expressions
-
Constructor Summary
ConstructorsConstructorDescriptionLiteralList
(Literal<? extends T>[] literals, Class<T> returnType, boolean and) LiteralList
(Literal<? extends T>[] literals, Class<T> returnType, boolean and, LiteralList<?> source) LiteralList
(Literal<? extends T>[] literals, Class<T> returnType, Class<?>[] possibleReturnTypes, boolean and) LiteralList
(Literal<? extends T>[] literals, Class<T> returnType, Class<?>[] possibleReturnTypes, boolean and, LiteralList<?> source) -
Method Summary
Methods inherited from class ch.njol.skript.lang.ExpressionList
acceptChange, change, check, check, getAll, getAllExpressions, getAnd, getArray, getReturnType, getSingle, getSource, getTime, init, invertAnd, isDefault, isLoopOf, isSingle, iterator, possibleReturnTypes, setTime, toString, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.njol.skript.lang.Debuggable
toString, toString
Methods inherited from interface ch.njol.skript.lang.Expression
acceptChange, beforeChange, canBeSingle, canReturn, change, changeInPlace, changeInPlace, check, check, getAcceptedChangeModes, getAll, getAnd, getArray, getOptionalSingle, getReturnType, getSingle, getSource, getSyntaxTypeName, getTime, isDefault, isSingle, possibleReturnTypes, setTime, stream, streamAll
Methods inherited from interface ch.njol.skript.lang.Loopable
isLoopOf, iterator, supportsLoopPeeking
Methods inherited from interface ch.njol.skript.lang.SyntaxElement
getParser, init, preInit
-
Constructor Details
-
LiteralList
-
LiteralList
-
LiteralList
public LiteralList(Literal<? extends T>[] literals, Class<T> returnType, boolean and, LiteralList<?> source) -
LiteralList
-
-
Method Details
-
getArray
-
getSingle
-
getAll
-
getConvertedExpression
Description copied from interface:Expression
Tries to convert this expression to the given type. This method can print an error prior to returning null to specify the cause.Please note that expressions whose
returnType
is not Object will not be parsed at all for a certain class if there's no converter from the expression's returnType to the desired class. Thus this method should only be overridden if this expression's returnType is Object.The returned expression should delegate this method to the original expression's method to prevent excessive converted expression chains (see also
ConvertedExpression
).- Specified by:
getConvertedExpression
in interfaceExpression<T>
- Specified by:
getConvertedExpression
in interfaceLiteral<T>
- Overrides:
getConvertedExpression
in classExpressionList<T>
- Parameters:
to
- The desired return type of the returned expression- Returns:
- Expression with the desired return type or null if the expression can't be converted to the given type. Returns the expression itself if it already returns the desired type.
- See Also:
-
getExpressions
- Overrides:
getExpressions
in classExpressionList<T>
- Returns:
- The internal list of expressions. Can be modified with care.
-
simplify
Description copied from interface:Simplifiable
Simplifies this object. This should be called immediately after init() returns true. If simplification is not possible, the object is returned as is.
References to the original object should be replaced with the simplified object.
Any returned object should attempt to maintain the original value ofDebuggable.toString(Event, boolean)
. An addition indicating that the value was simplified can be added in the debug string. SeeSimplifiedLiteral
for an example.
Simplification should never invalidate contracts. For example, any simplified expression should take care to return the same or a more specific type than the original expression, never a more generic type. Likewise, be sure to maintain the behavior of change() and acceptsChange(). Failure to do so can result in unexpected behavior and tricky bugs.
Finally, simplified results should updateExpression.getSource()
to point to the expression prior to simplification. This makes maintaining the above contracts easier.- Specified by:
simplify
in interfaceSimplifiable<T>
- Overrides:
simplify
in classExpressionList<T>
- Returns:
- the simplified object.
- See Also:
-