mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 16:49:10 +00:00
Added option to save credentials
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
package org.parabot;
|
||||
|
||||
import org.parabot.core.Configuration;
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.Directories;
|
||||
import org.parabot.core.forum.AccountManager;
|
||||
import org.parabot.core.ui.BotUI;
|
||||
import org.parabot.core.ui.ServerSelector;
|
||||
import org.parabot.core.ui.utils.UILog;
|
||||
import org.parabot.environment.api.utils.WebUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Parabot v2.1
|
||||
@@ -48,7 +52,13 @@ public final class Landing {
|
||||
Core.verbose("Validating account manager...");
|
||||
AccountManager.validate();
|
||||
|
||||
if (username != null && password != null) {
|
||||
if (getCredentials() != null && getCredentials().length == 2){
|
||||
if ((username = getCredentials()[0]) != null && (password = getCredentials()[1]) != null){
|
||||
new BotUI(username, password);
|
||||
}
|
||||
username = null;
|
||||
password = null;
|
||||
}else if (username != null && password != null) {
|
||||
new BotUI(username, password);
|
||||
username = null;
|
||||
password = null;
|
||||
@@ -59,6 +69,22 @@ public final class Landing {
|
||||
new BotUI(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of string containing only the username and password
|
||||
* @return String array with username and password
|
||||
*/
|
||||
private static String[] getCredentials(){
|
||||
try {
|
||||
BufferedReader bufferedReader = WebUtil.getReader(new URL(Configuration.GET_PASSWORD));
|
||||
if (bufferedReader.readLine() != null){
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void parseArgs(String... args) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
final String arg = args[i].toLowerCase();
|
||||
|
||||
@@ -14,6 +14,7 @@ public class Configuration {
|
||||
public static final String GET_SERVER_PROVIDER_INFO = "http://bdn.parabot.org/api/get.php?action=server_information&name=";
|
||||
public static final String GET_BOT_VERSION = "http://bot.parabot.org/version.txt";
|
||||
public static final String REGISTRATION_PAGE = "https://www.parabot.org/community/index.php?app=core&module=global§ion=register";
|
||||
public static final String GET_PASSWORD = "http://bdn.parabot.org/api/get.php?action=password";
|
||||
|
||||
public static final double BOT_VERSION = 2.1;
|
||||
}
|
||||
|
||||
@@ -120,25 +120,6 @@ public class Core {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO Get checksum from BDN and verify
|
||||
// BufferedReader br = WebUtil.getReader(Configuration.GET_BOT_VERSION);
|
||||
// try {
|
||||
// double version = Double.parseDouble(br.readLine());
|
||||
// if (Configuration.BOT_VERSION != version) {
|
||||
// Core.verbose("Updates available...");
|
||||
// return false;
|
||||
// }
|
||||
// } catch (NumberFormatException | IOException e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// try {
|
||||
// br.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user