Package ch.njol.skript.lang
Class Section.SectionContext
java.lang.Object
ch.njol.skript.lang.parser.ParserInstance.Data
ch.njol.skript.lang.Section.SectionContext
- Enclosing class:
Section
-
Field Summary
Modifier and TypeFieldDescriptionprotected @Nullable Debuggable
protected SectionNode
protected List
<TriggerItem> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<Syntax extends SyntaxElement & Debuggable>
booleanclaim
(Syntax syntax) Marks the section this context represents as having been 'claimed' by the current syntax.boolean
claimed()
Used to keep track of whether a syntax is managing the current section.protected <T> T
modify
(SectionNode sectionNode, List<TriggerItem> triggerItems, Supplier<T> supplier) Modifies this SectionContext temporarily, for the duration of theSupplier.get()
call, reverting the changes afterwards.Methods inherited from class ch.njol.skript.lang.parser.ParserInstance.Data
getParser, onCurrentEventsChange, onCurrentScriptChange
-
Field Details
-
sectionNode
-
triggerItems
-
owner
-
-
Constructor Details
-
SectionContext
-
-
Method Details
-
modify
protected <T> T modify(SectionNode sectionNode, List<TriggerItem> triggerItems, Supplier<T> supplier) Modifies this SectionContext temporarily, for the duration of theSupplier.get()
call, reverting the changes afterwards.
This must be used instead of manually modifying the fields of this instance, unless you also revert the changes afterwards.
See Pull Request #4353 and Issue #4473. -
claim
Marks the section this context represents as having been 'claimed' by the current syntax. Once a syntax has claimed a section, another syntax may not claim it.- Parameters:
syntax
- The syntax that wants to own this section- Returns:
- True if this was successfully claimed, false if it was already owned
-
claimed
public boolean claimed()Used to keep track of whether a syntax is managing the current section. Every section needs exactly one manager. This is used to detect errors such as:- Two syntax both want to manage the section (e.g. an effectsection and an expression or two expressions).
- No syntax wants to manage the section.
- Returns:
- Whether a syntax is already managing this section context
-