Package ch.njol.skript.lang.parser
Class ParserInstance
java.lang.Object
ch.njol.skript.lang.parser.ParserInstance
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An abstract class for addons that want to add data bound to a ParserInstance. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Deprecated.static ParserInstance
get()
@Nullable String
Class<? extends org.bukkit.event.Event> @Nullable []
Deprecated.UseScript.getData(Class)
instead.<T extends TriggerSection>
@Nullable TgetCurrentSection
(Class<T> sectionClass) <T extends TriggerSection>
@NotNull List<T>getCurrentSections
(Class<T> sectionClass) @Nullable SkriptEvent
Deprecated.@Nullable Structure
<T extends ParserInstance.Data>
TYou probably shouldn't use this method.@Nullable Node
getNode()
boolean
isActive()
boolean
isCurrentEvent
(Class<? extends org.bukkit.event.Event> event) This method checks whether at least one of the current event classes is covered by the argument event class (i.e.final boolean
isCurrentEvent
(Class<? extends org.bukkit.event.Event>... events) Same asisCurrentEvent(Class)
, but allows for plural argument input.boolean
isCurrentSection
(Class<? extends TriggerSection> sectionClass) final boolean
isCurrentSection
(Class<? extends TriggerSection>... sectionClasses) boolean
isCurrentStructure
(Class<? extends Structure> structureClass) final boolean
isCurrentStructure
(Class<? extends Structure>... structureClasses) static boolean
isRegistered
(Class<? extends ParserInstance.Data> dataClass) static <T extends ParserInstance.Data>
voidregisterData
(Class<T> dataClass, Function<ParserInstance, T> dataFunction) Registers a data class to allParserInstance
s.void
Internal method for updating a ParserInstance'sisActive()
status! You probably don't need to use this method!final void
setCurrentEvent
(String name, @Nullable Class<? extends org.bukkit.event.Event>... events) void
setCurrentEventName
(@Nullable String currentEventName) void
setCurrentEvents
(Class<? extends org.bukkit.event.Event> @Nullable [] currentEvents) void
setCurrentScript
(@Nullable Config currentScript) Deprecated.Addons should no longer be modifying this.void
setCurrentSections
(List<TriggerSection> currentSections) Updates the list of sections currently being handled by this ParserInstance.void
setCurrentSkriptEvent
(@Nullable SkriptEvent currentSkriptEvent) Deprecated.void
setCurrentStructure
(@Nullable Structure structure) Updates the Structure currently being handled by this ParserInstance.void
setHasDelayBefore
(Kleenean hasDelayBefore) This method should be called to indicate that the trigger will (possibly) be delayed from this point on.void
Internal method for updating a ParserInstance'sisActive()
status! You probably don't need to use this method!void
setIndentation
(String indentation) void
-
Constructor Details
-
ParserInstance
public ParserInstance()
-
-
Method Details
-
get
- Returns:
- The
ParserInstance
for this thread.
-
setInactive
public void setInactive()Internal method for updating a ParserInstance'sisActive()
status! You probably don't need to use this method! -
setActive
Internal method for updating a ParserInstance'sisActive()
status! You probably don't need to use this method! -
isActive
public boolean isActive()- Returns:
- Whether this ParserInstance is currently active.
An active ParserInstance may be loading, parsing, or unloading scripts.
Please note that some methods may be unavailable if this method returns
false
. You should consult the documentation of the method you are calling.
-
getCurrentScript
- Returns:
- The Script currently being handled by this ParserInstance.
- Throws:
SkriptAPIException
- If this ParserInstance is notisActive()
.
-
setCurrentStructure
Updates the Structure currently being handled by this ParserInstance.- Parameters:
structure
- The new Structure to be handled.
-
getCurrentStructure
- Returns:
- The Structure currently being handled by this ParserInstance.
-
isCurrentStructure
- Returns:
- Whether
getCurrentStructure()
is an instance of the given Structure class.
-
isCurrentStructure
@SafeVarargs public final boolean isCurrentStructure(Class<? extends Structure>... structureClasses) - Returns:
- Whether
getCurrentStructure()
is an instance of one of the given Structure classes.
-
setCurrentEventName
-
getCurrentEventName
-
setCurrentEvents
- Parameters:
currentEvents
- The events that may be present during execution. An instance of the events present in the provided array MUST be used to execute any loaded items.
-
setCurrentEvent
@SafeVarargs public final void setCurrentEvent(String name, @Nullable Class<? extends org.bukkit.event.Event>... events) -
deleteCurrentEvent
public void deleteCurrentEvent() -
getCurrentEvents
-
isCurrentEvent
This method checks whether at least one of the current event classes is covered by the argument event class (i.e. equal to the class or a subclass of it).
Using this method in an event-specific syntax element requires a runtime check, for example
if (!(e instanceof BlockBreakEvent)) return null;
This check is required because there can be more than 1 event class at parse-time, but this method only checks if one of them matches the argument class.
See alsoisCurrentEvent(Class[])
for checking with multiple argument classes -
isCurrentEvent
Same asisCurrentEvent(Class)
, but allows for plural argument input.
This means that this method will return whether any of the current event classes is covered by any of the argument classes.
Using this method in an event-specific syntax elementrequires a runtime check
, you can useCollectionUtils.isAnyInstanceOf(Object, Class[])
for this, for example:
if (!CollectionUtils.isAnyInstanceOf(e, BlockBreakEvent.class, BlockPlaceEvent.class)) return null;
- See Also:
-
setCurrentSections
Updates the list of sections currently being handled by this ParserInstance.- Parameters:
currentSections
- A new list of sections to handle.
-
getCurrentSections
- Returns:
- A list of all sections this ParserInstance is currently within.
-
getCurrentSection
- Returns:
- The outermost section which is an instance of the given class.
Returns
null
ifisCurrentSection(Class)
returnsfalse
. - See Also:
-
getCurrentSections
@NotNull public <T extends TriggerSection> @NotNull List<T> getCurrentSections(Class<T> sectionClass) - Returns:
- a
List
of current sections that are an instance of the given class. Modifications to the returned list are not saved. - See Also:
-
isCurrentSection
- Returns:
- Whether
getCurrentSections()
contains a section instance of the given class (or subclass).
-
isCurrentSection
@SafeVarargs public final boolean isCurrentSection(Class<? extends TriggerSection>... sectionClasses) - Returns:
- Whether
getCurrentSections()
contains a section instance of one of the given classes (or subclasses).
-
setHasDelayBefore
This method should be called to indicate that the trigger will (possibly) be delayed from this point on.- See Also:
-
getHasDelayBefore
- Returns:
- whether this trigger has had delays before.
Any syntax elements that modify event-values, should use this
(or the
Kleenean
provided to inSyntaxElement.init(Expression[], int, Kleenean, SkriptParser.ParseResult)
) to make sure the event can't be modified when it has passed.
-
getHandlers
You probably shouldn't use this method.- Returns:
- The
HandlerList
containing all active log handlers.
-
setNode
- Parameters:
node
- The node to mark as being handled. This is mainly used for logging. Null means to mark it as no node currently being handled (that the ParserInstance is aware of).
-
getNode
- Returns:
- The node currently marked as being handled. This is mainly used for logging. Null indicates no node is currently being handled (that the ParserInstance is aware of).
-
setIndentation
-
getIndentation
-
registerData
public static <T extends ParserInstance.Data> void registerData(Class<T> dataClass, Function<ParserInstance, T> dataFunction) Registers a data class to allParserInstance
s.- Parameters:
dataClass
- the data class to register.dataFunction
- an instance creator for the data class.
-
isRegistered
-
getData
- Returns:
- the data object for the given class from this
ParserInstance
, or null (afterfalse
has been asserted) if the given data class isn't registered.
-
getCurrentOptions
Deprecated.UseScript.getData(Class)
instead. TheStructOptions.OptionsData
class should be obtained. Example:script.getData(OptionsData.class)
-
getCurrentSkriptEvent
Deprecated. -
setCurrentSkriptEvent
Deprecated. -
deleteCurrentSkriptEvent
Deprecated.UsesetCurrentStructure(Structure)
with 'null'. -
setCurrentScript
Deprecated.Addons should no longer be modifying this.
-
setCurrentStructure(Structure)
with 'null'.