Class JsonConfig
java.lang.Object
fr.hytale.loader.config.BaseConfig
fr.hytale.loader.config.JsonConfig
- All Implemented Interfaces:
Config
JSON-based configuration implementation.
This class handles parsing and generating JSON files for configuration
storage.
It uses the Google Gson library to handle the JSON protocol.
It extends BaseConfig to leverage the common configuration Logic.
- Since:
- 1.0.4
- Version:
- 1.0.4
- Author:
- HytaleLoader
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class BaseConfig
BaseConfig.MapConfigSection -
Field Summary
Fields inherited from class BaseConfig
data, defaults, file -
Constructor Summary
ConstructorsConstructorDescriptionJsonConfig(File file) Creates a new JSON configuration linked to the specified file. -
Method Summary
Methods inherited from class BaseConfig
addDefault, applyDefaults, contains, get, get, getBoolean, getBoolean, getDouble, getDouble, getFile, getFromDefaults, getInt, getInt, getKeys, getKeysFromMap, getList, getList, getSection, getString, getString, getStringList, getValues, set, setDefaults
-
Constructor Details
-
JsonConfig
Creates a new JSON configuration linked to the specified file.- Parameters:
file- the configuration file (usually ending in .json)
-
-
Method Details
-
save
Saves the current configuration data to the file in JSON format.Creates parent directories if they do not exist. Uses pretty printing to make the file human-readable.
- Throws:
IOException- if an error occurs while writing to the file
-
reload
Reloads the configuration from the file.This clears the current data and re-parses the file using Gson. If the file does not exist but defaults are set, it creates the file with the default values.
- Throws:
IOException- if an error occurs while reading the file
-