<commit_before>package me.justramon.ircbot.justabotx.config;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.esotericsoftware.yamlbeans.YamlException;
import com.esotericsoftware.yamlbeans.YamlReader;
import com.esotericsoftware.yamlbeans.YamlWriter;

import me.justramon.ircbot.justabotx.core.Core;
import me.justramon.ircbot.justabotx.util.StringUtils;

public class ConfigHandler
{
	public static File configfile;
	public static Config config;

	public static void loadConfig()
	{
		configfile = new File("config.yml");

		if(!configfile.exists())
		{
			setupConfig(configfile);
		}

		try
		{
			YamlReader configreader = new YamlReader(new FileReader(configfile));
			config = configreader.read(Config.class);
		} 
		catch (FileNotFoundException | YamlException e)
		{
			e.printStackTrace();
		}
		System.gc();
	}
	
	static void setupConfig(File configfile)
	{
		try
		{
			configfile.createNewFile();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		
		Config config = new Config();
		
		config.nick = "JustABotX";
		config.devnick = "JABXDev";
		config.login = "JustABotX";
		config.realname = "Just a bot!";
		config.serverhostname = "irc.esper.net";
		
		List<String> channels = new ArrayList<String>();
		channels.add("#JustRamon");
		config.channels = channels;
		
		config.devchan = "#bl4ckb0tTest";
		
		List<String> operators = new ArrayList<String>();
		operators.add(StringUtils.genrandstring(10));
		config.operators = operators;
		
		List<String> xtrafunc = new ArrayList<String>();
		xtrafunc.add("#JustRamon");
		config.xtrafunc = xtrafunc;
		
		List<String> mojangUpdateChans = new ArrayList<String>();
		mojangUpdateChans.add("#JustRamon");
		config.mojangUpdateChans = mojangUpdateChans;
		
		List<String> jrwUpdateChans = new ArrayList<String>();
		jrwUpdateChans.add("#JustRamon");
		config.jrwUpdateChans = jrwUpdateChans;
		
		config.updateDevChan = config.devchan;
		
		config.gameChannels = config.xtrafunc;

        save();
//		try
//		{
//			YamlWriter writer = new YamlWriter(new FileWriter(configfile));
//			writer.write(config);
//			writer.close();
//		}
//		catch (IOException e)
//		{
//			e.printStackTrace();
//		}
	}
	
	public static void setNick(String newNick)
	{
		if(!configfile.exists())
		{
			setupConfig(configfile);
		}	
		
		if(!Core.dev)
			config.nick = newNick;
		else
			config.devnick = newNick;

        save();
//		try
//		{
//			YamlWriter writer = new YamlWriter(new FileWriter(configfile));
//			writer.write(config);
//			writer.close();
//		}
//		catch (IOException e)
//		{
//			e.printStackTrace();
//		}
	}

	public static String getNick() {
        return Core.dev ? config.devnick : config.nick;
    }

	public static void save() {
        try
        {
            YamlWriter writer = new YamlWriter(new FileWriter(configfile));
            writer.write(config);
            writer.close();
        }<commit_msg>remove commented out code<commit_after>package me.justramon.ircbot.justabotx.config;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.esotericsoftware.yamlbeans.YamlException;
import com.esotericsoftware.yamlbeans.YamlReader;
import com.esotericsoftware.yamlbeans.YamlWriter;

import me.justramon.ircbot.justabotx.core.Core;
import me.justramon.ircbot.justabotx.util.StringUtils;

public class ConfigHandler
{
	public static File configfile;
	public static Config config;

	public static void loadConfig()
	{
		configfile = new File("config.yml");

		if(!configfile.exists())
		{
			setupConfig(configfile);
		}

		try
		{
			YamlReader configreader = new YamlReader(new FileReader(configfile));
			config = configreader.read(Config.class);
		} 
		catch (FileNotFoundException | YamlException e)
		{
			e.printStackTrace();
		}
		System.gc();
	}
	
	static void setupConfig(File configfile)
	{
		try
		{
			configfile.createNewFile();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		
		Config config = new Config();
		
		config.nick = "JustABotX";
		config.devnick = "JABXDev";
		config.login = "JustABotX";
		config.realname = "Just a bot!";
		config.serverhostname = "irc.esper.net";
		
		List<String> channels = new ArrayList<String>();
		channels.add("#JustRamon");
		config.channels = channels;
		
		config.devchan = "#bl4ckb0tTest";
		
		List<String> operators = new ArrayList<String>();
		operators.add(StringUtils.genrandstring(10));
		config.operators = operators;
		
		List<String> xtrafunc = new ArrayList<String>();
		xtrafunc.add("#JustRamon");
		config.xtrafunc = xtrafunc;
		
		List<String> mojangUpdateChans = new ArrayList<String>();
		mojangUpdateChans.add("#JustRamon");
		config.mojangUpdateChans = mojangUpdateChans;
		
		List<String> jrwUpdateChans = new ArrayList<String>();
		jrwUpdateChans.add("#JustRamon");
		config.jrwUpdateChans = jrwUpdateChans;
		
		config.updateDevChan = config.devchan;
		
		config.gameChannels = config.xtrafunc;

        save();
	}
	
	public static void setNick(String newNick)
	{
		if(!configfile.exists())
		{
			setupConfig(configfile);
		}	
		
		if(!Core.dev)
			config.nick = newNick;
		else
			config.devnick = newNick;

        save();
	}

	public static String getNick() {
        return Core.dev ? config.devnick : config.nick;
    }

	public static void save() {
        try
        {
            YamlWriter writer = new YamlWriter(new FileWriter(configfile));
            writer.write(config);
            writer.close();
        }
{'fraction_non_alphanumeric': 0.1270118964310707, 'fraction_numerical': 0.0013995801259622112, 'mean_word_length': 3.56629392971246, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '3836169', 'n_tokens_mistral': 2134, 'n_tokens_neox': 1882, 'n_words': 351}