<commit_before>package com.creativemd.littletiles.common.gui;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;

import com.creativemd.creativecore.common.gui.container.SubGui;
import com.creativemd.creativecore.common.gui.controls.gui.GuiButton;
import com.creativemd.creativecore.common.gui.controls.gui.GuiTextfield;

import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException;

public class SubGuiImport extends SubGui {
	
	public GuiTextfield textfield;
	
	@Override
	public void createControls() {
		textfield = new GuiTextfield("import", "", 10, 30, 150, 14);
		controls.add(textfield);
		controls.add(new GuiButton("Paste", 10, 52) {
			
			@Override
			public void onClicked(int x, int y, int button) {
				StringSelection stringSelection = new StringSelection(textfield.text);
				Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
				Transferable t = clpbrd.getContents(this);
				if (t == null)
					return;
				try {
					textfield.text = (String) t.getTransferData(DataFlavor.stringFlavor);
				} catch (Exception e) {
					
				}
			}
		});
		
		controls.add(new GuiButton("Import", 128, 52) {
			
			@Override
			public void onClicked(int x, int y, int button) {
				try {
					sendPacketToServer(JsonToNBT.getTagFromJson(textfield.text));
				} catch (NBTException e) {
					
				}
			}
		});
	}
	
}<commit_msg>Added dialog when trying to import a structure with an unavailable grid size<commit_after>package com.creativemd.littletiles.common.gui;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;

import com.creativemd.creativecore.common.gui.container.SubGui;
import com.creativemd.creativecore.common.gui.controls.gui.GuiButton;
import com.creativemd.creativecore.common.gui.controls.gui.GuiTextfield;
import com.creativemd.littletiles.common.utils.grid.LittleGridContext;

import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException;
import net.minecraft.nbt.NBTTagCompound;

public class SubGuiImport extends SubGui {
	
	public GuiTextfield textfield;
	
	@Override
	public void createControls() {
		textfield = new GuiTextfield("import", "", 10, 30, 150, 14);
		controls.add(textfield);
		controls.add(new GuiButton("Paste", 10, 52) {
			
			@Override
			public void onClicked(int x, int y, int button) {
				StringSelection stringSelection = new StringSelection(textfield.text);
				Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard();
				Transferable t = clpbrd.getContents(this);
				if (t == null)
					return;
				try {
					textfield.text = (String) t.getTransferData(DataFlavor.stringFlavor);
				} catch (Exception e) {
					
				}
			}
		});
		
		controls.add(new GuiButton("Import", 128, 52) {
			
			@Override
			public void onClicked(int x, int y, int button) {
				try {
					NBTTagCompound nbt = JsonToNBT.getTagFromJson(textfield.text);
					try {
						LittleGridContext.get(nbt);
						sendPacketToServer(nbt);
					} catch (RuntimeException e) {
						openButtonDialogDialog("Invalid grid size " + nbt.getInteger("grid"), "Ok");
					}
				} catch (NBTException e) {
					
				}
			}
		});
	}
	
}
{'fraction_non_alphanumeric': 0.11225692398350029, 'fraction_numerical': 0.01060695344725987, 'mean_word_length': 4.014771048744461, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4556381', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1116, 'n_words': 217}