Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //THE GUI
- package me.lordethan.cryton.utils;
- import java.io.IOException;
- import java.util.List;
- import me.lordethan.cryton.ui.GuiMaskedTextField;
- import me.lordethan.cryton.utils.LoginThread;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.gui.FontRenderer;
- import net.minecraft.client.gui.GuiButton;
- import net.minecraft.client.gui.GuiScreen;
- import net.minecraft.client.gui.GuiTextField;
- import net.minecraft.util.Session;
- import org.lwjgl.input.Keyboard;
- public class GuiLogin
- extends GuiScreen {
- private GuiTextField username;
- private GuiMaskedTextField password;
- private LoginThread loginThread;
- private GuiScreen parent;
- public GuiLogin(GuiScreen parent) {
- this.parent = parent;
- }
- @Override
- public void initGui() {
- GuiLogin.drawString(this.fontRendererObj, "Welcome \u00a7c" + GuiLogin.mc.session.username, this.width / 2 - this.fontRendererObj.getStringWidth("Welcome " + GuiLogin.mc.session.username) / 2, this.height - 10, -1);
- Keyboard.enableRepeatEvents((boolean)true);
- this.buttonList.clear();
- this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 92 + 12, "Login"));
- this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 116 + 12, "Back"));
- this.username = new GuiTextField(0, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20);
- this.username.setMaxStringLength(Integer.MAX_VALUE);
- this.username.setFocused(true);
- this.password = new GuiMaskedTextField(0, this.fontRendererObj, this.width / 2 - 100, 100, 200, 20);
- this.password.setMaxStringLength(Integer.MAX_VALUE);
- }
- @Override
- public void keyTyped(char character, int keyCode) {
- this.username.textboxKeyTyped(character, keyCode);
- this.password.textboxKeyTyped(character, keyCode);
- if (keyCode == 15) {
- this.username.setFocused(!this.username.isFocused());
- this.password.setFocused(!this.password.isFocused());
- }
- if (keyCode == 28) {
- this.actionPerformed((GuiButton)this.buttonList.get(0));
- }
- }
- @Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- this.username.mouseClicked(mouseX, mouseY, mouseButton);
- this.password.mouseClicked(mouseX, mouseY, mouseButton);
- }
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- this.drawDefaultBackground();
- GuiLogin.drawCenteredString(GuiLogin.mc.fontRendererObj, "Login", this.width / 2, 20, -1);
- if (this.username.getText().isEmpty()) {
- GuiLogin.drawString(GuiLogin.mc.fontRendererObj, "Username / E-Mail", this.width / 2 - 96, 66.0f, -7829368);
- }
- if (this.password.getText().isEmpty()) {
- GuiLogin.drawString(GuiLogin.mc.fontRendererObj, "Password", this.width / 2 - 96, 106.0f, -7829368);
- }
- this.username.drawTextBox();
- this.password.drawTextBox();
- GuiLogin.drawCenteredString(GuiLogin.mc.fontRendererObj, this.loginThread == null ? "Waiting" : this.loginThread.getStatus(), this.width / 2, 30, -1);
- GuiLogin.drawString(this.fontRendererObj, "Logged in As \u00a7c" + GuiLogin.mc.session.username, this.width / 2 - this.fontRendererObj.getStringWidth("Welcome " + GuiLogin.mc.session.username) / 2, this.height - 10, -1);
- super.drawScreen(mouseX, mouseY, partialTicks);
- }
- @Override
- protected void actionPerformed(GuiButton button) {
- switch (button.id) {
- case 0: {
- if (this.username.getText().isEmpty()) break;
- this.loginThread = new LoginThread(this.username.getText(), this.password.getText());
- this.loginThread.start();
- break;
- }
- case 1: {
- mc.displayGuiScreen(this.parent);
- }
- }
- }
- @Override
- public void onGuiClosed() {
- Keyboard.enableRepeatEvents((boolean)false);
- }
- @Override
- public void updateScreen() {
- this.username.updateCursorCounter();
- this.password.updateCursorCounter();
- }
- }
- //TEXTFIELD FOR THE PASSWORT
- package me.lordethan.cryton.ui;
- import com.google.common.base.Predicate;
- import com.google.common.base.Predicates;
- import net.minecraft.client.gui.FontRenderer;
- import net.minecraft.client.gui.Gui;
- import net.minecraft.client.gui.GuiPageButtonList;
- import net.minecraft.client.gui.GuiScreen;
- import net.minecraft.client.renderer.GlStateManager;
- import net.minecraft.client.renderer.Tessellator;
- import net.minecraft.client.renderer.WorldRenderer;
- import net.minecraft.util.ChatAllowedCharacters;
- import net.minecraft.util.MathHelper;
- public class GuiMaskedTextField
- extends Gui {
- private final int field_175208_g;
- private final FontRenderer fontRendererInstance;
- public int xPosition;
- public int yPosition;
- private final int width;
- private final int height;
- private String text = "";
- private int maxStringLength = 32;
- private int cursorCounter;
- private boolean enableBackgroundDrawing = true;
- private boolean canLoseFocus = true;
- private boolean isFocused;
- private boolean isEnabled = true;
- private int lineScrollOffset;
- private int cursorPosition;
- private int selectionEnd;
- private int enabledColor = 14737632;
- private int disabledColor = 7368816;
- private boolean visible = true;
- private GuiPageButtonList.GuiResponder field_175210_x;
- private Predicate field_175209_y = Predicates.alwaysTrue();
- private static final String __OBFID = "CL_00000670";
- public GuiMaskedTextField(int p_i45542_1_, FontRenderer p_i45542_2_, int p_i45542_3_, int p_i45542_4_, int p_i45542_5_, int p_i45542_6_) {
- this.field_175208_g = p_i45542_1_;
- this.fontRendererInstance = p_i45542_2_;
- this.xPosition = p_i45542_3_;
- this.yPosition = p_i45542_4_;
- this.width = p_i45542_5_;
- this.height = p_i45542_6_;
- }
- public void func_175207_a(GuiPageButtonList.GuiResponder p_175207_1_) {
- this.field_175210_x = p_175207_1_;
- }
- public void updateCursorCounter() {
- ++this.cursorCounter;
- }
- public void setText(String p_146180_1_) {
- if (this.field_175209_y.apply((Object)p_146180_1_)) {
- this.text = p_146180_1_.length() > this.maxStringLength ? p_146180_1_.substring(0, this.maxStringLength) : p_146180_1_;
- this.setCursorPositionEnd();
- }
- }
- public String getText() {
- return this.text;
- }
- public String getSelectedText() {
- int var1 = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd;
- int var2 = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition;
- return this.text.substring(var1, var2);
- }
- public void func_175205_a(Predicate p_175205_1_) {
- this.field_175209_y = p_175205_1_;
- }
- public void writeText(String p_146191_1_) {
- int var8;
- String var2 = "";
- String var3 = ChatAllowedCharacters.filterAllowedCharacters(p_146191_1_);
- int var4 = this.cursorPosition < this.selectionEnd ? this.cursorPosition : this.selectionEnd;
- int var5 = this.cursorPosition < this.selectionEnd ? this.selectionEnd : this.cursorPosition;
- int var6 = this.maxStringLength - this.text.length() - (var4 - var5);
- boolean var7 = false;
- if (this.text.length() > 0) {
- var2 = var2 + this.text.substring(0, var4);
- }
- if (var6 < var3.length()) {
- var2 = var2 + var3.substring(0, var6);
- var8 = var6;
- } else {
- var2 = var2 + var3;
- var8 = var3.length();
- }
- if (this.text.length() > 0 && var5 < this.text.length()) {
- var2 = var2 + this.text.substring(var5);
- }
- if (this.field_175209_y.apply((Object)var2)) {
- this.text = var2;
- this.moveCursorBy(var4 - this.selectionEnd + var8);
- if (this.field_175210_x != null) {
- this.field_175210_x.func_175319_a(this.field_175208_g, this.text);
- }
- }
- }
- public void deleteWords(int p_146177_1_) {
- if (this.text.length() != 0) {
- if (this.selectionEnd != this.cursorPosition) {
- this.writeText("");
- } else {
- this.deleteFromCursor(this.getNthWordFromCursor(p_146177_1_) - this.cursorPosition);
- }
- }
- }
- public void deleteFromCursor(int p_146175_1_) {
- if (this.text.length() != 0) {
- if (this.selectionEnd != this.cursorPosition) {
- this.writeText("");
- } else {
- boolean var2 = p_146175_1_ < 0;
- int var3 = var2 ? this.cursorPosition + p_146175_1_ : this.cursorPosition;
- int var4 = var2 ? this.cursorPosition : this.cursorPosition + p_146175_1_;
- String var5 = "";
- if (var3 >= 0) {
- var5 = this.text.substring(0, var3);
- }
- if (var4 < this.text.length()) {
- var5 = var5 + this.text.substring(var4);
- }
- this.text = var5;
- if (var2) {
- this.moveCursorBy(p_146175_1_);
- }
- if (this.field_175210_x != null) {
- this.field_175210_x.func_175319_a(this.field_175208_g, this.text);
- }
- }
- }
- }
- public int func_175206_d() {
- return this.field_175208_g;
- }
- public int getNthWordFromCursor(int p_146187_1_) {
- return this.getNthWordFromPos(p_146187_1_, this.getCursorPosition());
- }
- public int getNthWordFromPos(int p_146183_1_, int p_146183_2_) {
- return this.func_146197_a(p_146183_1_, p_146183_2_, true);
- }
- public int func_146197_a(int p_146197_1_, int p_146197_2_, boolean p_146197_3_) {
- int var4 = p_146197_2_;
- boolean var5 = p_146197_1_ < 0;
- int var6 = Math.abs(p_146197_1_);
- for (int var7 = 0; var7 < var6; ++var7) {
- if (var5) {
- while (p_146197_3_ && var4 > 0 && this.text.charAt(var4 - 1) == ' ') {
- --var4;
- }
- while (var4 > 0 && this.text.charAt(var4 - 1) != ' ') {
- --var4;
- }
- continue;
- }
- int var8 = this.text.length();
- if ((var4 = this.text.indexOf(32, var4)) == -1) {
- var4 = var8;
- continue;
- }
- while (p_146197_3_ && var4 < var8 && this.text.charAt(var4) == ' ') {
- ++var4;
- }
- }
- return var4;
- }
- public void moveCursorBy(int p_146182_1_) {
- this.setCursorPosition(this.selectionEnd + p_146182_1_);
- }
- public void setCursorPosition(int p_146190_1_) {
- this.cursorPosition = p_146190_1_;
- int var2 = this.text.length();
- this.cursorPosition = MathHelper.clamp_int(this.cursorPosition, 0, var2);
- this.setSelectionPos(this.cursorPosition);
- }
- public void setCursorPositionZero() {
- this.setCursorPosition(0);
- }
- public void setCursorPositionEnd() {
- this.setCursorPosition(this.text.length());
- }
- public boolean textboxKeyTyped(char p_146201_1_, int p_146201_2_) {
- if (!this.isFocused) {
- return false;
- }
- if (GuiScreen.func_175278_g(p_146201_2_)) {
- this.setCursorPositionEnd();
- this.setSelectionPos(0);
- return true;
- }
- if (GuiScreen.func_175280_f(p_146201_2_)) {
- GuiScreen.setClipboardString(this.getSelectedText());
- return true;
- }
- if (GuiScreen.func_175279_e(p_146201_2_)) {
- if (this.isEnabled) {
- this.writeText(GuiScreen.getClipboardString());
- }
- return true;
- }
- if (GuiScreen.func_175277_d(p_146201_2_)) {
- GuiScreen.setClipboardString(this.getSelectedText());
- if (this.isEnabled) {
- this.writeText("");
- }
- return true;
- }
- switch (p_146201_2_) {
- case 14: {
- if (GuiScreen.isCtrlKeyDown()) {
- if (this.isEnabled) {
- this.deleteWords(-1);
- }
- } else if (this.isEnabled) {
- this.deleteFromCursor(-1);
- }
- return true;
- }
- case 199: {
- if (GuiScreen.isShiftKeyDown()) {
- this.setSelectionPos(0);
- } else {
- this.setCursorPositionZero();
- }
- return true;
- }
- case 203: {
- if (GuiScreen.isShiftKeyDown()) {
- if (GuiScreen.isCtrlKeyDown()) {
- this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd()));
- } else {
- this.setSelectionPos(this.getSelectionEnd() - 1);
- }
- } else if (GuiScreen.isCtrlKeyDown()) {
- this.setCursorPosition(this.getNthWordFromCursor(-1));
- } else {
- this.moveCursorBy(-1);
- }
- return true;
- }
- case 205: {
- if (GuiScreen.isShiftKeyDown()) {
- if (GuiScreen.isCtrlKeyDown()) {
- this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd()));
- } else {
- this.setSelectionPos(this.getSelectionEnd() + 1);
- }
- } else if (GuiScreen.isCtrlKeyDown()) {
- this.setCursorPosition(this.getNthWordFromCursor(1));
- } else {
- this.moveCursorBy(1);
- }
- return true;
- }
- case 207: {
- if (GuiScreen.isShiftKeyDown()) {
- this.setSelectionPos(this.text.length());
- } else {
- this.setCursorPositionEnd();
- }
- return true;
- }
- case 211: {
- if (GuiScreen.isCtrlKeyDown()) {
- if (this.isEnabled) {
- this.deleteWords(1);
- }
- } else if (this.isEnabled) {
- this.deleteFromCursor(1);
- }
- return true;
- }
- }
- if (ChatAllowedCharacters.isAllowedCharacter(p_146201_1_)) {
- if (this.isEnabled) {
- this.writeText(Character.toString(p_146201_1_));
- }
- return true;
- }
- return false;
- }
- public void mouseClicked(int p_146192_1_, int p_146192_2_, int p_146192_3_) {
- boolean var4;
- boolean bl = var4 = p_146192_1_ >= this.xPosition && p_146192_1_ < this.xPosition + this.width && p_146192_2_ >= this.yPosition && p_146192_2_ < this.yPosition + this.height;
- if (this.canLoseFocus) {
- this.setFocused(var4);
- }
- if (this.isFocused && var4 && p_146192_3_ == 0) {
- int var5 = p_146192_1_ - this.xPosition;
- if (this.enableBackgroundDrawing) {
- var5-=4;
- }
- String var6 = this.fontRendererInstance.trimStringToWidth(this.text.substring(this.lineScrollOffset), this.getWidth());
- this.setCursorPosition(this.fontRendererInstance.trimStringToWidth(var6, var5).length() + this.lineScrollOffset);
- }
- }
- public void drawTextBox() {
- if (this.getVisible()) {
- if (this.getEnableBackgroundDrawing()) {
- GuiMaskedTextField.drawRect(this.xPosition - 1, this.yPosition - 1, this.xPosition + this.width + 1, this.yPosition + this.height + 1, -6250336);
- GuiMaskedTextField.drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, -16777216);
- }
- int var1 = this.isEnabled ? this.enabledColor : this.disabledColor;
- int var2 = this.cursorPosition - this.lineScrollOffset;
- int var3 = this.selectionEnd - this.lineScrollOffset;
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < this.text.length(); ++i) {
- sb.append("*");
- }
- String text = sb.toString();
- String var4 = this.fontRendererInstance.trimStringToWidth(text.substring(this.lineScrollOffset), this.getWidth());
- boolean var5 = var2 >= 0 && var2 <= var4.length();
- boolean var6 = this.isFocused && this.cursorCounter / 6 % 2 == 0 && var5;
- int var7 = this.enableBackgroundDrawing ? this.xPosition + 4 : this.xPosition;
- int var8 = this.enableBackgroundDrawing ? this.yPosition + (this.height - 8) / 2 : this.yPosition;
- int var9 = var7;
- if (var3 > var4.length()) {
- var3 = var4.length();
- }
- if (var4.length() > 0) {
- String var10 = var5 ? var4.substring(0, var2) : var4;
- var9 = this.fontRendererInstance.func_175063_a(var10, var7, var8, var1);
- }
- boolean var13 = this.cursorPosition < this.text.length() || this.text.length() >= this.getMaxStringLength();
- int var11 = var9;
- if (!var5) {
- var11 = var2 > 0 ? var7 + this.width : var7;
- } else if (var13) {
- var11 = var9 - 1;
- --var9;
- }
- if (var4.length() > 0 && var5 && var2 < var4.length()) {
- var9 = this.fontRendererInstance.func_175063_a(var4.substring(var2), var9, var8, var1);
- }
- if (var6) {
- if (var13) {
- Gui.drawRect(var11, var8 - 1, var11 + 1, var8 + 1 + this.fontRendererInstance.FONT_HEIGHT, -3092272);
- } else {
- this.fontRendererInstance.func_175063_a("_", var11, var8, var1);
- }
- }
- if (var3 != var2) {
- int var12 = var7 + this.fontRendererInstance.getStringWidth(var4.substring(0, var3));
- this.drawCursorVertical(var11, var8 - 1, var12 - 1, var8 + 1 + this.fontRendererInstance.FONT_HEIGHT);
- }
- }
- }
- private void drawCursorVertical(int p_146188_1_, int p_146188_2_, int p_146188_3_, int p_146188_4_) {
- int var5;
- if (p_146188_1_ < p_146188_3_) {
- var5 = p_146188_1_;
- p_146188_1_ = p_146188_3_;
- p_146188_3_ = var5;
- }
- if (p_146188_2_ < p_146188_4_) {
- var5 = p_146188_2_;
- p_146188_2_ = p_146188_4_;
- p_146188_4_ = var5;
- }
- if (p_146188_3_ > this.xPosition + this.width) {
- p_146188_3_ = this.xPosition + this.width;
- }
- if (p_146188_1_ > this.xPosition + this.width) {
- p_146188_1_ = this.xPosition + this.width;
- }
- Tessellator var7 = Tessellator.getInstance();
- WorldRenderer var6 = var7.getWorldRenderer();
- GlStateManager.color(0.0f, 0.0f, 255.0f, 255.0f);
- GlStateManager.func_179090_x();
- GlStateManager.enableColorLogic();
- GlStateManager.colorLogicOp(5387);
- var6.startDrawingQuads();
- var6.addVertex(p_146188_1_, p_146188_4_, 0.0);
- var6.addVertex(p_146188_3_, p_146188_4_, 0.0);
- var6.addVertex(p_146188_3_, p_146188_2_, 0.0);
- var6.addVertex(p_146188_1_, p_146188_2_, 0.0);
- var7.draw();
- GlStateManager.disableColorLogic();
- GlStateManager.func_179098_w();
- }
- public void setMaxStringLength(int p_146203_1_) {
- this.maxStringLength = p_146203_1_;
- if (this.text.length() > p_146203_1_) {
- this.text = this.text.substring(0, p_146203_1_);
- }
- }
- public int getMaxStringLength() {
- return this.maxStringLength;
- }
- public int getCursorPosition() {
- return this.cursorPosition;
- }
- public boolean getEnableBackgroundDrawing() {
- return this.enableBackgroundDrawing;
- }
- public void setEnableBackgroundDrawing(boolean p_146185_1_) {
- this.enableBackgroundDrawing = p_146185_1_;
- }
- public void setTextColor(int p_146193_1_) {
- this.enabledColor = p_146193_1_;
- }
- public void setDisabledTextColour(int p_146204_1_) {
- this.disabledColor = p_146204_1_;
- }
- public void setFocused(boolean p_146195_1_) {
- if (p_146195_1_ && !this.isFocused) {
- this.cursorCounter = 0;
- }
- this.isFocused = p_146195_1_;
- }
- public boolean isFocused() {
- return this.isFocused;
- }
- public void setEnabled(boolean p_146184_1_) {
- this.isEnabled = p_146184_1_;
- }
- public int getSelectionEnd() {
- return this.selectionEnd;
- }
- public int getWidth() {
- return this.getEnableBackgroundDrawing() ? this.width - 8 : this.width;
- }
- public void setSelectionPos(int p_146199_1_) {
- int var2 = this.text.length();
- if (p_146199_1_ > var2) {
- p_146199_1_ = var2;
- }
- if (p_146199_1_ < 0) {
- p_146199_1_ = 0;
- }
- this.selectionEnd = p_146199_1_;
- if (this.fontRendererInstance != null) {
- if (this.lineScrollOffset > var2) {
- this.lineScrollOffset = var2;
- }
- int var3 = this.getWidth();
- String var4 = this.fontRendererInstance.trimStringToWidth(this.text.substring(this.lineScrollOffset), var3);
- int var5 = var4.length() + this.lineScrollOffset;
- if (p_146199_1_ == this.lineScrollOffset) {
- this.lineScrollOffset-=this.fontRendererInstance.trimStringToWidth(this.text, var3, true).length();
- }
- if (p_146199_1_ > var5) {
- this.lineScrollOffset+=p_146199_1_ - var5;
- } else if (p_146199_1_ <= this.lineScrollOffset) {
- this.lineScrollOffset-=this.lineScrollOffset - p_146199_1_;
- }
- this.lineScrollOffset = MathHelper.clamp_int(this.lineScrollOffset, 0, var2);
- }
- }
- public void setCanLoseFocus(boolean p_146205_1_) {
- this.canLoseFocus = p_146205_1_;
- }
- public boolean getVisible() {
- return this.visible;
- }
- public void setVisible(boolean p_146189_1_) {
- this.visible = p_146189_1_;
- }
- }
- /*
- * Decompiled with CFR 0_110.
- *
- * Could not load the following classes:
- * com.mojang.authlib.Agent
- * com.mojang.authlib.GameProfile
- * com.mojang.authlib.UserAuthentication
- * com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService
- * com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication
- */
- package me.lordethan.cryton.utils;
- import com.mojang.authlib.Agent;
- import com.mojang.authlib.GameProfile;
- import com.mojang.authlib.UserAuthentication;
- import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
- import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
- import java.net.Proxy;
- import java.util.UUID;
- import me.lordethan.cryton.utils.ChatColor;
- import net.minecraft.client.Minecraft;
- import net.minecraft.util.Session;
- public class LoginThread
- extends Thread {
- private final Minecraft mc = Minecraft.getMinecraft();
- private String status;
- private final String username;
- private final String password;
- public LoginThread(String username, String password) {
- super("Login Thread");
- this.username = username;
- this.password = password;
- this.status = "Current Account :" + this.username;
- }
- private final Session createSession(String username, String password) {
- YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
- YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication)service.createUserAuthentication(Agent.MINECRAFT);
- auth.setUsername(username);
- auth.setPassword(password);
- try {
- auth.logIn();
- return new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(), auth.getAuthenticatedToken(), "mojang");
- }
- catch (Exception e) {
- return null;
- }
- }
- public String getStatus() {
- return this.status;
- }
- @Override
- public void run() {
- if (this.password.equals("")) {
- this.mc.session = new Session(this.username, "", "", "mojang");
- this.status = (Object)((Object)ChatColor.GREEN) + "Logged in. " + this.username + " - cracked";
- return;
- }
- this.status = (Object)((Object)ChatColor.YELLOW) + "Logging in";
- Session auth = this.createSession(this.username, this.password);
- if (auth == null) {
- this.status = (Object)((Object)ChatColor.RED) + "Login failed";
- } else {
- this.status = (Object)((Object)ChatColor.GREEN) + "Logged in. (" + auth.getUsername() + ")";
- this.mc.session = auth;
- }
- }
- public void setStatus(String status) {
- this.status = status;
- }
- }
- package me.lordethan.cryton.utils;
- import com.mojang.authlib.Agent;
- import com.mojang.authlib.GameProfile;
- import com.mojang.authlib.UserAuthentication;
- import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
- import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
- import java.net.Proxy;
- import java.util.UUID;
- import me.lordethan.cryton.utils.ChatColor;
- import net.minecraft.client.Minecraft;
- import net.minecraft.util.Session;
- public class LoginThread
- extends Thread {
- private final Minecraft mc = Minecraft.getMinecraft();
- private String status;
- private final String username;
- private final String password;
- public LoginThread(String username, String password) {
- super("Login Thread");
- this.username = username;
- this.password = password;
- this.status = "Current Account :" + this.username;
- }
- private final Session createSession(String username, String password) {
- YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
- YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication)service.createUserAuthentication(Agent.MINECRAFT);
- auth.setUsername(username);
- auth.setPassword(password);
- try {
- auth.logIn();
- return new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(), auth.getAuthenticatedToken(), "mojang");
- }
- catch (Exception e) {
- return null;
- }
- }
- public String getStatus() {
- return this.status;
- }
- @Override
- public void run() {
- if (this.password.equals("")) {
- this.mc.session = new Session(this.username, "", "", "mojang");
- this.status = (Object)((Object)ChatColor.GREEN) + "Logged in. " + this.username + " - cracked";
- return;
- }
- this.status = (Object)((Object)ChatColor.YELLOW) + "Logging in";
- Session auth = this.createSession(this.username, this.password);
- if (auth == null) {
- this.status = (Object)((Object)ChatColor.RED) + "Login failed";
- } else {
- this.status = (Object)((Object)ChatColor.GREEN) + "Logged in. (" + auth.getUsername() + ")";
- this.mc.session = auth;
- }
- }
- public void setStatus(String status) {
- this.status = status;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement