Class SectionUtils

java.lang.Object
ch.njol.skript.lang.util.SectionUtils

public final class SectionUtils extends Object
Utility methods for working with Sections and SectionExpressions.
  • Method Details

    • loadLinkedCode

      @Nullable public static @Nullable Trigger loadLinkedCode(String name, BiFunction<Runnable,Runnable,Trigger> triggerSupplier)
      This method is used for loading a section into a Trigger under different context (Events). However, unlike the traditional methods such as Section.loadCode(SectionNode, String, Runnable, Runnable, Class[]), this method assumes some level of linkage between the returned trigger and the section it was loaded from. These assumptions are:
      • Local variables (and at parse time, type hints) will be shared between the two sections.
      • Delays within the trigger are not permitted.
      As a result, this method takes action to ensure that type hints are shared and that delays are not permitted. At runtime, local variables will need to be copied by the caller using a method such as Variables.withLocalVariables(Event, Event, Runnable)
      Parameters:
      name - The name of the section being loaded.
      triggerSupplier - A function to load code using a trigger. The function has two runnable arguments. When using a method like Section.loadCode(SectionNode, String, Runnable, Runnable, Class[]), the runnable arguments represent the parameters beforeLoading and afterLoading, respectively. It is imperative that these runnable arguments be passed. If the method you are using does not support those arguments, use a different method.
      Returns:
      The result of triggerSupplier, or null if some issue occurred.