Class ExprStringColor
- All Implemented Interfaces:
Debuggable, Expression<Object>, Loopable<Object>, Simplifiable<Expression<? extends Object>>, SyntaxElement, RuntimeErrorProducer, SyntaxRuntimeErrorProducer
@Name("String Colors")
@Description({"Retrieve the first, the last, or all of the color objects or color codes of a string.","The retrieved color codes of the string will be formatted with the color symbol."})
@Example("set {_colors::*} to the string colors of \"<red>hey<blue>yo\"") @Example("set {_color} to the first string color code of \"&aGoodbye!\"\nsend \"%{_color}%Howdy!\" to all players\n")
@Since("2.11")
public class ExprStringColor
extends ch.njol.skript.expressions.base.PropertyExpression<String,Object>
-
Field Summary
Fields inherited from class ch.njol.skript.expressions.base.PropertyExpression
DEFAULT_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Object[]Class<?> Gets the return type of this expression.booleaninit(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) Called just after the constructor andSyntaxElement.preInit().booleanisSingle()Class<?>[]For expressions that might return multiple (incalculable at parse time) types, this provides a list of all possible types.static voidregister(SyntaxRegistry syntaxRegistry) Expression<?> simplify()Simplifies this object.toString(@Nullable org.bukkit.event.Event event, boolean debug) Methods inherited from class ch.njol.skript.expressions.base.PropertyExpression
get, get, getAll, getAnd, getDefaultPatterns, getExpr, getPatterns, infoBuilder, register, register, registerDefault, registerDefault, setExprMethods inherited from class SimpleExpression
acceptChange, change, check, check, check, getArray, getConvertedExpr, getConvertedExpression, getNode, getSingle, getSource, getTime, isDefault, isLoopOf, iterator, preInit, setTime, setTime, setTime, setTime, setTime, supportsLoopPeeking, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Expression
beforeChange, canBeSingle, canReturn, canReturnAnyOf, changeInPlace, changeInPlace, getAcceptedChangeModes, getOptionalSingle, getSyntaxTypeName, returnNestedStructures, returnsNestedStructures, stream, streamAllMethods inherited from interface RuntimeErrorProducer
error, error, getRuntimeErrorManager, warning, warningMethods inherited from interface SyntaxElement
getParserMethods inherited from interface SyntaxRuntimeErrorProducer
getErrorSource
-
Constructor Details
-
ExprStringColor
public ExprStringColor()
-
-
Method Details
-
register
-
init
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) Description copied from interface:SyntaxElementCalled just after the constructor andSyntaxElement.preInit().- Parameters:
exprs- 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 matchedisDelayed- 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:
-
get
-
getReturnType
Description copied from interface:ExpressionGets the return type of this expression.- Returns:
- A supertype of any objects returned by
Expression.getSingle(Event)and the component type of any arrays returned byExpression.getArray(Event)
-
possibleReturnTypes
Description copied from interface:ExpressionFor expressions that might return multiple (incalculable at parse time) types, this provides a list of all possible types. Use cases include: expressions that depend on the return type of their input.- Returns:
- A list of all possible types this might return
-
isSingle
public boolean isSingle()- Specified by:
isSinglein interfaceExpression<Object>- Overrides:
isSinglein classch.njol.skript.expressions.base.PropertyExpression<String,Object> - Returns:
- true if this expression will ever only return one value at most, false if it can return multiple values.
-
simplify
Description copied from interface:SimplifiableSimplifies 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. SeeSimplifiedLiteralfor 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:
simplifyin interfaceExpression<Object>- Specified by:
simplifyin interfaceSimplifiable<Expression<? extends Object>>- Overrides:
simplifyin classch.njol.skript.expressions.base.PropertyExpression<String,Object> - Returns:
- the simplified object.
- See Also:
-
toString
- 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
-