Class Structure

java.lang.Object
org.skriptlang.skript.lang.structure.Structure
All Implemented Interfaces:
Debuggable, SyntaxElement
Direct Known Subclasses:
SkriptEvent

public abstract class Structure extends Object implements SyntaxElement, Debuggable
Structures are the root elements in every script. They are essentially the "headers". Events and functions are both a type of Structure. However, each one has its own parsing requirements, order, and defined structure within. Structures may also contain "entries" that hold values or sections of code. The values of these entries can be obtained by parsing the Structure's subNodes through registered EntryData.
  • Field Details

  • Constructor Details

    • Structure

      public Structure()
  • Method Details

    • getEntryContainer

      public final EntryContainer getEntryContainer()
      Returns:
      An EntryContainer containing this Structure's EntryData and Node parse results. Please note that this Structure MUST have been initialized for this to work.
    • init

      public final boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult)
      Description copied from interface: SyntaxElement
      Called just after the constructor.
      Specified by:
      init in interface SyntaxElement
      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 matched
      isDelayed - 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:
    • init

      public abstract boolean init(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult, EntryContainer entryContainer)
    • preLoad

      public boolean preLoad()
      The first phase of Structure loading. During this phase, all Structures across all loading scripts are loaded with respect to their priorities.
      Returns:
      Whether preloading was successful. An error should be printed prior to returning false to specify the cause.
    • load

      public abstract boolean load()
      The second phase of Structure loading. During this phase, all Structures across all loading scripts are loaded with respect to their priorities.
      Returns:
      Whether loading was successful. An error should be printed prior to returning false to specify the cause.
    • postLoad

      public boolean postLoad()
      The third and final phase of Structure loading. During this phase, all Structures across all loading scripts are loaded with respect to their priorities. This method is primarily designed for Structures that wish to execute actions after most other Structures have finished loading.
      Returns:
      Whether postLoading was successful. An error should be printed prior to returning false to specify the cause.
    • unload

      public void unload()
      Called when this structure is unloaded.
    • postUnload

      public void postUnload()
      Called when this structure is unloaded. This method is primarily designed for Structures that wish to execute actions after most other Structures have finished unloading.
    • getPriority

      public Structure.Priority getPriority()
      The priority of a Structure determines the order in which it should be loaded. For more information, see the javadoc of Structure.Priority.
      Returns:
      The priority of this Structure. By default, this is DEFAULT_PRIORITY.
    • toString

      public String toString()
      Description copied from interface: Debuggable
      Should return toString(null, false)
      Specified by:
      toString in interface Debuggable
      Overrides:
      toString in class Object
    • parse

      public static @Nullable Structure parse(String expr, SectionNode sectionNode, @Nullable String defaultError)