Package ch.njol.skript.lang
Interface ReturnHandler<T>
- All Known Implementing Classes:
ReturnableTrigger
,ScriptFunction
public interface ReturnHandler<T>
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
default void
Loads the code in the givenSectionNode
using the same logic asSection.loadCode(SectionNode)
and pushes the section onto the return handler stack
This method may only be called by aSection
default ReturnableTrigger
<T> loadReturnableSectionCode
(SectionNode node, String name, Class<? extends org.bukkit.event.Event>[] events) Loads the code in the givenSectionNode
using the same logic asSection.loadCode(SectionNode, String, Class[])
and pushes the section onto the return handler stack
This method may only be called by aSection
default ReturnableTrigger
<T> loadReturnableTrigger
(SectionNode node, String name, SkriptEvent event) Loads the code in the givenSectionNode
into aReturnableTrigger
.void
returnValues
(org.bukkit.event.Event event, Expression<? extends T> value) Called whenEffReturn
is executedThe return type of this return handler, or null if it can't accept return values in this context (e.g.
-
Method Details
-
loadReturnableSectionCode
Loads the code in the givenSectionNode
using the same logic asSection.loadCode(SectionNode)
and pushes the section onto the return handler stack
This method may only be called by aSection
- Throws:
SkriptAPIException
- if this return handler is not aSection
-
loadReturnableSectionCode
@NonExtendable default ReturnableTrigger<T> loadReturnableSectionCode(SectionNode node, String name, Class<? extends org.bukkit.event.Event>[] events) Loads the code in the givenSectionNode
using the same logic asSection.loadCode(SectionNode, String, Class[])
and pushes the section onto the return handler stack
This method may only be called by aSection
- Parameters:
node
- the section nodename
- the name of the event(s) being usedevents
- the event(s) during the section's execution- Returns:
- a returnable trigger containing the loaded section. This should be stored and used to run the section one or more times
- Throws:
SkriptAPIException
- if this return handler is not aSection
-
loadReturnableTrigger
@NonExtendable default ReturnableTrigger<T> loadReturnableTrigger(SectionNode node, String name, SkriptEvent event) Loads the code in the givenSectionNode
into aReturnableTrigger
.
This is a general method to load a section node without extra logic done to theParserInstance
. The calling code is expected to manage theParserInstance
accordingly, which may vary depending on where the code being loaded is located and what state theParserInstance
is in.- Parameters:
node
- the section node to loadname
- the name of the triggerevent
- theSkriptEvent
of the trigger- Returns:
- a returnable trigger containing the loaded section node
-
returnValues
Called whenEffReturn
is executed- Parameters:
event
- the event providing contextvalue
- an expression representing the value(s) to return
-
isSingleReturnValue
boolean isSingleReturnValue()- Returns:
- whether this return handler may accept multiple return values
-
returnValueType
The return type of this return handler, or null if it can't accept return values in this context (e.g. a function without a return type).- Returns:
- the return type
-