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
ConstructorDescriptionConfig
(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 TypeMethodDescriptionint
boolean
compareValues
(Config other, String... excluded) Compares the keys and values of this Config and another.@Nullable String
Gets an entry node's value at the designated path@Nullable String
Splits the given path at the dot character and passes the result toget(String...)
.@Nullable File
getFile()
@Nullable Path
getPath()
boolean
isEmpty()
void
Sets all staticOption
fields of the given class to the values from this configvoid
Sets allOption
fields of the given object to the values from this configvoid
Saves the config to a file.boolean
Sets this config's values to those in the given config.boolean
boolean
validate
(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 allOption
fields of the given object to the values from this config -
load
Sets all staticOption
fields of the given class to the values from this config -
compareTo
- Specified by:
compareTo
in interfaceComparable<Config>
-