Package ch.njol.skript.lang.util
Class SectionUtils
java.lang.Object
ch.njol.skript.lang.util.SectionUtils
Utility methods for working with
Section
s and SectionExpression
s.-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable Trigger
loadLinkedCode
(String name, BiFunction<Runnable, Runnable, Trigger> triggerSupplier) This method is used for loading a section into aTrigger
under different context (Event
s).
-
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 aTrigger
under different context (Event
s). 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 parametersbeforeLoading
andafterLoading
, 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.
-