Package ch.njol.skript.config
Class Config
java.lang.Object
ch.njol.skript.config.Config
- All Implemented Interfaces:
Comparable<Config>
Represents a config file.
-
Constructor Summary
ConstructorsConstructorDescriptionConfig(InputStream source, String fileName, boolean simple, boolean allowEmptySections, String defaultSeparator) Config(InputStream source, String fileName, @Nullable File file, boolean simple, boolean allowEmptySections, String defaultSeparator) Config(String s, String fileName, boolean simple, boolean allowEmptySections, String defaultSeparator) For testing -
Method Summary
Modifier and TypeMethodDescriptionintbooleancompareValues(Config other, String... excluded) Compares the keys and values of this Config and another.@Nullable StringGets an entry node's value at the designated path@Nullable StringSplits the given path at the dot character and passes the result toget(String...).@Nullable FilegetFile()@Nullable PathgetPath()booleanisEmpty()voidSets all staticOptionfields of the given class to the values from this configvoidSets allOptionfields of the given object to the values from this configvoidSaves the config to a file.booleanSets this config's values to those in the given config.booleanbooleanvalidate(SectionValidator validator)
-
Constructor Details
-
Config
public Config(InputStream source, String fileName, @Nullable @Nullable File file, boolean simple, boolean allowEmptySections, String defaultSeparator) throws IOException - Throws:
IOException
-
Config
public Config(InputStream source, String fileName, boolean simple, boolean allowEmptySections, String defaultSeparator) throws IOException - Throws:
IOException
-
Config
public Config(File file, boolean simple, boolean allowEmptySections, String defaultSeparator) throws IOException - Throws:
IOException
-
Config
public Config(Path file, boolean simple, boolean allowEmptySections, String defaultSeparator) throws IOException - Throws:
IOException
-
Config
public Config(String s, String fileName, boolean simple, boolean allowEmptySections, String defaultSeparator) throws IOException For testing- Parameters:
s-fileName-simple-allowEmptySections-defaultSeparator-- Throws:
IOException
-
-
Method Details
-
getMainNode
-
getFileName
-
save
Saves the config to a file.- Parameters:
f- The file to save to- Throws:
IOException- If the file could not be written to.
-
setValues
Sets this config's values to those in the given config.Used by Skript to import old settings into the updated config. The return value is used to not modify the config if no new options were added.
- Parameters:
other-- Returns:
- Whether the configs' keys differ, i.e. false == configs only differ in values, not keys.
-
setValues
-
compareValues
Compares the keys and values of this Config and another.- Parameters:
other- The other Config.excluded- Keys to exclude from this comparison.- Returns:
- True if there are differences in the keys and their values of this Config and the other Config.
-
getFile
-
getPath
-
getSeparator
- Returns:
- The most recent separator. Only useful while the file is loading.
-
getSaveSeparator
- Returns:
- A separator string useful for saving, e.g. ": " or " = ".
-
getByPath
Splits the given path at the dot character and passes the result toget(String...).- Parameters:
path-- Returns:
- get(path.split("\\."))
-
get
Gets an entry node's value at the designated path- Parameters:
path-- Returns:
- The entry node's value at the location defined by path or null if it either doesn't exist or is not an entry.
-
isEmpty
public boolean isEmpty() -
toMap
-
validate
-
load
Sets allOptionfields of the given object to the values from this config -
load
Sets all staticOptionfields of the given class to the values from this config -
compareTo
- Specified by:
compareToin interfaceComparable<Config>
-