Class SectionConfiguration
java.lang.Object
io.github.syst3ms.skriptparser.lang.entries.SectionConfiguration
The SectionConfiguration class can be used to create simple and efficient data sections
that only allow specific keys and values. Skript's command structure is the perfect example:
command /hello:
permission: plugin.hello
permission message: "You don't have the permission to do that!"
cooldown: 1 minute
trigger:
broadcast "Hello!"
This example portrays the many features this class has.
- Keys can be omitted if they are optional.
- Whole sections can be added as value.
- Some keys only allow specific types.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiongetData()getSection(String key) getStringList(String key) <T> Optional<T> Tries to retrieve a value from its key and cast it to the correct class.booleanloadConfiguration(@Nullable CodeSection parent, FileSection section, ParserState parserState, SkriptLogger logger) Load the data of thisSectionConfigurationinto to thedata mapusing a FileSection instance.
-
Method Details
-
loadConfiguration
public boolean loadConfiguration(@Nullable @Nullable CodeSection parent, FileSection section, ParserState parserState, SkriptLogger logger) Load the data of thisSectionConfigurationinto to thedata mapusing a FileSection instance. This method should be called only once and will throw an error if attempting to load the configuration multiple times. The default use-case would be to load the configuration inside CodeSection'sloadmethod.- Parameters:
parent- the parent sectionsection- the file sectionparserState- the parse statelogger- the logger- Returns:
- whether the section was loaded successfully or errors occurred
-
getParent
-
getData
-
getEntries
-
getValue
-
getValue
Tries to retrieve a value from its key and cast it to the correct class. This can only be used when you register your option as aliteral, otherwise, the option will likely be parsed as a String and throw an exception. Options that allow literal lists are saved as an array. Returns an empty Optional if the key is not present. This is only possible for optional keys.- Type Parameters:
T- the type of the value- Parameters:
key- the keycls- the class to cast to- Returns:
- the value cast to the given class, or an empty Optional if the key was not specified
-
getString
-
getStringList
-
getSection
- Parameters:
key- the key- Returns:
- the enclosed code section, or an empty Optional if the key was not specified
-