// Check if config.json exists. If not, we generate a new config.
if(!configFile.exists()){
getLogger().info("config.json could not be found. Generating a default configuration ...");
config=newConfigContainer();
Grasscutter.saveConfig(config);
return;
}
// If the file already exists, we attempt to load it.
try(FileReaderfile=newFileReader(configFile)){
config=gson.fromJson(file,ConfigContainer.class);
}catch(Exceptionexception){
getLogger().error("There was an error while trying to load the configuration from config.json. Please make sure that there are no syntax errors. If you want to start with a default configuration, delete your existing config.json.");
System.exit(1);
}
}
/**
* Saves the provided server configuration.
* @param config The configuration to save, or null for a new one.
// Check if config.json exists. If not, we generate a new config.
if(!configFile.exists()){
getLogger().info("config.json could not be found. Generating a default configuration ...");
config=newConfigContainer();
Grasscutter.saveConfig(config);
return;
}
// If the file already exists, we attempt to load it.
try(FileReaderfile=newFileReader(configFile)){
config=gson.fromJson(file,ConfigContainer.class);
}catch(Exceptionexception){
getLogger().error("There was an error while trying to load the configuration from config.json. Please make sure that there are no syntax errors. If you want to start with a default configuration, delete your existing config.json.");
System.exit(1);
}
}
/**
* Saves the provided server configuration.
*
* @param config The configuration to save, or null for a new one.