<commit_before>package pt.uptodate.gui;

import java.awt.*;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import pt.uptodate.FetchedUpdateable;
import pt.uptodate.UpToDate;
import pt.uptodate.util.io.WebUtils;

/**
 * @author CoolSquid
 */

public class GuiUpdates extends GuiBase {
	private final Iterable<FetchedUpdateable> updates;
	private final String returnMessage;
	private final String updatesAvailable;

	public GuiUpdates(Iterable<FetchedUpdateable> updates, String returnMessage, String updatesAvailable) {
		super();
		this.updates = updates;
		this.returnMessage = returnMessage;
		this.updatesAvailable = updatesAvailable;
	}

	@SuppressWarnings("unchecked")
	@Override
	public void initGui() {
		int a = 0;
		for (FetchedUpdateable fetched : updates) {
			GuiButton b = new GuiButtonMod(1, 0, this.height / 2 - 20 + a, fetched.mod.getName() + " " + fetched.oldDisp + "/" + fetched.display, fetched);
			b.xPosition = this.width / 2 - (b.width / 2);
			this.buttonList.add(b);
			a += b.height + 4;
		}
		GuiButton button = new GuiButton(0, 10, 0, returnMessage);
		button.yPosition = this.height - button.height - 10;
		button.width = 100;
		this.buttonList.add(button);
	}

	@Override
	public void drawScreen(int mouseRelX, int mouseRelY, float tickTime) {
		this.drawDefaultBackground();
		super.drawScreen(mouseRelX, mouseRelY, tickTime);
		if (UpToDate.updates.isEmpty()) {
			this.drawString("No updates available.", this.width / 2, this.height / 2);
		}
		else {
			String line1 = updatesAvailable;
			this.drawCenteredString(this.fontRendererObj, line1, this.width / 2, this.height / 2 - 60, 16777215);
		}
		if (!Desktop.isDesktopSupported()) {
			this.drawString("Your desktop is not supported. The buttons will not be clickable.", this.width / 2, 20);
		}
	}

	@Override
	protected void actionPerformed(GuiButton button) {
		if (button.id == 1) {
			if (Desktop.isDesktopSupported()) {
				WebUtils.openBrowser(((GuiButtonMod) button).getMod().url);
			}
		}
		else if (button.id == 0) {
			Minecraft.getMinecraft().displayGuiScreen(null);
		}
	}

	private static class GuiButtonMod extends GuiButton {
<commit_msg>Implement clipboard<commit_after>package pt.uptodate.gui;

import java.awt.*;
import java.awt.datatransfer.StringSelection;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import pt.uptodate.FetchedUpdateable;
import pt.uptodate.UpToDate;
import pt.uptodate.util.io.WebUtils;

/**
 * @author CoolSquid
 */

public class GuiUpdates extends GuiBase {
	private final Iterable<FetchedUpdateable> updates;
	private final String returnMessage;
	private final String updatesAvailable;

	public GuiUpdates(Iterable<FetchedUpdateable> updates, String returnMessage, String updatesAvailable) {
		super();
		this.updates = updates;
		this.returnMessage = returnMessage;
		this.updatesAvailable = updatesAvailable;
	}

	@SuppressWarnings("unchecked")
	@Override
	public void initGui() {
		int a = 0;
		for (FetchedUpdateable fetched : updates) {
			GuiButton b = new GuiButtonMod(1, 0, this.height / 2 - 20 + a, fetched.mod.getName() + " " + fetched.oldDisp + "/" + fetched.display, fetched);
			b.xPosition = this.width / 2 - (b.width / 2);
			this.buttonList.add(b);
			a += b.height + 4;
		}
		GuiButton button = new GuiButton(0, 10, 0, returnMessage);
		button.yPosition = this.height - button.height - 10;
		button.width = 100;
		this.buttonList.add(button);
	}

	@Override
	public void drawScreen(int mouseRelX, int mouseRelY, float tickTime) {
		this.drawDefaultBackground();
		super.drawScreen(mouseRelX, mouseRelY, tickTime);
		if (UpToDate.updates.isEmpty()) {
			this.drawString("No updates available.", this.width / 2, this.height / 2);
		}
		else {
			String line1 = updatesAvailable;
			this.drawCenteredString(this.fontRendererObj, line1, this.width / 2, this.height / 2 - 60, 16777215);
		}
		if (!Desktop.isDesktopSupported()) {
			this.drawString("Your desktop is not supported. The buttons will not be clickable.", this.width / 2, 20);
		}
	}

	@Override
	protected void actionPerformed(GuiButton button) {
		if (button.id == 1) {
			String url = ((GuiButtonMod) button).getMod().url;
			if (Desktop.isDesktopSupported()) {
				WebUtils.openBrowser(url);
			} else {
				Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(url), null);
			}
		}
		else if (button.id == 0) {
			Minecraft.getMinecraft().displayGuiScreen(null);
		}
	}

	private static class GuiButtonMod extends GuiButton {

{'fraction_non_alphanumeric': 0.12409080890456249, 'fraction_numerical': 0.017191977077363897, 'mean_word_length': 4.204128440366972, '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': '2358560', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1500, 'n_words': 346}