<commit_before>package invtweaks;

import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import org.apache.logging.log4j.Logger;

import java.io.*;
import java.util.List;

/**
 * Handles the (re)loading of the configuration, and all that is related to file extraction/moves.
 *
 * @author <NAME>
 */
@SuppressWarnings("ResultOfMethodCallIgnored") // Lots of these from file creation
public class InvTweaksConfigManager {

    private static final Logger log = InvTweaks.log;

    private final Minecraft mc;

    /**
     * The mod's configuration.
     */
    private InvTweaksConfig config = null;
    private long storedConfigLastModified = 0;

    private InvTweaksHandlerAutoRefill autoRefillHandler = null;
    private InvTweaksHandlerShortcuts shortcutsHandler = null;

    public InvTweaksConfigManager(Minecraft mc_) {
        mc = mc_;
    }

    private static long computeConfigLastModified() {
        return InvTweaksConst.CONFIG_RULES_FILE.lastModified() + InvTweaksConst.CONFIG_TREE_FILE.lastModified();
    }

    private static void backupFile(File file) {
        File newFile = new File(file.getName() + ".bak");
        if(newFile.exists()) {
            newFile.delete();
        }
        file.renameTo(newFile);
    }

    private static void showConfigErrors(@SuppressWarnings("ParameterHidesMemberVariable") InvTweaksConfig config) {
        List<String> invalid = config.getInvalidKeywords();
        if(invalid.size() > 0) {
            String error = I18n.translateToLocal("invtweaks.loadconfig.invalidkeywords") + ": ";
            for(String keyword : config.getInvalidKeywords()) {
                error += keyword + " ";
            }
            InvTweaks.logInGameStatic(error);
        }
    }

    // TODO Only reload modified file(s)
    public boolean makeSureConfigurationIsLoaded() {

        // Load properties
        try {
            if(config != null && config.refreshProperties()) {<commit_msg>Place backup files in the same location as the originals.<commit_after>package invtweaks;

import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import org.apache.logging.log4j.Logger;

import java.io.*;
import java.util.List;

/**
 * Handles the (re)loading of the configuration, and all that is related to file extraction/moves.
 *
 * @author <NAME>
 */
@SuppressWarnings("ResultOfMethodCallIgnored") // Lots of these from file creation
public class InvTweaksConfigManager {

    private static final Logger log = InvTweaks.log;

    private final Minecraft mc;

    /**
     * The mod's configuration.
     */
    private InvTweaksConfig config = null;
    private long storedConfigLastModified = 0;

    private InvTweaksHandlerAutoRefill autoRefillHandler = null;
    private InvTweaksHandlerShortcuts shortcutsHandler = null;

    public InvTweaksConfigManager(Minecraft mc_) {
        mc = mc_;
    }

    private static long computeConfigLastModified() {
        return InvTweaksConst.CONFIG_RULES_FILE.lastModified() + InvTweaksConst.CONFIG_TREE_FILE.lastModified();
    }

    private static void backupFile(File file) {
        File newFile = new File(file.getParentFile(), file.getName() + ".bak");
        if(newFile.exists()) {
            newFile.delete();
        }
        file.renameTo(newFile);
    }

    private static void showConfigErrors(@SuppressWarnings("ParameterHidesMemberVariable") InvTweaksConfig config) {
        List<String> invalid = config.getInvalidKeywords();
        if(invalid.size() > 0) {
            String error = I18n.translateToLocal("invtweaks.loadconfig.invalidkeywords") + ": ";
            for(String keyword : config.getInvalidKeywords()) {
                error += keyword + " ";
            }
            InvTweaks.logInGameStatic(error);
        }
    }

    // TODO Only reload modified file(s)
    public boolean makeSureConfigurationIsLoaded() {

        // Load properties
        try {
            if(config != null && config.refreshProperties()) {
{'fraction_non_alphanumeric': 0.09819688109161794, 'fraction_numerical': 0.00341130604288499, 'mean_word_length': 3.060336300692384, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4148012', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1148, 'n_words': 266}