Skip to content

Commit

Permalink
1.09_15-pre3
Browse files Browse the repository at this point in the history
  • Loading branch information
Moresteck committed Sep 30, 2021
1 parent 302cc80 commit dc8b830
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
6 changes: 2 additions & 4 deletions src/main/java/org/betacraft/launcher/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public static void refresh(boolean download, boolean force) {
LOGIN_EMAIL_NICKNAME = Util.getProperty(file, "login_email_nickname", charset);
LOGIN_PASSWORD = Util.getProperty(file, "login_password", charset);
LOGIN_MOJANG_HEADER = Util.getProperty(file, "login_mojang_header", charset);
LOGIN_MICROSOFT_HEADER = Util.getProperty(file, "login_microsoft_header", charset);
LOGIN_MICROSOFT_BUTTON = Util.getProperty(file, "login_microsoft_button", charset);
LOGIN_MICROSOFT_TITLE = Util.getProperty(file, "login_microsoft_title", charset);
LOGIN_MICROSOFT_ERROR = Util.getProperty(file, "login_microsoft_error", charset);
LOGIN_MICROSOFT_PARENT = Util.getProperty(file, "login_microsoft_parent", charset);
Expand Down Expand Up @@ -326,9 +326,7 @@ public static void refresh(boolean download, boolean force) {
public static String LOGIN_EMAIL_NICKNAME = "E-mail:";
public static String LOGIN_PASSWORD = "Password:";
public static String LOGIN_MOJANG_HEADER = "... or login with a Mojang account:";
public static String LOGIN_MICROSOFT_HEADER = "Login with Microsoft";
public static String LOGIN_MICROSOFT_BROWSER = "via browser";
public static String LOGIN_MICROSOFT_PROMPT = "via prompt";
public static String LOGIN_MICROSOFT_BUTTON = "Login with Microsoft";
public static String LOGIN_MICROSOFT_TITLE = "Login with your Microsoft account";
public static String LOGIN_MICROSOFT_ERROR = "Microsoft authentication error";
public static String LOGIN_MICROSOFT_PARENT = "Parental approval required. Add this account to Family to login.";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/betacraft/launcher/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

/** Main class */
public class Launcher {
public static String VERSION = "1.09_15-pre2"; // TODO Always update this
public static String VERSION = "1.09_15-pre3"; // TODO Always update this

public static Instance currentInstance;
public static boolean forceUpdate = false;
Expand Down
32 changes: 22 additions & 10 deletions src/main/java/org/betacraft/launcher/ListenThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ public void run() {
try {
while (running) {
Socket sock = this.socket.accept();
System.out.println("oh yes");
try {
byte[] bytes = readInputStreamBytes(sock.getInputStream());
String http = new String(bytes, "UTF-8");
System.out.println(http);
// msa
if (http.startsWith("GET " + MicrosoftAuth.AUTH_URI)) {
System.out.println("Received Microsoft login response");

respond(sock);

MicrosoftAuth msa = new MicrosoftAuth(null);
msa.code = http.substring(http.indexOf("=")+1, http.indexOf(" HTTP/"));
try {
Expand All @@ -46,16 +50,6 @@ public void run() {
sock.close();
continue;
}
BufferedWriter bos = new BufferedWriter(
new OutputStreamWriter(
new BufferedOutputStream(sock.getOutputStream()), "UTF-8"));
bos.write("HTTP/1.1 200 OK\r\n" +
"Content-Type: text/html\r\n" +
"\r\n\r\n");
bos.write("<html> <head> <title>All done!</title> <script> window.onload = function() { window.close(); } </script> </head> <body> <center><h1>You can now close this tab.</h1></center> </html>");
bos.flush();
bos.close();
sock.close();
} catch (Throwable t) {}
}
// close on exit
Expand Down Expand Up @@ -90,4 +84,22 @@ public static byte[] readInputStreamBytes(InputStream in) {
return null;
}
}

public static void respond(Socket sock) {
try {
BufferedWriter bos = new BufferedWriter(
new OutputStreamWriter(
new BufferedOutputStream(sock.getOutputStream()), "UTF-8"));
bos.write("HTTP/1.1 200 OK\r\n" +
"Content-Type: text/html\r\n" +
"\r\n\r\n");
bos.write("<html> <head> <title>All done!</title> </head> <body> <center><h1>You can now close this tab.</h1></center> </html>");
bos.flush();
bos.close();
sock.close();
} catch (Throwable t) {
t.printStackTrace();
Logger.printException(t);
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/betacraft/launcher/LoginPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public LoginPanel() {
constr.insets = new Insets(10, 10, 0, 10);

constr.gridwidth = 3;
JButton microsoftbrowser = new JButton(Lang.LOGIN_MICROSOFT_HEADER);
JButton microsoftbrowser = new JButton(Lang.LOGIN_MICROSOFT_BUTTON);
microsoftbrowser.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Expand Down

0 comments on commit dc8b830

Please sign in to comment.