Skip to content

Commit

Permalink
add comments & actually backup file
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadiboo committed Dec 28, 2018
1 parent b7da48e commit b59bec3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/io/github/cadiboo/nocubes/NoCubes.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.Date;
Expand Down Expand Up @@ -118,12 +120,18 @@ private void fixConfig(final File configFile) {
if (!CONFIG_VERSION.equals(config.getLoadedConfigVersion())) {
LOGGER.info("Resetting config file " + configFile.getName());
//copied from Configuration
{
File fileBak = new File(configFile.getAbsolutePath() + "_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".version-" + config.getLoadedConfigVersion());
File backupFile = new File(configFile.getAbsolutePath() + "_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".version-" + config.getLoadedConfigVersion());
try {
FileUtils.copyFile(configFile, backupFile, true);
} catch (IOException e) {
LOGGER.error("We don't really care about this error", e);
}
configFile.delete();
//refresh
config.load();
//save version
config.save();
//save default config
ConfigManager.sync(MOD_ID, Config.Type.INSTANCE);
}

Expand All @@ -135,7 +143,9 @@ private void fixConfig(final File configFile) {
// isosurfaceLevel.set(0.0D);
// }

//save (Unnecessary?)
config.save();
//save
ConfigManager.sync(MOD_ID, Config.Type.INSTANCE);
}

Expand Down

0 comments on commit b59bec3

Please sign in to comment.