mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 00:37:55 +00:00
@@ -1,7 +1,6 @@
|
||||
package org.parabot;
|
||||
|
||||
import org.parabot.api.translations.TranslationHelper;
|
||||
import org.parabot.core.Configuration;
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.Directories;
|
||||
import org.parabot.core.forum.AccountManager;
|
||||
@@ -10,13 +9,10 @@ import org.parabot.core.network.proxy.ProxySocket;
|
||||
import org.parabot.core.network.proxy.ProxyType;
|
||||
import org.parabot.core.ui.BotUI;
|
||||
import org.parabot.core.ui.ServerSelector;
|
||||
import org.parabot.core.ui.utils.UILog;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* Parabot v2.6
|
||||
@@ -46,8 +42,10 @@ public final class Landing {
|
||||
}
|
||||
|
||||
if (!Core.inDebugMode() && Core.hasValidation() && !Core.isValid()) {
|
||||
Core.downloadNewVersion();
|
||||
return;
|
||||
if (Core.newVersionAlert() == JOptionPane.YES_OPTION) {
|
||||
Core.downloadNewVersion();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Core.verbose(TranslationHelper.translate("VALIDATION_ACCOUNT_MANAGER"));
|
||||
|
||||
@@ -14,13 +14,11 @@ import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* The core of parabot
|
||||
@@ -36,7 +34,7 @@ public class Core {
|
||||
private static boolean loadLocal; //Loads both local and public scripts/servers
|
||||
|
||||
private static boolean validate = true;
|
||||
private static boolean secure = true;
|
||||
private static boolean secure = true;
|
||||
|
||||
private static Version currentVersion = Configuration.BOT_VERSION;
|
||||
|
||||
@@ -141,11 +139,11 @@ public class Core {
|
||||
File f = new File(Landing.class.getProtectionDomain().getCodeSource().getLocation().getFile());
|
||||
if (f.isFile()) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
File location = new File(Landing.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
File location = new File(Landing.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
||||
if (location.exists()) {
|
||||
FileInputStream fis = new FileInputStream(location);
|
||||
byte[] dataBytes = new byte[1024];
|
||||
FileInputStream fis = new FileInputStream(location);
|
||||
byte[] dataBytes = new byte[1024];
|
||||
|
||||
int nread;
|
||||
|
||||
@@ -185,7 +183,7 @@ public class Core {
|
||||
try {
|
||||
if (br != null) {
|
||||
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(br);
|
||||
boolean latest = (Boolean) object.get("result");
|
||||
boolean latest = (Boolean) object.get("result");
|
||||
if (!latest) {
|
||||
Directories.clearCache();
|
||||
}
|
||||
@@ -251,4 +249,11 @@ public class Core {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alerts the user that there is a new version
|
||||
*/
|
||||
public static int newVersionAlert() {
|
||||
return UILog.alert("Parabot Update", "There's a new version of Parabot! \nDo you wish to download it?\n\nThe current version could have some problems!", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,33 @@
|
||||
package org.parabot.core.ui.utils;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* Log messages to the log user interface which is attached to the bot user interface
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
* @author Everel
|
||||
*/
|
||||
public class UILog {
|
||||
|
||||
public static void log(final String title, final String message) {
|
||||
log(title, message, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
public static void log(final String title, final String message) {
|
||||
log(title, message, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
public static void log(final String title, final String message,
|
||||
int messageType) {
|
||||
JOptionPane.showMessageDialog(null, message, title,
|
||||
messageType);
|
||||
}
|
||||
public static void log(final String title, final String message,
|
||||
int messageType) {
|
||||
JOptionPane.showMessageDialog(null, message, title,
|
||||
messageType);
|
||||
}
|
||||
|
||||
public static int alert(final String title, final String message) {
|
||||
alert(title, message, JOptionPane.YES_NO_OPTION);
|
||||
}
|
||||
|
||||
public static int alert(final String title, final String message, int option) {
|
||||
alert(title, message, option, JOptionPane.DEFAULT_OPTION);
|
||||
}
|
||||
|
||||
public static int alert(final String title, final String message, int optionType, int messageType) {
|
||||
JOptionPane.showConfirmDialog(null, message, title, optionType, messageType);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user