Class YAMLParser
java.lang.Object
studio.magemonkey.codex.mccore.config.parse.YAMLParser
Custom parser for YAML that preserves comments with
the key they precede.
Fixed up Feb 2024 by Travja for more actual YAML spec compliance.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddump(DataSection data, StringBuilder builder, int indent, char quote) Dumps config data to a string in YAML formatReads and then parses data from the file.Reads and then parses data from the file at the given path.parseResource(org.bukkit.plugin.Plugin plugin, String path) Reads and then parses data from an embedded plugin resource.Parses the text read in from a file.Parses the text read in from a file.voidsave(DataSection data, BufferedWriter write) Dumps the data contents into the streamvoidsave(DataSection data, File file) Dumps the data contents to a file to the given filevoidsave(DataSection data, String path) Saves config data to a file
-
Constructor Details
-
YAMLParser
public YAMLParser()
-
-
Method Details
-
parseResource
Reads and then parses data from an embedded plugin resource. If the resource does not exist or doesn't contain any data, this will return an empty DataSection object.- Parameters:
plugin- plugin containing the embedded resourcepath- path to the resource (not including the beginning slash)- Returns:
- loaded data
-
parseFile
Reads and then parses data from the file at the given path. If the file does not exist or doesn't contain any data, this will return an empty DataSection object.- Parameters:
path- path to the file load from- Returns:
- loaded data
-
parseFile
Reads and then parses data from the file. If the file does not exist or doesn't contain any data, this will return an empty DataSection object.- Parameters:
file- the file load from- Returns:
- loaded data
-
parseText
Parses the text read in from a file. If a null string is passed in, this will return an empty data section.- Parameters:
text- text to parse- Returns:
- parsed data
-
parseText
Parses the text read in from a file. If a null string is passed in, this will return an empty data section.- Parameters:
text- text to parsequote- character strings are wrapped in- Returns:
- parsed data
-
save
Saves config data to a file- Parameters:
path- path to the file
-
save
Dumps the data contents to a file to the given file- Parameters:
file- file to dump to
-
save
Dumps the data contents into the stream- Parameters:
write- stream to dump to- Throws:
IOException
-
dump
Dumps config data to a string in YAML format- Parameters:
data- data to dumpbuilder- string builder to useindent- starting indentquote- character to use for containing strings
-