Advertisement
Guest User

Untitled

a guest
Jun 4th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.28 KB | None | 0 0
  1. /*
  2. * Decompiled with CFR 0_115.
  3. */
  4. package de.scrush.altmanager;
  5.  
  6. import com.mojang.authlib.Agent;
  7. import com.mojang.authlib.GameProfile;
  8. import com.mojang.authlib.UserAuthentication;
  9. import com.mojang.authlib.exceptions.AuthenticationException;
  10. import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
  11. import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
  12.  
  13. import de.scrush.backgroundchanger.Listener;
  14. import de.scrush.home.Scrush;
  15. import de.scrush.utils.Alts;
  16.  
  17. import java.io.IOException;
  18. import java.net.Proxy;
  19. import java.util.ArrayList;
  20. import java.util.List;
  21. import net.minecraft.client.Minecraft;
  22. import net.minecraft.client.gui.FontRenderer;
  23. import net.minecraft.client.gui.GuiButton;
  24. import net.minecraft.client.gui.GuiScreen;
  25. import net.minecraft.client.gui.GuiTextField;
  26. import net.minecraft.util.EnumChatFormatting;
  27. import org.lwjgl.input.Keyboard;
  28.  
  29. public class GuiAddAlt extends GuiScreen {
  30. private final GuiAltManager manager;
  31. private PasswordField password;
  32. private String status = (Object) ((Object) EnumChatFormatting.GRAY) + "Idle...";
  33. private GuiTextField username;
  34.  
  35. public GuiAddAlt(GuiAltManager manager) {
  36. this.manager = manager;
  37. }
  38.  
  39. @Override
  40. protected void actionPerformed(GuiButton button) {
  41. switch (button.id) {
  42. case 0: {
  43. AddAltThread login = new AddAltThread(this.username.getText(), this.password.getText());
  44. login.start();
  45. break;
  46. }
  47. case 1: {
  48. this.mc.displayGuiScreen(this.manager);
  49. }
  50. }
  51. }
  52.  
  53. @Override
  54. public void drawScreen(int i2, int j2, float f2) {
  55. Listener.drawBackground();
  56. this.username.drawTextBox();
  57. this.password.drawTextBox();
  58. this.drawCenteredString(this.fontRendererObj, "Add Alt", width / 2, 20, -1);
  59. if (this.username.getText().isEmpty()) {
  60. this.drawString(this.mc.fontRendererObj, "Username / E-Mail", width / 2 - 96, 66, -7829368);
  61. }
  62. if (this.password.getText().isEmpty()) {
  63. this.drawString(this.mc.fontRendererObj, "Password", width / 2 - 96, 106, -7829368);
  64. }
  65. this.drawCenteredString(this.fontRendererObj, this.status, width / 2, 30, -1);
  66. super.drawScreen(i2, j2, f2);
  67. }
  68.  
  69. @Override
  70. public void initGui() {
  71. Keyboard.enableRepeatEvents(true);
  72. this.buttonList.clear();
  73. this.buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 92 + 12, "Login"));
  74. this.buttonList.add(new GuiButton(1, width / 2 - 100, height / 4 + 116 + 12, "Back"));
  75. this.buttonList.add(new GuiButton(2, width / 2 - 100, height / 4 + 68 + 12, "CopyPaste-Login"));
  76. this.username = new GuiTextField(this.eventButton, this.mc.fontRendererObj, width / 2 - 100, 60, 200, 20);
  77. this.password = new PasswordField(this.mc.fontRendererObj, width / 2 - 100, 100, 200, 20);
  78. }
  79.  
  80. @Override
  81. protected void keyTyped(char par1, int par2) {
  82. this.username.textboxKeyTyped(par1, par2);
  83. this.password.textboxKeyTyped(par1, par2);
  84. if (par1 == '\t' && (this.username.isFocused() || this.password.isFocused())) {
  85. this.username.setFocused(!this.username.isFocused());
  86. this.password.setFocused(!this.password.isFocused());
  87. }
  88. if (par1 == '\r') {
  89. this.actionPerformed((GuiButton) this.buttonList.get(0));
  90. }
  91. }
  92.  
  93. @Override
  94. protected void mouseClicked(int par1, int par2, int par3) {
  95. try {
  96. super.mouseClicked(par1, par2, par3);
  97. } catch (IOException e) {
  98. e.printStackTrace();
  99. }
  100. this.username.mouseClicked(par1, par2, par3);
  101. this.password.mouseClicked(par1, par2, par3);
  102. }
  103.  
  104. static void access$0(GuiAddAlt guiAddAlt, String status) {
  105. guiAddAlt.status = status;
  106. }
  107.  
  108. private class AddAltThread extends Thread {
  109. private final String password;
  110. private final String username;
  111.  
  112. public AddAltThread(String username, String password) {
  113. this.username = username;
  114. this.password = password;
  115. GuiAddAlt.access$0(GuiAddAlt.this, (Object) ((Object) EnumChatFormatting.GRAY) + "Idle...");
  116. }
  117.  
  118. private final void checkAndAddAlt(String username, String password) throws IOException {
  119. YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
  120. YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) service
  121. .createUserAuthentication(Agent.MINECRAFT);
  122. auth.setUsername(username);
  123. auth.setPassword(password);
  124. try {
  125. auth.logIn();
  126. AltManager altManager = Scrush.altManager;
  127. AltManager.registry.add(new Alt(username, password, auth.getSelectedProfile().getName()));
  128. Scrush.manager2.getFile(Alts.class).saveFile();
  129. GuiAddAlt.access$0(GuiAddAlt.this, "Alt added. (" + username + ")");
  130. } catch (AuthenticationException e) {
  131. GuiAddAlt.access$0(GuiAddAlt.this, (Object) ((Object) EnumChatFormatting.RED) + "Alt failed!");
  132. e.printStackTrace();
  133. }
  134. }
  135.  
  136. @Override
  137. public void run() {
  138. if (this.password.equals("")) {
  139. AltManager altManager = Scrush.altManager;
  140. AltManager.registry.add(new Alt(this.username, ""));
  141. GuiAddAlt.access$0(GuiAddAlt.this, (Object) ((Object) EnumChatFormatting.GREEN) + "Alt added. ("
  142. + this.username + " - offline name)");
  143. return;
  144. }
  145. GuiAddAlt.access$0(GuiAddAlt.this, (Object) ((Object) EnumChatFormatting.YELLOW) + "Trying alt...");
  146. try {
  147. this.checkAndAddAlt(this.username, this.password);
  148. } catch (IOException e) {
  149. e.printStackTrace();
  150. }
  151. }
  152. }
  153.  
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement