// Path: src/api/java/com/github/atomicblom/shearmadness/api/events/ShearMadnessSyncSettingsEvent.java
// public class ShearMadnessSyncSettingsEvent extends Event {
//     private Configuration config;
// 
//     public ShearMadnessSyncSettingsEvent(Configuration config) {
// 
//         this.config = config;
//     }
// 
//     public Configuration getConfig() {
//         return config;
//     }
// }
// 
// Path: src/main/java/com/github/atomicblom/shearmadness/utility/Logger.java
// public enum Logger
// {
//     INSTANCE;
// 
//     @SuppressWarnings({"NonSerializableFieldInSerializableClass", "InstanceVariableMayNotBeInitialized"})
//     private org.apache.logging.log4j.Logger logger;
// 
//     public static void info(final String format, final Object... args)
//     {
//         INSTANCE.log(Level.INFO, format, args);
//     }
// 
//     public static void log(final Level level, final Throwable exception, final String format, final Object... args)
//     {
//         //noinspection ChainedMethodCall
//         INSTANCE.getLogger().log(level, String.format(format, args), exception);
//     }
// 
//     public static void severe(final String format, final Object... args)
//     {
//         INSTANCE.log(Level.ERROR, format, args);
//     }
// 
//     public static void warning(final String format, final Object... args)
//     {
//         INSTANCE.log(Level.WARN, format, args);
//     }
// 
//     public static void trace(final String format, final Object... args)
//     {
//         INSTANCE.log(Level.TRACE, format, args);
//     }
// 
//     private org.apache.logging.log4j.Logger getLogger()
//     {
//         if (logger == null)
//         {
//             init();
//         }
// 
//         return logger;
//     }
// 
//     private void init()
//     {
//         if (logger == null)
//         {
//             logger = LogManager.getLogger(CommonReference.MOD_ID);
//         }
//     }
// 
//     private void log(final Level level, final String format, final Object... data)
//     {
//         //noinspection ChainedMethodCall
//         getLogger().log(level, String.format(format, data));
//     }
// }
// 
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/CommonReference.java
// public final class CommonReference {
//     public static final String MOD_ID = "shearmadness";
//     public static final String MOD_NAME = "Shear Madness";
//     public static final String VERSION = "@MOD_VERSION@";
// 
//     private CommonReference() {}
// }


import com.github.atomicblom.shearmadness.api.events.ShearMadnessSyncSettingsEvent;
import com.github.atomicblom.shearmadness.utility.Logger;
import com.github.atomicblom.shearmadness.variations.CommonReference;
import com.google.common.base.Objects;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Optional;
import static com.google.common.base.Preconditions.*;
        syncConfig(true);
    }

    void syncConfig()
    {
        syncConfig(false);
    }

    @SuppressWarnings("OverlyBroadCatchBlock")
    private void syncConfig(boolean skipLoad)
    {
        if (!skipLoad)
        {
            try
            {
                config.load();
            } catch (final Exception e)
            {
                final File fileBak = new File(fileRef.getAbsolutePath() + '_' + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".errored");
                Logger.severe("An exception occurred while loading your config file. This file will be renamed to %s and a new config file will be generated.", fileBak.getName());
                Logger.severe("Exception encountered: %s", e.getLocalizedMessage());

                final boolean success = fileRef.renameTo(fileBak);
                Logger.warning("Rename %s successful.", success ? "was" : "was not");

                config = new Configuration(fileRef, CONFIG_VERSION);
            }
            convertOldConfig();
        }

// Path: src/api/java/com/github/atomicblom/shearmadness/api/events/ShearMadnessSyncSettingsEvent.java
// public class ShearMadnessSyncSettingsEvent extends Event {
//     private Configuration config;
// 
//     public ShearMadnessSyncSettingsEvent(Configuration config) {
// 
//         this.config = config;
//     }
// 
//     public Configuration getConfig() {
//         return config;
//     }
// }
// 
// Path: src/main/java/com/github/atomicblom/shearmadness/utility/Logger.java
// public enum Logger
// {
//     INSTANCE;
// 
//     @SuppressWarnings({"NonSerializableFieldInSerializableClass", "InstanceVariableMayNotBeInitialized"})
//     private org.apache.logging.log4j.Logger logger;
// 
//     public static void info(final String format, final Object... args)
//     {
//         INSTANCE.log(Level.INFO, format, args);
//     }
// 
//     public static void log(final Level level, final Throwable exception, final String format, final Object... args)
//     {
//         //noinspection ChainedMethodCall
//         INSTANCE.getLogger().log(level, String.format(format, args), exception);
//     }
// 
//     public static void severe(final String format, final Object... args)
//     {
//         INSTANCE.log(Level.ERROR, format, args);
//     }
// 
//     public static void warning(final String format, final Object... args)
//     {
//         INSTANCE.log(Level.WARN, format, args);
//     }
// 
//     public static void trace(final String format, final Object... args)
//     {
//         INSTANCE.log(Level.TRACE, format, args);
//     }
// 
//     private org.apache.logging.log4j.Logger getLogger()
//     {
//         if (logger == null)
//         {
//             init();
//         }
// 
//         return logger;
//     }
// 
//     private void init()
//     {
//         if (logger == null)
//         {
//             logger = LogManager.getLogger(CommonReference.MOD_ID);
//         }
//     }
// 
//     private void log(final Level level, final String format, final Object... data)
//     {
//         //noinspection ChainedMethodCall
//         getLogger().log(level, String.format(format, data));
//     }
// }
// 
// Path: src/integration/java/com/github/atomicblom/shearmadness/variations/CommonReference.java
// public final class CommonReference {
//     public static final String MOD_ID = "shearmadness";
//     public static final String MOD_NAME = "Shear Madness";
//     public static final String VERSION = "@MOD_VERSION@";
// 
//     private CommonReference() {}
// }


// Path: src/main/java/com/github/atomicblom/shearmadness/configuration/ConfigurationHandler.java
import com.github.atomicblom.shearmadness.api.events.ShearMadnessSyncSettingsEvent;
import com.github.atomicblom.shearmadness.utility.Logger;
import com.github.atomicblom.shearmadness.variations.CommonReference;
import com.google.common.base.Objects;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Optional;
import static com.google.common.base.Preconditions.*;

        syncConfig(true);
    }

    void syncConfig()
    {
        syncConfig(false);
    }

    @SuppressWarnings("OverlyBroadCatchBlock")
    private void syncConfig(boolean skipLoad)
    {
        if (!skipLoad)
        {
            try
            {
                config.load();
            } catch (final Exception e)
            {
                final File fileBak = new File(fileRef.getAbsolutePath() + '_' + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".errored");
                Logger.severe("An exception occurred while loading your config file. This file will be renamed to %s and a new config file will be generated.", fileBak.getName());
                Logger.severe("Exception encountered: %s", e.getLocalizedMessage());

                final boolean success = fileRef.renameTo(fileBak);
                Logger.warning("Rename %s successful.", success ? "was" : "was not");

                config = new Configuration(fileRef, CONFIG_VERSION);
            }
            convertOldConfig();
        }

        MinecraftForge.EVENT_BUS.post(new ShearMadnessSyncSettingsEvent(config));