Class Structure
java.lang.Object
org.skriptlang.skript.lang.structure.Structure
- All Implemented Interfaces:
Debuggable
,SyntaxElement
- Direct Known Subclasses:
SkriptEvent
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 sub
Node
s
through registered EntryData
.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Priorities are used to determine the order in which Structures should be loaded.static class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Structure.Priority
The defaultStructure.Priority
of every registered Structure. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal EntryContainer
Deprecated.This method will be removed in a future version.The priority of a Structure determines the order in which it should be loaded.final boolean
init
(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) Called just after the constructor.abstract boolean
init
(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult, @Nullable EntryContainer entryContainer) The initialization phase of a Structure.abstract boolean
load()
The second phase of Structure loading.static @Nullable Structure
static @Nullable Structure
parse
(String expr, Node node, @Nullable String defaultError, Iterator<? extends StructureInfo<? extends Structure>> iterator) boolean
postLoad()
The third and final phase of Structure loading.void
Called when this structure is unloaded.boolean
preLoad()
The first phase of Structure loading.toString()
Should returntoString
(null, false)void
unload()
Called when this structure is unloaded.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.njol.skript.lang.Debuggable
toString
Methods inherited from interface ch.njol.skript.lang.SyntaxElement
getParser
-
Field Details
-
DEFAULT_PRIORITY
The defaultStructure.Priority
of every registered Structure.
-
-
Constructor Details
-
Structure
public Structure()
-
-
Method Details
-
getEntryContainer
Deprecated.This method will be removed in a future version. If the EntryContainer is needed outside ofinit(Literal[], int, ParseResult, EntryContainer)
, the Structure should keep a reference to it. -
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 interfaceSyntaxElement
- 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 matchedisDelayed
- 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
The priority of a Structure determines the order in which it should be loaded. For more information, see the javadoc ofStructure.Priority
.- Returns:
- The priority of this Structure. By default, this is
DEFAULT_PRIORITY
.
-
toString
Description copied from interface:Debuggable
Should returntoString
(null, false)- Specified by:
toString
in interfaceDebuggable
- Overrides:
toString
in classObject
-
parse
-
parse
-