<commit_before>package io.github.thatsmusic99.headsplus.config;

import io.github.thatsmusic99.headsplus.HeadsPlus;
import io.github.thatsmusic99.headsplus.crafting.RecipeEnums;
import io.github.thatsmusic99.headsplus.nms.NMSManager;
import io.github.thatsmusic99.headsplus.util.MaterialTranslator;
import org.bukkit.DyeColor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class HeadsPlusCrafting extends ConfigSettings {

	private static HeadsPlusMessagesManager messages;
	public HeadsPlusCrafting() {
        this.conName = "crafting";
        messages = HeadsPlus.getInstance().getMessagesConfig();
	    enable();
    }
	
	private void loadCrafting() {
		getConfig().options().header("HeadsPlus by Thatsmusic99 - due to the way Bukkit works, this config can only be reloaded on restart.\nInstructions for setting up can be found at: https://github.com/Thatsmusic99/HeadsPlus/wiki");
		getConfig().options().copyDefaults(true);
		save();
	}

	@Override
	public void reloadC() {
		performFileChecks();
		loadCrafting();
		checkCrafting();
		save();
	}

	private void checkCrafting() {
        NMSManager nms = HeadsPlus.getInstance().getNMS();
        int currentSize = getConfig().saveToString().length();
	    getConfig().addDefault("base-item.material", nms.getSkull(0).getType().name());
	    getConfig().addDefault("base-item.data", 0);
	    getConfig().addDefault("base-item.price", 10.0);
	    getConfig().addDefault("base-item.display-name", "{type} Head");
	    getConfig().addDefault("base-item.lore", new ArrayList<>(Arrays.asList("&7Price &8» &c{price}", "&7Type &8» &c{type}")));
	    getConfig().addDefault("base-item.use-base-item", true);
	    if (currentSize == 0) {
			for (RecipeEnums key : RecipeEnums.values()) {
				checkForOldFormat(key.str);
				if (key == RecipeEnums.SHEEP) {
					for (DyeColor d : DyeColor.values()) {
						if (d.name().equalsIgnoreCase("LIGHT_GRAY")) { // stupid move ngl
							getConfig().addDefault(key.str + "." + d.name() + ".head", "HP#silver_sheep");
						} else {
							getConfig().addDefault(key.str + "." + d.name() + ".head", "HP#" + d.name().toLowerCase() + "_sheep");
						}
						getConfig().addDefault(key.str + "." + d.name() + ".ingredients", new ArrayList<>(Collections.singletonList(nms.getColouredBlock(MaterialTranslator.BlockType.WOOL, d.ordinal()).getType().name())));
						getConfig().addDefault(key.str + "." + d.name() + ".price", "{default}");
						getConfig().addDefault(key.str + "." + d.name() + ".display-name", "{default}");
						getConfig().addDefault(key.str + "." + d.name() + ".display-type", HeadsPlus.capitalize(key.name().toLowerCase().replaceAll("_", " ")));
						getConfig().addDefault(key.str + "." + d.name() + ".lore", "{default}");<commit_msg>Fixed crafting.yml emptying itself<commit_after>package io.github.thatsmusic99.headsplus.config;

import io.github.thatsmusic99.headsplus.HeadsPlus;
import io.github.thatsmusic99.headsplus.crafting.RecipeEnums;
import io.github.thatsmusic99.headsplus.nms.NMSManager;
import io.github.thatsmusic99.headsplus.util.MaterialTranslator;
import org.bukkit.DyeColor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class HeadsPlusCrafting extends ConfigSettings {

	private static HeadsPlusMessagesManager messages;

	public HeadsPlusCrafting() {
        this.conName = "crafting";
        messages = HeadsPlus.getInstance().getMessagesConfig();
	    enable();
    }

	@Override
	public void reloadC() {
		performFileChecks();
		checkCrafting();
		save();
	}

	private void checkCrafting() {
        NMSManager nms = HeadsPlus.getInstance().getNMS();
        int currentSize = getConfig().saveToString().length();
		getConfig().options().header("HeadsPlus by Thatsmusic99 - due to the way Bukkit works, this config can only be reloaded on restart.\nInstructions for setting up can be found at: https://github.com/Thatsmusic99/HeadsPlus/wiki");
		getConfig().addDefault("base-item.material", nms.getSkull(0).getType().name());
	    getConfig().addDefault("base-item.data", 0);
	    getConfig().addDefault("base-item.price", 10.0);
	    getConfig().addDefault("base-item.display-name", "{type} Head");
	    getConfig().addDefault("base-item.lore", new ArrayList<>(Arrays.asList("&7Price &8» &c{price}", "&7Type &8» &c{type}")));
	    getConfig().addDefault("base-item.use-base-item", true);
	    if (currentSize == 0) {
			for (RecipeEnums key : RecipeEnums.values()) {
				checkForOldFormat(key.str);
				if (key == RecipeEnums.SHEEP) {
					for (DyeColor d : DyeColor.values()) {
						if (d.name().equalsIgnoreCase("LIGHT_GRAY")) { // stupid move ngl
							getConfig().addDefault(key.str + "." + d.name() + ".head", "HP#silver_sheep");
						} else {
							getConfig().addDefault(key.str + "." + d.name() + ".head", "HP#" + d.name().toLowerCase() + "_sheep");
						}
						getConfig().addDefault(key.str + "." + d.name() + ".ingredients", new ArrayList<>(Collections.singletonList(nms.getColouredBlock(MaterialTranslator.BlockType.WOOL, d.ordinal()).getType().name())));
						getConfig().addDefault(key.str + "." + d.name() + ".price", "{default}");
						getConfig().addDefault(key.str + "." + d.name() + ".display-name", "{default}");
						getConfig().addDefault(key.str + "." + d.name() + ".display-type", HeadsPlus.capitalize(key.name().toLowerCase().replaceAll("_", " ")));
						getConfig().addDefault(key.str + "." + d.name() + ".lore", "{default}");
{'fraction_non_alphanumeric': 0.1795844625112918, 'fraction_numerical': 0.008672086720867209, 'mean_word_length': 4.2774070543374645, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '378482', 'n_tokens_mistral': 2000, 'n_tokens_neox': 1796, 'n_words': 310}