Class Statement

java.lang.Object
io.github.syst3ms.skriptparser.lang.Statement
All Implemented Interfaces:
SyntaxElement
Direct Known Subclasses:
CodeSection, Effect

public abstract class Statement extends Object implements SyntaxElement
The base class for any runnable line of code inside of a script.
See Also:
  • Field Details

  • Constructor Details

    • Statement

      public Statement()
  • Method Details

    • run

      public abstract boolean run(TriggerContext ctx)
      Executes this Statement
      Parameters:
      ctx - the event
    • getParent

      public Optional<? extends CodeSection> getParent()
      Returns:
      the parent of this Statement
    • setParent

      public Statement setParent(CodeSection section)
      Sets the parent CodeSection of this Statement
      Parameters:
      section - the parent
      Returns:
      this Statement
    • getNext

      public final Optional<? extends Statement> getNext()
      Returns:
      the Statement after this one in the file. If this Statement is the last item of the section, returns the item after said section. If this Statement is the very last item of a trigger, returns null
    • setNext

      public Statement setNext(@Nullable @Nullable Statement next)
      Sets the Statement that is placed after this Statement in the file. You can assume that the next statement of the next parameter is known if it has such a statement.
      Parameters:
      next - the Statement that is following this one
      Returns:
      this statement
    • walk

      public Optional<? extends Statement> walk(TriggerContext ctx)
      By default, runs run(TriggerContext) ; returns getNext() if it returns true, or null otherwise. Note that if this method is overridden, then the implementation of run(TriggerContext) doesn't matter.
      Parameters:
      ctx - the event
      Returns:
      the next item to be ran, or null if this is the last item to be executed
    • runAll

      public static boolean runAll(Statement start, TriggerContext context)
      Runs all code starting at a given point sequentially
      Parameters:
      start - the Statement the method should first run
      context - the context
      Returns:
      true if the code ran normally, and false if any exception occurred