Class SectionUtils
java.lang.Object
ch.njol.skript.lang.util.SectionUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable TriggerloadDelayableLinkedCode(String name, BiFunction<Runnable, Runnable, Trigger> triggerSupplier) A variant ofloadLinkedCode(String, BiFunction)that permits delays within the loaded trigger.static @Nullable TriggerloadLinkedCode(String name, BiFunction<Runnable, Runnable, Trigger> triggerSupplier) This method is used for loading a section into aTriggerunder different context (Events).
-
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 aTriggerunder different context (Events). However, unlike the traditional methods such asSection.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.
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 likeSection.loadCode(SectionNode, String, Runnable, Runnable, Class[]), the runnable arguments represent the parametersbeforeLoadingandafterLoading, 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.
-
loadDelayableLinkedCode
@Nullable public static @Nullable Trigger loadDelayableLinkedCode(String name, BiFunction<Runnable, Runnable, Trigger> triggerSupplier) A variant ofloadLinkedCode(String, BiFunction)that permits delays within the loaded trigger. Type hints are still shared with the outer section, but delays inside the body do not cause a parse-time error. The caller is responsible for correctly handling any delays encountered while executing the returned trigger (e.g. by scheduling execution asynchronously or on a separate tick).- Parameters:
name- The name of the section being loaded.triggerSupplier- A function to load code using a trigger. SeeloadLinkedCode(String, BiFunction)for details on the expected behavior of this supplier.- Returns:
- The result of
triggerSupplier, or null if some issue occurred. - See Also:
-