<commit_before>package net.blay09.mods.bmc.gui.config;

import net.blay09.mods.bmc.ChatViewManager;
import net.blay09.mods.bmc.chat.ChatView;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.client.config.ConfigGuiType;
import net.minecraftforge.fml.client.config.DummyConfigElement;
import net.minecraftforge.fml.client.config.GuiButtonExt;
import net.minecraftforge.fml.client.config.GuiConfig;
import net.minecraftforge.fml.client.config.GuiConfigEntries;
import net.minecraftforge.fml.client.config.GuiEditArray;
import net.minecraftforge.fml.client.config.GuiEditArrayEntries;
import net.minecraftforge.fml.client.config.IConfigElement;

public class GuiChatViewsConfig extends GuiEditArray {

	public GuiChatViewsConfig(GuiScreen parentScreen, IConfigElement configElement, int slotIndex, Object[] currentValues, boolean enabled) {
		super(parentScreen, configElement, slotIndex, currentValues, enabled);
	}

	@Override
	public void initGui() {
		super.initGui();

		fixForge();
	}

	private void fixForge() {
		entryList = new GuiEditArrayEntries(this, mc, configElement, beforeValues, currentValues);
		entryList.listEntries.clear();
		boolean canDelete = currentValues.length > 1;
		for (Object chatView : currentValues) {
			entryList.listEntries.add(new ChatViewArrayEntry(this, entryList, configElement, chatView, canDelete));
		}
		entryList.listEntries.add(new GuiEditArrayEntries.BaseEntry(this, entryList, configElement));
	}

	@Override
	protected void actionPerformed(GuiButton button) {
		super.actionPerformed(button);
		if (button == btnUndoChanges) {
			fixForge();
		} else if(button == btnDefault) {
			fixForge();
		}
	}

	public static IConfigElement getDummyElement() {
		SmartyListElement dummy = new SmartyListElement("Views", ChatViewManager.createDefaults(), ConfigGuiType.STRING, "config.category.views");
		dummy.setConfigEntryClass(ChatViewConfigEntry.class);
		dummy.setArrayEntryClass(ChatViewArrayEntry.class);
		dummy.setCustomEditListEntryClass(ChatViewArrayEntry.class);
		dummy.set(ChatViewManager.getViews().toArray());
		return dummy;
	}

	public static class ChatViewConfigEntry extends GuiConfigEntries.ArrayEntry {
		protected final GuiButtonExt btnValueFixed;

		public ChatViewConfigEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {<commit_msg>What a waste of time<commit_after>package net.blay09.mods.bmc.gui.config;

import net.blay09.mods.bmc.ChatViewManager;
import net.blay09.mods.bmc.chat.ChatView;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.client.config.ConfigGuiType;
import net.minecraftforge.fml.client.config.DummyConfigElement;
import net.minecraftforge.fml.client.config.GuiButtonExt;
import net.minecraftforge.fml.client.config.GuiConfig;
import net.minecraftforge.fml.client.config.GuiConfigEntries;
import net.minecraftforge.fml.client.config.GuiEditArray;
import net.minecraftforge.fml.client.config.GuiEditArrayEntries;
import net.minecraftforge.fml.client.config.IConfigElement;

public class GuiChatViewsConfig extends GuiEditArray {

	public GuiChatViewsConfig(GuiScreen parentScreen, IConfigElement configElement, int slotIndex, Object[] currentValues, boolean enabled) {
		super(parentScreen, configElement, slotIndex, currentValues, enabled);
	}

	@Override
	public void initGui() {
		super.initGui();

		fixForge();
	}

	private void fixForge() {
		entryList = new GuiEditArrayEntries(this, mc, configElement, beforeValues, currentValues) {
			@Override
			public void addNewEntry(int index) {
				super.addNewEntry(index);

				saveListChanges();
				ChatViewArrayEntry entry = (ChatViewArrayEntry) listEntries.get(index);
				if(entry.chatView != null) {
					mc.displayGuiScreen(new GuiChatView(owningGui, entry.chatView));
				}
			}
		};
		entryList.listEntries.clear();
		boolean canDelete = currentValues.length > 1;
		for (Object chatView : currentValues) {
			entryList.listEntries.add(new ChatViewArrayEntry(this, entryList, configElement, chatView, canDelete));
		}
		entryList.listEntries.add(new GuiEditArrayEntries.BaseEntry(this, entryList, configElement));
	}

	@Override
	protected void actionPerformed(GuiButton button) {
		super.actionPerformed(button);
		if (button == btnUndoChanges) {
			fixForge();
		} else if(button == btnDefault) {
			fixForge();
		}
	}

	public static IConfigElement getDummyElement() {
		SmartyListElement dummy = new SmartyListElement("Views", ChatViewManager.createDefaults(), ConfigGuiType.STRING, "config.category.views");
		dummy.setConfigEntryClass(ChatViewConfigEntry.class);
		dummy.setArrayEntryClass(ChatViewArrayEntry.class);
		dummy.setCustomEditListEntryClass(ChatViewArrayEntry.class);
		dummy.set(ChatViewManager.getViews().toArray());
		return dummy;
	}

	public static class ChatViewConfigEntry extends GuiConfigEntries.ArrayEntry {
		protected final GuiButtonExt btnValueFixed;

		public ChatViewConfigEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
{'fraction_non_alphanumeric': 0.09984639016897082, 'fraction_numerical': 0.0034562211981566822, 'mean_word_length': 6.305750350631136, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6817044', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1582, 'n_words': 284}