Interface Simplifiable<S extends SyntaxElement>
- Type Parameters:
S
- the type of the simplified object
- All Known Subinterfaces:
DefaultExpression<T>
,Expression<T>
,KeyProviderExpression<T>
,KeyReceiverExpression<T>
,Literal<T>
- All Known Implementing Classes:
ContainerExpression
,ConvertedExpression
,ConvertedKeyProviderExpression
,ConvertedLiteral
,ch.njol.skript.expressions.base.EventValueExpression
,ExprBreedingFamily
,ExprCausingEntity
,ExprCreatedDamageSource
,ExprCurrentInputKeys
,ExprDamageLocation
,ExprDamageType
,ExprDirectEntity
,ExprDisplayBillboard
,ExprDisplayBrightness
,ExprDisplayGlowOverride
,ExprDisplayHeightWidth
,ExprDisplayInterpolation
,ExprDisplayShadow
,ExprDisplayTeleportDuration
,ExprDisplayTransformationRotation
,ExprDisplayTransformationScaleTranslation
,ExprDisplayViewRange
,ExpressionList
,ExprFishingApproachAngle
,ExprFishingBiteTime
,ExprFishingHook
,ExprFishingHookEntity
,ExprFishingWaitTime
,ExprFoodExhaustion
,ExprFurnaceEventItems
,ExprFurnaceSlot
,ExprFurnaceTime
,ExprItemDisplayTransform
,ExprItemOfEntity
,ExprLoot
,ExprLootContext
,ExprLootContextEntity
,ExprLootContextLocation
,ExprLootContextLooter
,ExprLootContextLuck
,ExprLootItems
,ExprLootTable
,ExprLootTableFromString
,ExprLootTableSeed
,ExprLoveTime
,ExprQuaternionAxisAngle
,ExprRotate
,ExprSecCreateLootContext
,ExprSecDamageSource
,ExprSourceLocation
,ExprTag
,ExprTagContents
,ExprTagKey
,ExprTagsOf
,ExprTagsOfType
,ExprTextDisplayAlignment
,ExprTextDisplayLineWidth
,ExprTextDisplayOpacity
,ExprTextOf
,LiteralList
,LiteralString
,ch.njol.skript.expressions.base.PropertyExpression
,ch.njol.skript.expressions.base.SectionExpression
,SimpleExpression
,SimpleLiteral
,ch.njol.skript.expressions.base.SimplePropertyExpression
,SimplifiedLiteral
,UnparsedLiteral
,Variable
,VariableString
public interface Simplifiable<S extends SyntaxElement>
Represents an object that can be simplified to a simpler
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.
SyntaxElement
. For example, a complex math equation
can be simplified to a single number Literal
if all the inputs are
Literal
s.
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.
-
Method Summary
-
Method Details
-
simplify
S simplify()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.- Returns:
- the simplified object.
- See Also:
-