<commit_before>package com.khorn.terraincontrol.customobjects.bo3;

import com.khorn.terraincontrol.TerrainControl;
import com.khorn.terraincontrol.configuration.ConfigFile;
import com.khorn.terraincontrol.configuration.ConfigFunction;
import com.khorn.terraincontrol.configuration.TCDefaultValues;
import com.khorn.terraincontrol.configuration.WorldConfig.ConfigMode;
import com.khorn.terraincontrol.customobjects.bo3.BO3Settings.OutsideSourceBlock;
import com.khorn.terraincontrol.customobjects.bo3.BO3Settings.SpawnHeight;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class BO3Config extends ConfigFile
{
    public File file;
    public String name;
    public String author;
    public String description;
    public ConfigMode settingsMode;

    public boolean tree;
    public int frequency;
    public double rarity;
    public boolean rotateRandomly;
    public SpawnHeight spawnHeight;
    public int minHeight;
    public int maxHeight;
    public ArrayList<String> excludedBiomes;

    public int sourceBlock;
    public int maxPercentageOutsideSourceBlock;
    public OutsideSourceBlock outsideSourceBlock;

    public BlockFunction[][] blocks = new BlockFunction[4][]; // four rotations
    public BO3Check[][] bo3Checks = new BO3Check[4][];

    /**
     * Creates a BO3Config from a file.
     *
     * @param name
     * @param file
     */
    public BO3Config(String name, File file)
    {
        this.file = file;
        this.name = name;

        ReadSettingsFile(file);

        init();
    }

    /**
     * Creates a BO3Config with the specified settings. Ignores the settings in the
     * settings file.
     *
     * @param name
     * @param file
     * @param settings
     */
    public BO3Config(String name, File file, Map<String, String> settings)
    {
        this.file = file;
        this.name = name;
        this.SettingsCache = settings;

        init();
    }

    private void init()
    {
        ReadConfigSettings();
        CorrectSettings();
        if (settingsMode != ConfigMode.WriteDisable)
        {
            writeSettingsFile(file, settingsMode == ConfigMode.WriteAll);
        }

        if (rotateRandomly)
        {
            rotateBlockAndChecks();
        }
    }
    
    @Override
    public void sayFileNotFound(File file) 
    {
        // Ignore
    }<commit_msg>Don't write tempory settings to the BO3 file<commit_after>package com.khorn.terraincontrol.customobjects.bo3;

import com.khorn.terraincontrol.TerrainControl;
import com.khorn.terraincontrol.configuration.ConfigFile;
import com.khorn.terraincontrol.configuration.ConfigFunction;
import com.khorn.terraincontrol.configuration.TCDefaultValues;
import com.khorn.terraincontrol.configuration.WorldConfig.ConfigMode;
import com.khorn.terraincontrol.customobjects.bo3.BO3Settings.OutsideSourceBlock;
import com.khorn.terraincontrol.customobjects.bo3.BO3Settings.SpawnHeight;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class BO3Config extends ConfigFile
{
    public File file;
    public String name;
    public String author;
    public String description;
    public ConfigMode settingsMode;

    public boolean tree;
    public int frequency;
    public double rarity;
    public boolean rotateRandomly;
    public SpawnHeight spawnHeight;
    public int minHeight;
    public int maxHeight;
    public ArrayList<String> excludedBiomes;

    public int sourceBlock;
    public int maxPercentageOutsideSourceBlock;
    public OutsideSourceBlock outsideSourceBlock;

    public BlockFunction[][] blocks = new BlockFunction[4][]; // four rotations
    public BO3Check[][] bo3Checks = new BO3Check[4][];

    /**
     * Creates a BO3Config from a file.
     *
     * @param name
     * @param file
     */
    public BO3Config(String name, File file)
    {
        this.file = file;
        this.name = name;

        ReadSettingsFile(file);

        init();
    }

    /**
     * Creates a BO3Config with the specified settings. Ignores the settings in the
     * settings file.
     *
     * @param name
     * @param file
     * @param settings
     */
    public BO3Config(String name, File file, Map<String, String> settings)
    {
        this.file = file;
        this.name = name;

        this.SettingsCache = settings;

        // Make sure that the BO3 file won't get overwritten
        this.SettingsCache.put(TCDefaultValues.SettingsMode.toString().toLowerCase(), ConfigMode.WriteDisable.toString());

        init();
    }

    private void init()
    {
        ReadConfigSettings();
        CorrectSettings();
        if (settingsMode != ConfigMode.WriteDisable)
        {
            writeSettingsFile(file, settingsMode == ConfigMode.WriteAll);
        }

        if (rotateRandomly)
        {
            rotateBlockAndChecks();
        }
    }

    @Override
    public void sayFileNotFound(File file)
    {
        // Ignore
    }
{'fraction_non_alphanumeric': 0.08647058823529412, 'fraction_numerical': 0.006274509803921568, 'mean_word_length': 2.8411144578313254, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '139360', 'n_tokens_mistral': 1468, 'n_tokens_neox': 1416, 'n_words': 356}