use of io.xol.chunkstories.bugsreporter.JavaCrashesUploader in project chunkstories by Hugobros3.
the class LoginPrompt method connect.
private void connect() {
if (usernameForm.getText().equals("OFFLINE")) {
Client.offline = true;
Client.username = "OfflineUser" + (int) (Math.random() * 1000);
gameWindow.setLayer(new MainMenu(gameWindow, parentLayer));
} else {
logging_in = true;
RequestResultAction postAction = (result) -> {
gameWindow.getClient().logger().debug("Received login answer");
logging_in = false;
if (result == null) {
failed_login = true;
message = "Can't connect to server.";
return;
}
if (result.startsWith("ok")) {
String session = result.split(":")[1];
Client.username = usernameForm.getText();
Client.session_key = session;
Client.getInstance().getConfiguration().getOption("client.login.auto").trySetting("ok");
Client.getInstance().getConfiguration().getOption("client.login.username").trySetting(usernameForm.getText());
Client.getInstance().getConfiguration().getOption("client.login.password").trySetting(passwordForm.getText());
if (Client.username.equals("Gobrosse") || Client.username.equals("kektest")) {
ClientLimitations.isDebugAllowed = true;
}
// If the user didn't opt-out, look for crash files and upload those
if (Client.getInstance().getConfiguration().getStringOption("client.game.log-policy").equals("send")) {
JavaCrashesUploader t = new JavaCrashesUploader(Client.getInstance());
t.start();
}
can_next = true;
} else if (result.startsWith("ko")) {
failed_login = true;
String reason = result.split(":")[1];
if (reason.equals("notpremium"))
message = ("User is not premium");
else if (reason.equals("invalidcredentials"))
message = ("Invalid credentials");
} else {
message = ("Unknown error");
}
};
new SimplePostRequest("https://chunkstories.xyz/api/login.php", "user=" + usernameForm.getText() + "&pass=" + passwordForm.getText(), postAction);
}
}
Aggregations