Class JsonConfig

java.lang.Object
fr.hytale.loader.config.BaseConfig
fr.hytale.loader.config.JsonConfig
All Implemented Interfaces:
Config

public class JsonConfig extends BaseConfig
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:
  • Constructor Details

    • JsonConfig

      public JsonConfig(File file)
      Creates a new JSON configuration linked to the specified file.
      Parameters:
      file - the configuration file (usually ending in .json)
  • Method Details

    • save

      public void save() throws IOException
      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

      public void reload() throws IOException
      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