Class ConditionalExpression

java.lang.Object
io.github.syst3ms.skriptparser.lang.base.ConditionalExpression
All Implemented Interfaces:
Expression<Boolean>, SyntaxElement
Direct Known Subclasses:
CondExprCompare, CondExprContains, CondExprDateCompare, CondExprIsEmpty, CondExprMatch, CondExprStartsEnds, PropertyConditional

public abstract class ConditionalExpression extends Object implements Expression<Boolean>
A base class for all boolean expressions (i.e Expression<Boolean>) that should be treated as "conditional". This means that they can't be used "as-is" (e.g in trying to set a variable to them). Instead, they can only be used either in :
  1. Conditions (if and else if)
  2. While loops
  3. Expression whose boolean parameters are declared as %=boolean% inside their syntax.
The simplest way to use a value of a conditional expression as if it were a regular boolean expression is to use the whether %=boolean% expression. Other, non-conditional boolean expressions should implement Expression<Boolean>
See Also:
  • Constructor Details

    • ConditionalExpression

      public ConditionalExpression()
  • Method Details

    • getValues

      public Boolean[] getValues(TriggerContext ctx)
      Description copied from interface: Expression
      Retrieves 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:
      getValues in interface Expression<Boolean>
      Parameters:
      ctx - the event
      Returns:
      an array of the values
      See Also:
    • check

      public abstract boolean check(TriggerContext ctx)
    • isNegated

      public boolean isNegated()
      Whether a condition is negated. This is used in conjunction with setNegated(boolean).
      Returns:
      whether the condition is negated
    • setNegated

      public void setNegated(boolean negated)
      Decides whether the output of a condition should be inverted in order to create a "negated" condition. This was made a built-in method because it is a very common feature of conditions.
      Parameters:
      negated - whether the condition should be negated