Class ParserInstance

java.lang.Object
ch.njol.skript.lang.parser.ParserInstance

public final class ParserInstance extends Object
  • Constructor Details

    • ParserInstance

      public ParserInstance()
  • Method Details

    • get

      public static ParserInstance get()
      Returns:
      The ParserInstance for this thread.
    • setInactive

      public void setInactive()
      Internal method for updating a ParserInstance's isActive() status! You probably don't need to use this method!
    • setActive

      public void setActive(Script script)
      Internal method for updating a ParserInstance's isActive() 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

      public Script getCurrentScript()
      Returns:
      The Script currently being handled by this ParserInstance.
      Throws:
      SkriptAPIException - If this ParserInstance is not isActive().
    • setCurrentStructure

      public void setCurrentStructure(@Nullable Structure structure)
      Updates the Structure currently being handled by this ParserInstance.
      Parameters:
      structure - The new Structure to be handled.
    • getCurrentStructure

      public @Nullable Structure getCurrentStructure()
      Returns:
      The Structure currently being handled by this ParserInstance.
    • isCurrentStructure

      public boolean isCurrentStructure(Class<? extends Structure> structureClass)
      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

      public void setCurrentEventName(@Nullable String currentEventName)
    • getCurrentEventName

      public @Nullable String getCurrentEventName()
    • setCurrentEvents

      public void setCurrentEvents(Class<? extends org.bukkit.event.Event> @Nullable [] currentEvents)
      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

      public Class<? extends org.bukkit.event.Event> @Nullable [] getCurrentEvents()
    • isCurrentEvent

      public 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. 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 also isCurrentEvent(Class[]) for checking with multiple argument classes
    • isCurrentEvent

      @SafeVarargs public final boolean isCurrentEvent(Class<? extends org.bukkit.event.Event>... events)
      Same as isCurrentEvent(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 element requires a runtime check, you can use CollectionUtils.isAnyInstanceOf(Object, Class[]) for this, for example:
      if (!CollectionUtils.isAnyInstanceOf(e, BlockBreakEvent.class, BlockPlaceEvent.class)) return null;
      See Also:
    • setCurrentSections

      public void setCurrentSections(List<TriggerSection> currentSections)
      Updates the list of sections currently being handled by this ParserInstance.
      Parameters:
      currentSections - A new list of sections to handle.
    • getCurrentSections

      public List<TriggerSection> getCurrentSections()
      Returns:
      A list of all sections this ParserInstance is currently within.
    • getCurrentSection

      public <T extends TriggerSection> @Nullable T getCurrentSection(Class<T> sectionClass)
      Returns:
      The outermost section which is an instance of the given class. Returns null if isCurrentSection(Class) returns false.
      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

      public boolean isCurrentSection(Class<? extends TriggerSection> sectionClass)
      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

      public void setHasDelayBefore(Kleenean hasDelayBefore)
      This method should be called to indicate that the trigger will (possibly) be delayed from this point on.
      See Also:
    • getHasDelayBefore

      public Kleenean getHasDelayBefore()
      Returns:
      whether this trigger has had delays before. Any syntax elements that modify event-values, should use this (or the Kleenean provided to in SyntaxElement.init(Expression[], int, Kleenean, SkriptParser.ParseResult)) to make sure the event can't be modified when it has passed.
    • getHandlers

      public HandlerList getHandlers()
      You probably shouldn't use this method.
      Returns:
      The HandlerList containing all active log handlers.
    • setNode

      public void setNode(@Nullable Node node)
      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

      public @Nullable Node 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

      public void setIndentation(String indentation)
    • getIndentation

      public String getIndentation()
    • registerData

      public static <T extends ParserInstance.Data> void registerData(Class<T> dataClass, Function<ParserInstance,T> dataFunction)
      Registers a data class to all ParserInstances.
      Parameters:
      dataClass - the data class to register.
      dataFunction - an instance creator for the data class.
    • isRegistered

      public static boolean isRegistered(Class<? extends ParserInstance.Data> dataClass)
    • getData

      public <T extends ParserInstance.Data> T getData(Class<T> dataClass)
      Returns:
      the data object for the given class from this ParserInstance, or null (after false has been asserted) if the given data class isn't registered.
    • getCurrentOptions

      @Deprecated public HashMap<String,String> getCurrentOptions()
      Deprecated.
      Use Script.getData(Class) instead. The StructOptions.OptionsData class should be obtained. Example: script.getData(OptionsData.class)
    • getCurrentSkriptEvent

      @Deprecated public @Nullable SkriptEvent getCurrentSkriptEvent()
      Deprecated.
    • setCurrentSkriptEvent

      @Deprecated public void setCurrentSkriptEvent(@Nullable SkriptEvent currentSkriptEvent)
    • deleteCurrentSkriptEvent

      @Deprecated public void deleteCurrentSkriptEvent()
      Deprecated.
    • setCurrentScript

      @Deprecated public void setCurrentScript(@Nullable Config currentScript)
      Deprecated.
      Addons should no longer be modifying this.