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

      @Deprecated @ScheduledForRemoval public final EntryContainer getEntryContainer()
      Deprecated.
      This method will be removed in a future version. If the EntryContainer is needed outside of init(Literal[], int, ParseResult, EntryContainer), the Structure should keep a reference to it.
      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. This method is not usable for simple structures.
    • init

      public final boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult)
      Description copied from interface: SyntaxElement
      Called just after the constructor.
      Specified by:
      init in interface SyntaxElement
      Parameters:
      expressions - 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, @Nullable @Nullable EntryContainer entryContainer)
      The initialization phase of a Structure. Typically, this should be used for preparing fields (e.g. handling arguments, parse tags) Logic such as trigger loading should be saved for a loading phase (e.g. load()).
      Returns:
      Whether initialization was successful.
    • 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

      @Nullable public static @Nullable Structure parse(String expr, Node node, @Nullable @Nullable String defaultError)
    • parse

      @Nullable public static @Nullable Structure parse(String expr, Node node, @Nullable @Nullable String defaultError, Iterator<? extends StructureInfo<? extends Structure>> iterator)