Advertisement
FuskedLLCC

Untitled

Nov 25th, 2020 (edited)
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | None | 0 0
  1. package xyz.ultrapixelmon.pepefab;
  2.  
  3. import net.minecraft.client.gui.GuiChat;
  4. import net.minecraft.client.gui.GuiScreen;
  5.  
  6. import java.io.IOException;
  7. import java.lang.reflect.Field;
  8. import java.lang.reflect.InvocationTargetException;
  9. import java.lang.reflect.Method;
  10.  
  11. public class NewChat2 extends GuiChat{
  12.  
  13. private String password = "";
  14. private String doublePassword = "";
  15. private int passCount = 0;
  16.  
  17. public Field tabCompleterField;
  18. public Method completeMethode;
  19. public Method resetRequestedMethode;
  20. public Method resetDidCompleteMethode;
  21.  
  22. public NewChat2() {
  23. try {
  24.  
  25. tabCompleterField = GuiChat.class.getDeclaredField("field_184083_x");
  26. tabCompleterField.setAccessible(true);
  27. completeMethode = tabCompleterField.getClass().getMethod("func_186841_a");
  28. completeMethode.setAccessible(true);
  29. resetRequestedMethode = tabCompleterField.getClass().getMethod("func_186843_d");
  30. resetRequestedMethode.setAccessible(true);
  31. resetDidCompleteMethode = tabCompleterField.getClass().getMethod("func_186842_c");
  32. resetDidCompleteMethode.setAccessible(true);
  33.  
  34.  
  35. } catch (NoSuchFieldException e) {
  36. e.printStackTrace();
  37. } catch (NoSuchMethodException e) {
  38. e.printStackTrace();
  39. }
  40. }
  41. @Override
  42. protected void keyTyped(char typedChar, int keyCode) throws IOException {
  43. try {
  44. if (tabCompleterField == null) {
  45. tabCompleterField = GuiChat.class.getDeclaredField("field_184083_x");
  46. tabCompleterField.setAccessible(true);
  47. completeMethode = tabCompleterField.getClass().getMethod("func_186841_a");
  48. completeMethode.setAccessible(true);
  49. resetRequestedMethode = tabCompleterField.getClass().getMethod("func_186843_d");
  50. resetRequestedMethode.setAccessible(true);
  51. resetDidCompleteMethode = tabCompleterField.getClass().getMethod("func_186842_c");
  52. resetDidCompleteMethode.setAccessible(true);
  53. }
  54.  
  55.  
  56. resetRequestedMethode.invoke(tabCompleterField);
  57.  
  58. if (keyCode == 15) {
  59.  
  60. completeMethode.invoke(tabCompleterField);
  61.  
  62. } else {
  63.  
  64. resetDidCompleteMethode.invoke(tabCompleterField);
  65.  
  66. }
  67.  
  68. if (keyCode == 1) {
  69. this.mc.displayGuiScreen((GuiScreen) null);
  70. } else if (keyCode != 28 && keyCode != 156) {
  71. if (keyCode == 200) {
  72. this.getSentHistory(-1);
  73. } else if (keyCode == 208) {
  74. this.getSentHistory(1);
  75. } else if (keyCode == 201) {
  76. this.mc.ingameGUI.getChatGUI().scroll(this.mc.ingameGUI.getChatGUI().getLineCount() - 1);
  77. } else if (keyCode == 209) {
  78. this.mc.ingameGUI.getChatGUI().scroll(-this.mc.ingameGUI.getChatGUI().getLineCount() + 1);
  79. } else {
  80. this.inputField.textboxKeyTyped(typedChar, keyCode);
  81. String consoleText = this.inputField.getText();
  82.  
  83. if (consoleText.startsWith("/login ") || consoleText.startsWith("/l ")) {
  84.  
  85. if (consoleText.trim().matches(".*[a-z].*")
  86. || consoleText.trim().matches(".*[A-Z].*")
  87. || consoleText.trim().matches(".*[0-9].*")
  88. || consoleText.trim().matches(".*[^a-zA-Z0-9].*")) {
  89.  
  90. String text = this.inputField.getText();
  91. String sb;
  92. int cLen;
  93.  
  94. if (consoleText.startsWith("/login")) {
  95. sb = "/login ";
  96. cLen = 7;
  97. } else {
  98. sb = "/l ";
  99. cLen = 3;
  100. }
  101. if (text.length() - cLen >= passCount) {
  102. password += text.charAt(text.length() - 1);
  103. passCount += 1;
  104. } else {
  105. passCount -= 1;
  106. password = password.substring(0, passCount);
  107. }
  108. for (int c = cLen; c < text.length(); c++) {
  109. sb = sb + '*';
  110. }
  111.  
  112. this.inputField.setText(sb);
  113. }
  114. } else if (consoleText.startsWith("/register ")) {
  115. if (keyCode == 8) {
  116. if (passCount > 0) {
  117. passCount--;
  118. doublePassword = doublePassword.substring(0, passCount);
  119. } else {
  120. passCount = 0;
  121. doublePassword = "";
  122. }
  123. } else if (consoleText.trim().matches(".*[a-z].*")
  124. || consoleText.trim().matches(".*[A-Z].*")
  125. || consoleText.trim().matches(".*[0-9].*")
  126. || consoleText.trim().matches(".*[^a-zA-Z0-9].*")) {
  127.  
  128. String text = this.inputField.getText();
  129. String sb = "/register ";
  130.  
  131. if (text.length() - 10 >= passCount) {
  132. doublePassword += text.charAt(text.length() - 1);
  133. passCount += 1;
  134. } else {
  135. passCount -= 1;
  136. doublePassword = doublePassword.substring(0, passCount);
  137. }
  138.  
  139. int ct = 0;
  140. String[] pass = doublePassword.split(" ");
  141. for (String s : pass) {
  142. if (ct > 0) sb += " ";
  143. if (!s.equals("")) {
  144. for (int c = 0; c < s.length(); c++) {
  145. sb = sb + '*';
  146. }
  147. ct++;
  148. }
  149. }
  150. if (text.charAt(text.length() - 1) == ' ' && text.length() > 10) {
  151. sb += " ";
  152. }
  153. this.inputField.setText(sb);
  154. }
  155. }
  156.  
  157. }
  158. } else {
  159. if (this.inputField.getText().startsWith("/l")) {
  160. if (passCount > 0) {
  161. this.sendChatMessage("/login " + password);
  162. }
  163. } else if (this.inputField.getText().startsWith("/register ")) {
  164. if (passCount > 0) {
  165. this.sendChatMessage("/register " + doublePassword);
  166. }
  167. } else {
  168. this.sendChatMessage(this.inputField.getText());
  169. }
  170.  
  171. this.mc.displayGuiScreen((GuiScreen) null);
  172. }
  173. } catch (NoSuchMethodException e) {
  174. e.printStackTrace();
  175. } catch (NoSuchFieldException e) {
  176. e.printStackTrace();
  177. } catch (IllegalAccessException e) {
  178. e.printStackTrace();
  179. } catch (InvocationTargetException e) {
  180. e.printStackTrace();
  181. }
  182. }
  183. }
  184.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement