Package dev.dhyces.compostbag
Class SimpleConfig
java.lang.Object
dev.dhyces.compostbag.SimpleConfig
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Method Summary
Modifier and TypeMethodDescriptionbooleandelete()deletes the config file from the filesystemDeprecated.booleangetOrDefault(String key, boolean def) Returns boolean value from config corresponding to the given key, or the default boolean if the key is missing.doublegetOrDefault(String key, double def) Returns double value from config corresponding to the given key, or the default string if the key is missing or invalid.intgetOrDefault(String key, int def) Returns integer value from config corresponding to the given key, or the default integer if the key is missing or invalid.getOrDefault(String key, String def) Returns string value from config corresponding to the given key, or the default string if the key is missing.booleanisBroken()If any error occurred during loading or reading from the config a 'broken' flag is set, indicating that the config's state is undefined and should be discarded using `delete()`static SimpleConfig.ConfigRequestCreates new config request object, ideally `namespace` should be the name of the mod id of the requesting mod
-
Method Details
-
of
Creates new config request object, ideally `namespace` should be the name of the mod id of the requesting mod- Parameters:
filename- - name of the config file- Returns:
- new config request object
-
get
Deprecated.Queries a value from config, returns `null` if the key does not exist.- Returns:
- value corresponding to the given key
- See Also:
-
getOrDefault
Returns string value from config corresponding to the given key, or the default string if the key is missing.- Returns:
- value corresponding to the given key, or the default value
-
getOrDefault
Returns integer value from config corresponding to the given key, or the default integer if the key is missing or invalid.- Returns:
- value corresponding to the given key, or the default value
-
getOrDefault
Returns boolean value from config corresponding to the given key, or the default boolean if the key is missing.- Returns:
- value corresponding to the given key, or the default value
-
getOrDefault
Returns double value from config corresponding to the given key, or the default string if the key is missing or invalid.- Returns:
- value corresponding to the given key, or the default value
-
isBroken
public boolean isBroken()If any error occurred during loading or reading from the config a 'broken' flag is set, indicating that the config's state is undefined and should be discarded using `delete()`- Returns:
- the 'broken' flag of the configuration
-
delete
deletes the config file from the filesystem- Returns:
- true if the operation was successful
- Throws:
IOException
-