Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package xyz.ultrapixelmon.pepefab;
- import net.minecraft.client.gui.GuiChat;
- import net.minecraft.client.gui.GuiScreen;
- import java.io.IOException;
- import java.lang.reflect.Field;
- import java.lang.reflect.InvocationTargetException;
- import java.lang.reflect.Method;
- public class NewChat2 extends GuiChat{
- private String password = "";
- private String doublePassword = "";
- private int passCount = 0;
- public Field tabCompleterField;
- public Method completeMethode;
- public Method resetRequestedMethode;
- public Method resetDidCompleteMethode;
- public NewChat2() {
- try {
- tabCompleterField = GuiChat.class.getDeclaredField("field_184083_x");
- tabCompleterField.setAccessible(true);
- completeMethode = tabCompleterField.getClass().getMethod("func_186841_a");
- completeMethode.setAccessible(true);
- resetRequestedMethode = tabCompleterField.getClass().getMethod("func_186843_d");
- resetRequestedMethode.setAccessible(true);
- resetDidCompleteMethode = tabCompleterField.getClass().getMethod("func_186842_c");
- resetDidCompleteMethode.setAccessible(true);
- } catch (NoSuchFieldException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
- }
- @Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
- try {
- if (tabCompleterField == null) {
- tabCompleterField = GuiChat.class.getDeclaredField("field_184083_x");
- tabCompleterField.setAccessible(true);
- completeMethode = tabCompleterField.getClass().getMethod("func_186841_a");
- completeMethode.setAccessible(true);
- resetRequestedMethode = tabCompleterField.getClass().getMethod("func_186843_d");
- resetRequestedMethode.setAccessible(true);
- resetDidCompleteMethode = tabCompleterField.getClass().getMethod("func_186842_c");
- resetDidCompleteMethode.setAccessible(true);
- }
- resetRequestedMethode.invoke(tabCompleterField);
- if (keyCode == 15) {
- completeMethode.invoke(tabCompleterField);
- } else {
- resetDidCompleteMethode.invoke(tabCompleterField);
- }
- if (keyCode == 1) {
- this.mc.displayGuiScreen((GuiScreen) null);
- } else if (keyCode != 28 && keyCode != 156) {
- if (keyCode == 200) {
- this.getSentHistory(-1);
- } else if (keyCode == 208) {
- this.getSentHistory(1);
- } else if (keyCode == 201) {
- this.mc.ingameGUI.getChatGUI().scroll(this.mc.ingameGUI.getChatGUI().getLineCount() - 1);
- } else if (keyCode == 209) {
- this.mc.ingameGUI.getChatGUI().scroll(-this.mc.ingameGUI.getChatGUI().getLineCount() + 1);
- } else {
- this.inputField.textboxKeyTyped(typedChar, keyCode);
- String consoleText = this.inputField.getText();
- if (consoleText.startsWith("/login ") || consoleText.startsWith("/l ")) {
- if (consoleText.trim().matches(".*[a-z].*")
- || consoleText.trim().matches(".*[A-Z].*")
- || consoleText.trim().matches(".*[0-9].*")
- || consoleText.trim().matches(".*[^a-zA-Z0-9].*")) {
- String text = this.inputField.getText();
- String sb;
- int cLen;
- if (consoleText.startsWith("/login")) {
- sb = "/login ";
- cLen = 7;
- } else {
- sb = "/l ";
- cLen = 3;
- }
- if (text.length() - cLen >= passCount) {
- password += text.charAt(text.length() - 1);
- passCount += 1;
- } else {
- passCount -= 1;
- password = password.substring(0, passCount);
- }
- for (int c = cLen; c < text.length(); c++) {
- sb = sb + '*';
- }
- this.inputField.setText(sb);
- }
- } else if (consoleText.startsWith("/register ")) {
- if (keyCode == 8) {
- if (passCount > 0) {
- passCount--;
- doublePassword = doublePassword.substring(0, passCount);
- } else {
- passCount = 0;
- doublePassword = "";
- }
- } else if (consoleText.trim().matches(".*[a-z].*")
- || consoleText.trim().matches(".*[A-Z].*")
- || consoleText.trim().matches(".*[0-9].*")
- || consoleText.trim().matches(".*[^a-zA-Z0-9].*")) {
- String text = this.inputField.getText();
- String sb = "/register ";
- if (text.length() - 10 >= passCount) {
- doublePassword += text.charAt(text.length() - 1);
- passCount += 1;
- } else {
- passCount -= 1;
- doublePassword = doublePassword.substring(0, passCount);
- }
- int ct = 0;
- String[] pass = doublePassword.split(" ");
- for (String s : pass) {
- if (ct > 0) sb += " ";
- if (!s.equals("")) {
- for (int c = 0; c < s.length(); c++) {
- sb = sb + '*';
- }
- ct++;
- }
- }
- if (text.charAt(text.length() - 1) == ' ' && text.length() > 10) {
- sb += " ";
- }
- this.inputField.setText(sb);
- }
- }
- }
- } else {
- if (this.inputField.getText().startsWith("/l")) {
- if (passCount > 0) {
- this.sendChatMessage("/login " + password);
- }
- } else if (this.inputField.getText().startsWith("/register ")) {
- if (passCount > 0) {
- this.sendChatMessage("/register " + doublePassword);
- }
- } else {
- this.sendChatMessage(this.inputField.getText());
- }
- this.mc.displayGuiScreen((GuiScreen) null);
- }
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (NoSuchFieldException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement