<commit_before>package net.darkhax.darkutils.client.gui;

import java.io.IOException;

import org.apache.commons.lang3.StringUtils;
import org.lwjgl.input.Keyboard;

import net.darkhax.bookshelf.lib.util.Utilities;
import net.darkhax.darkutils.DarkUtils;
import net.darkhax.darkutils.common.network.packet.PacketSyncTimer;
import net.darkhax.darkutils.tileentity.TileEntityTimer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class GuiTimerAmount extends GuiScreen {
    
    private TileEntityTimer timer;
    
    private GuiTextField delayTextField;
    private GuiButton doneBtn;
    private GuiButton cancelBtn;
    
    public GuiTimerAmount(TileEntityTimer timer) {
        
        this.timer = timer;
    }
    
    @Override
    public void updateScreen () {
        
        this.delayTextField.updateCursorCounter();
    }
    
    @Override
    public void initGui () {
        
        Keyboard.enableRepeatEvents(true);
        this.buttonList.clear();
        this.buttonList.add(this.doneBtn = new GuiButton(0, this.width / 2 - 4 - 150, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.done", new Object[0])));
        this.buttonList.add(this.cancelBtn = new GuiButton(1, this.width / 2 + 4, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.cancel", new Object[0])));
        this.delayTextField = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 150, 50, 300, 20);
        this.delayTextField.setMaxStringLength(5);
        this.delayTextField.setFocused(true);
        this.delayTextField.setText("" + timer.getDelayTime());
        this.doneBtn.enabled = this.delayTextField.getText().trim().length() > 0 && StringUtils.isNumeric(this.delayTextField.getText());
    }
    
    @Override
    public void onGuiClosed () {
        
        Keyboard.enableRepeatEvents(false);
    }
    
    @Override
    protected void actionPerformed (GuiButton button) throws IOException {
        
        if (button.enabled) {
            
            if (button.id == 1) {
                
                this.mc.displayGuiScreen((GuiScreen) null);
            }
            
            else if (button.id == 0 && StringUtils.isNumeric(this.delayTextField.getText())) {
                
                DarkUtils.network.sendToServer(new PacketSyncTimer(timer.getPos(), Integer.parseInt(delayTextField.getText())));
                this.mc.displayGuiScreen((GuiScreen) null);
            }
        }
    }
    
    @Override
    protected void keyTyped (char typedChar, int keyCode) throws IOException {
        
        if (Utilities.isKeyCodeNumeric(keyCode) || keyCode == 14)
            this.delayTextField.textboxKeyTyped(typedChar, keyCode);
            
        this.doneBtn.enabled = this.delayTextField.getText().trim().length() > 0 && StringUtils.isNumeric(this.delayTextField.getText());
        
        if (keyCode != 28 && keyCode != 156) {
            
            if (keyCode == 1) {
                
                this.actionPerformed(this.cancelBtn);
            }
        }
        
        else {
            
            this.actionPerformed(this.doneBtn);
        }
    }
    
    @Override
    protected void mouseClicked (int mouseX, int mouseY, int mouseButton) throws IOException {
        
        super.mouseClicked(mouseX, mouseY, mouseButton);
        this.delayTextField.mouseClicked(mouseX, mouseY, mouseButton);
    }
    
    @Override
    public void drawScreen (int mouseX, int mouseY, float partialTicks) {
        
        this.drawDefaultBackground();
        this.drawCenteredString(this.fontRendererObj, I18n.format("gui.darkutils.timer.title", new Object[0]), this.width / 2, 20, 16777215);
        this.drawString(this.fontRendererObj, I18n.format("gui.darkutils.timer.delay", new Object[0]), this.width / 2 - 150, 37, 10526880);
        this.delayTextField.drawTextBox();
        
        int i = 75;
        int j = 0;
        this.drawString(this.fontRendererObj, I18n.format("gui.darkutils.timer.desc.1", new Object[0]), this.width / 2 - 150, i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880);
        this.drawString(this.fontRendererObj, I18n.format("gui.darkutils.timer.desc.2", new Object[0]), this.width / 2 - 150, i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880);
        this.drawString(this.fontRendererObj, I18n.format("gui.darkutils.timer.desc.3", new Object[0]), this.width / 2 - 150, i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880);
        this.drawString(this.fontRendererObj, I18n.format("gui.darkutils.timer.desc.4", new Object[0]), this.width / 2 - 150, i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880);
        
        super.drawScreen(mouseX, mouseY, partialTicks);
    }
}<commit_msg>Fixed a bug in the gui. <commit_after>package net.darkhax.darkutils.client.gui;

import java.io.IOException;

import org.apache.commons.lang3.StringUtils;
import org.lwjgl.input.Keyboard;

import net.darkhax.bookshelf.lib.util.Utilities;
import net.darkhax.darkutils.DarkUtils;
import net.darkhax.darkutils.common.network.packet.PacketSyncTimer;
import net.darkhax.darkutils.tileentity.TileEntityTimer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class GuiTimerAmount extends GuiScreen {
    
    private TileEntityTimer timer;
    
    private GuiTextField delayTextField;
    private GuiButton doneBtn;
    private GuiButton cancelBtn;
    
    public GuiTimerAmount(TileEntityTimer timer) {
        
        this.timer = timer;
    }
    
    @Override
    public void updateScreen () {
        
        this.delayTextField.updateCursorCounter();
    }
    
    @Override
    public void initGui () {
        
        Keyboard.enableRepeatEvents(true);
        this.buttonList.clear();
        this.buttonList.add(this.doneBtn = new GuiButton(0, this.width / 2 - 4 - 150, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.done", new Object[0])));
        this.buttonList.add(this.cancelBtn = new GuiButton(1, this.width / 2 + 4, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.cancel", new Object[0])));
        this.delayTextField = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 150, 50, 300, 20);
        this.delayTextField.setMaxStringLength(5);
        this.delayTextField.setFocused(true);
        this.delayTextField.setText("" + timer.getDelayTime());
        this.doneBtn.enabled = this.delayTextField.getText().trim().length() > 0 && StringUtils.isNumeric(this.delayTextField.getText());
    }
    
    @Override
    public void onGuiClosed () {
        
        Keyboard.enableRepeatEvents(false);
    }
    
    @Override
    protected void actionPerformed (GuiButton button) throws IOException {
        
        if (button.enabled) {
            
            if (button.id == 1) {
                
                this.mc.displayGuiScreen((GuiScreen) null);
            }
            
            else if (button.id == 0 && StringUtils.isNumeric(this.delayTextField.getText())) {
                
                DarkUtils.network.sendToServer(new PacketSyncTimer(timer.getPos(), Integer.parseInt(delayTextField.getText())));
                this.mc.displayGuiScreen((GuiScreen) null);
            }
        }
    }
    
    @Override
    protected void keyTyped (char typedChar, int keyCode) throws IOException {
        
        if (Utilities.isKeyCodeNumeric(keyCode) || keyCode == 14) {
            
            this.delayTextField.textboxKeyTyped(typedChar, keyCode);
            this.doneBtn.enabled = this.delayTextField.getText().trim().length() > 0 && StringUtils.isNumeric(this.delayTextField.getText());
            return;
        }
        
        if (keyCode == 1)
            this.actionPerformed(this.cancelBtn);
            
        else if (keyCode == 28)
            this.actionPerformed(this.doneBtn);
    }
    
    @Override
    protected void mouseClicked (int mouseX, int mouseY, int mouseButton) throws IOException {
        
        super.mouseClicked(mouseX, mouseY, mouseButton);
        this.delayTextField.mouseClicked(mouseX, mouseY, mouseButton);
    }
    
    @Override
    public void drawScreen (int mouseX, int mouseY, float partialTicks) {
        
        this.drawDefaultBackground();
        this.drawCenteredString(this.fontRendererObj, I18n.format("gui.darkutils.timer.title", new Object[0]), this.width / 2, 20, 16777215);
        this.drawString(this.fontRendererObj, I18n.format("gui.darkutils.timer.delay", new Object[0]), this.width / 2 - 150, 37, 10526880);
        this.delayTextField.drawTextBox();
        
        int i = 75;
        int j = 0;
        this.drawString(this.fontRendererObj, I18n.format("gui.darkutils.timer.desc.1", new Object[0]), this.width / 2 - 150, i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880);
        this.drawString(this.fontRendererObj, I18n.format("gui.darkutils.timer.desc.2", new Object[0]), this.width / 2 - 150, i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880);
        this.drawString(this.fontRendererObj, I18n.format("gui.darkutils.timer.desc.3", new Object[0]), this.width / 2 - 150, i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880);
        this.drawString(this.fontRendererObj, I18n.format("gui.darkutils.timer.desc.4", new Object[0]), this.width / 2 - 150, i + j++ * this.fontRendererObj.FONT_HEIGHT, 10526880);
        
        super.drawScreen(mouseX, mouseY, partialTicks);
    }
}
{'fraction_non_alphanumeric': 0.11627216004753888, 'fraction_numerical': 0.031989699910864616, 'mean_word_length': 2.445240532241556, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7059737', 'n_tokens_mistral': 3311, 'n_tokens_neox': 3001, 'n_words': 549}