mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 00:37:55 +00:00
Merge pull request #214 from Parabot/development
[MERGE] Development into Master
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@ env:
|
||||
- secure: UG+b1tEgc8xv9x4r//2OAIK1RrYv6n209KTTFMMwcnAa7DI8HaP8nljRa5/VhDhuKHdlVrYH/tI90v7UVBs0GDVNwK5V17Io0fMm3FUGZekSthTCqqno5wAGa9r6a6mMLtSaSmIFeIKi0+0d2ZwplRuhj/dtEYjjBBj+kK8g4nE=
|
||||
- secure: St/fecUDInFBCRriYqgp2F8PU9/SooorgxD9Mrs+b0EsC7AbtSsQXvdIv2Lp6xzdQ0VSXPcLIhULPOYrmBKnGQ/NjXTIZXxnroyQxxnI6xyEWIZwiHRY/bKRJDRbQTxD9NL32szKiDSwnw7pu6llF4D64UqQvziq4Gm6VohU75M=
|
||||
- secure: bD15GVZWowiknbfLavh8CxSh0GsnF5kT4kZ6ggCuUDGyj0mzqf7dNRnchQIKkCG0WRYyTrFN4pEiygeywWsipEeAVv9Xhx3cuUZmzeQaR5KCWabSwJ8gK6jZd1YhcWmM9vrdPHobZr65MP0y/8mu/Fovgky9dY7KDf4G3SebNrM=
|
||||
- PARABOT_VERSION=2.6.4
|
||||
- PARABOT_VERSION=2.6.6
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>org.parabot</groupId>
|
||||
<artifactId>client</artifactId>
|
||||
<version>2.6.4</version>
|
||||
<version>2.6.6</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -12,7 +12,7 @@ public class Configuration extends org.parabot.api.Configuration {
|
||||
public static final String GET_SCRIPTS = "http://bdn.parabot.org/api/get.php?action=scripts_scripts&server=";
|
||||
public static final String GET_SCRIPT = "http://bdn.parabot.org/api/get.php?action=scripts_script&id=";
|
||||
public static final String GET_SERVER_PROVIDERS = "http://bdn.parabot.org/api/get.php?action=server_providers";
|
||||
public static final String GET_SERVER_PROVIDER = "http://v3.bdn.parabot.org/api/bot/download/provider?nightly=%s";
|
||||
public static final String GET_SERVER_PROVIDER = "http://v3.bdn.parabot.org/api/bot/download/provider?nightly=%s&server=%s";
|
||||
public static final String GET_SERVER_PROVIDER_INFO = "http://bdn.parabot.org/api/get.php?action=server_information&name=";
|
||||
public static final String GET_SERVER_SETTINGS = "http://bdn.parabot.org/api/get.php?action=get_settings";
|
||||
public static final String GET_BOT_VERSION = "http://bdn.parabot.org/api/v2/bot/version";
|
||||
|
||||
@@ -164,7 +164,6 @@ public class Context {
|
||||
* Loads the game
|
||||
*/
|
||||
public void load() {
|
||||
BotUI.getInstance().getJMenuBar().remove(2);
|
||||
Core.verbose(TranslationHelper.translate("PARSING_SERVER_JAR"));
|
||||
serverProvider.init();
|
||||
serverProvider.parseJar();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -125,6 +125,14 @@ public class ClassRedirect {
|
||||
return c.getResourceAsStream(res);
|
||||
}
|
||||
|
||||
public static boolean desiredAssertionStatus(Class<?> c) {
|
||||
if (validStack()) {
|
||||
return c.desiredAssertionStatus();
|
||||
}
|
||||
|
||||
return !c.getName().contains("parabot") && c.desiredAssertionStatus();
|
||||
}
|
||||
|
||||
private static boolean validStack() {
|
||||
Exception e = new Exception();
|
||||
for (StackTraceElement elem : e.getStackTrace()) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.parabot.core.asm.redirect;
|
||||
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.Directories;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -33,7 +34,8 @@ public class SystemRedirect {
|
||||
value = System.getProperty(s);
|
||||
break;
|
||||
}
|
||||
System.out.printf("GetSystemProp %s = %s\n", s, value);
|
||||
|
||||
Core.verbose(String.format("GetSystemProp %s = %s", s, value));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -55,7 +57,8 @@ public class SystemRedirect {
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.out.printf("GetSystemProp %s = %s\n", s, value);
|
||||
|
||||
Core.verbose(String.format("GetSystemProp %s = %s", s, value));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -64,12 +67,12 @@ public class SystemRedirect {
|
||||
}
|
||||
|
||||
public static String setProperty(String s1, String s2) {
|
||||
System.out.printf("SetSystemProp %s = %s\n", s1, s2);
|
||||
Core.verbose(String.format("SetSystemProp %s = %s", s1, s2));
|
||||
return System.setProperty(s1, s2);
|
||||
}
|
||||
|
||||
public static String getenv(String string) {
|
||||
System.out.printf("getEnv %s = %s\n", string, System.getenv(string));
|
||||
Core.verbose(String.format("getEnv %s = %s", string, System.getenv(string)));
|
||||
return System.getenv(string);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.parabot.core.asm.redirect;
|
||||
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.asm.RedirectClassAdapter;
|
||||
|
||||
public class ThreadRedirect {
|
||||
@@ -58,4 +59,8 @@ public class ThreadRedirect {
|
||||
Thread.sleep(time);
|
||||
}
|
||||
|
||||
|
||||
public static void setUncaughtExceptionHandler(Thread t, Thread.UncaughtExceptionHandler handler){
|
||||
t.setUncaughtExceptionHandler(handler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,13 @@ public class ToolkitRedirect {
|
||||
public static Dimension getScreenSize(Toolkit t){
|
||||
return new Dimension(0,0);
|
||||
}
|
||||
|
||||
public static Image createImage(Toolkit t,byte[] b){
|
||||
return t.createImage(b);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Image createImage(Toolkit t, String s){
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Image getImage(Toolkit t,URL u){
|
||||
|
||||
@@ -34,9 +34,12 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
||||
private static BotUI instance;
|
||||
private static JDialog dialog;
|
||||
|
||||
private JMenuItem run, pause, stop;
|
||||
private JMenuBar menuBar;
|
||||
private JMenu features, scripts, file;
|
||||
private JMenuItem run, pause, stop, cacheClear, notifications;
|
||||
private boolean runScript, pauseScript;
|
||||
|
||||
|
||||
public BotUI(String username, String password) {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException("BotUI already created");
|
||||
@@ -74,11 +77,11 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
||||
|
||||
|
||||
private void createMenu() {
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menuBar = new JMenuBar();
|
||||
|
||||
JMenu file = new JMenu("File");
|
||||
JMenu scripts = new JMenu("Script");
|
||||
JMenu features = new JMenu("Features");
|
||||
file = new JMenu("File");
|
||||
scripts = new JMenu("Script");
|
||||
features = new JMenu("Features");
|
||||
|
||||
JMenuItem screenshot = new JMenuItem("Create screenshot");
|
||||
JMenuItem proxy = new JMenuItem("Network");
|
||||
@@ -104,10 +107,10 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
||||
stop.setEnabled(false);
|
||||
stop.setIcon(new ImageIcon(Images.getResource("/storage/images/stop.png")));
|
||||
|
||||
JMenuItem cacheClear = new JMenuItem("Clear cache");
|
||||
cacheClear = new JMenuItem("Clear cache");
|
||||
cacheClear.setIcon(new ImageIcon(Images.getResource("/storage/images/trash.png")));
|
||||
|
||||
JMenuItem notifications = new JMenuItem("Notifications");
|
||||
notifications = new JMenuItem("Notifications");
|
||||
notifications.setIcon(new ImageIcon(Images.getResource("/storage/images/bell.png")));
|
||||
|
||||
screenshot.addActionListener(this);
|
||||
@@ -157,7 +160,7 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
||||
case "Create screenshot":
|
||||
try {
|
||||
Robot robot = new Robot();
|
||||
Rectangle parabotScreen = new Rectangle((int) getLocation().getX(), (int) getLocation().getY(), getWidth(), getHeight());
|
||||
Rectangle parabotScreen = new Rectangle((int) getLocation().getX(), (int) getLocation().getY() + (menuBar.getHeight() + features.getHeight()), getWidth(), getHeight());
|
||||
BufferedImage image = robot.createScreenCapture(parabotScreen);
|
||||
String randString = StringUtils.randomString(10);
|
||||
boolean search = true;
|
||||
@@ -341,4 +344,23 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
||||
public void windowOpened(WindowEvent arg0) {
|
||||
}
|
||||
|
||||
}
|
||||
public JMenu getFeatures() {
|
||||
return features;
|
||||
}
|
||||
|
||||
public JMenu getScripts() {
|
||||
return scripts;
|
||||
}
|
||||
|
||||
public JMenu getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public JMenuItem getCacheClear() {
|
||||
return cacheClear;
|
||||
}
|
||||
|
||||
public JMenuItem getNotifications() {
|
||||
return notifications;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,6 @@ public class Logger extends JPanel {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @param message
|
||||
*/
|
||||
public static void addMessage(String 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) {
|
||||
return alert(title, message, JOptionPane.YES_NO_OPTION);
|
||||
}
|
||||
|
||||
public static int alert(final String title, final String message, int option) {
|
||||
return alert(title, message, option, JOptionPane.DEFAULT_OPTION);
|
||||
}
|
||||
|
||||
public static int alert(final String title, final String message, int optionType, int messageType) {
|
||||
return JOptionPane.showConfirmDialog(null, message, title, optionType, messageType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class RandomHandler {
|
||||
|
||||
public void init() {
|
||||
RandomParser.enable();
|
||||
checkAndRun(RandomType.ON_SERVER_START);
|
||||
runAll(RandomType.ON_SERVER_START);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,6 +100,40 @@ public class RandomHandler {
|
||||
this.activeRandoms.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a specific random
|
||||
*
|
||||
* @param r
|
||||
* @return True if the random is executed, false if not
|
||||
*/
|
||||
public boolean executeRandom(Random r){
|
||||
if (r.activate()) {
|
||||
Logger.addMessage("Running random '" + r.getName() + "'", true);
|
||||
try {
|
||||
r.execute();
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
Logger.addMessage("Random failed: '" + r.getName() + "'", false);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs all randoms of a certain type
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public void runAll(RandomType type){
|
||||
for (Random r : this.activeRandoms) {
|
||||
if (r.getRandomType().getId() == type.getId()) {
|
||||
executeRandom(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if random occurs and runs it
|
||||
*
|
||||
@@ -107,15 +141,8 @@ public class RandomHandler {
|
||||
*/
|
||||
public boolean checkAndRun(RandomType type) {
|
||||
for (Random r : this.activeRandoms) {
|
||||
if (r.getRandomType().getId() == type.getId() && r.activate()) {
|
||||
Logger.addMessage("Running random '" + r.getName() + "'", true);
|
||||
try {
|
||||
r.execute();
|
||||
}catch (Exception e){
|
||||
Logger.addMessage("Random failed: '" + r.getName() + "'", false);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
if (r.getRandomType().getId() == type.getId()) {
|
||||
return executeRandom(r);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class Script implements Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
context.getRandomHandler().checkAndRun(RandomType.ON_SCRIPT_START);
|
||||
context.getRandomHandler().runAll(RandomType.ON_SCRIPT_START);
|
||||
|
||||
Core.verbose("Detecting script framework...");
|
||||
context.setRunningScript(this);
|
||||
@@ -120,7 +120,7 @@ public class Script implements Runnable {
|
||||
Core.verbose("Script stopped/finished, unloading and stopping...");
|
||||
onFinish();
|
||||
|
||||
context.getRandomHandler().checkAndRun(RandomType.ON_SCRIPT_FINISH);
|
||||
context.getRandomHandler().runAll(RandomType.ON_SCRIPT_FINISH);
|
||||
|
||||
Logger.addMessage("Script stopped.", false);
|
||||
context.getServerProvider().unloadScript(this);
|
||||
|
||||
@@ -54,7 +54,7 @@ public class PublicServerExecuter extends ServerExecuter {
|
||||
|
||||
final File destination = new File(Directories.getCachePath(),
|
||||
serverProviderInfo.getCRC32() + ".jar");
|
||||
final String jarUrl = String.format(Configuration.GET_SERVER_PROVIDER, Configuration.BOT_VERSION.isNightly());
|
||||
final String jarUrl = String.format(Configuration.GET_SERVER_PROVIDER, Configuration.BOT_VERSION.isNightly(), serverName);
|
||||
|
||||
Core.verbose("Downloading: " + jarUrl + " ...");
|
||||
|
||||
|
||||
@@ -1,39 +1,36 @@
|
||||
package org.parabot.environment.servers.executers;
|
||||
|
||||
import org.parabot.core.Context;
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.parsers.randoms.RandomParser;
|
||||
import org.parabot.core.ui.BotUI;
|
||||
import org.parabot.core.ui.components.PaintComponent;
|
||||
import org.parabot.environment.servers.ServerProvider;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* Executes a server provider
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
* @author Everel
|
||||
*/
|
||||
public abstract class ServerExecuter {
|
||||
|
||||
public abstract void run();
|
||||
public abstract void run();
|
||||
|
||||
public void finalize(final ServerProvider provider, final String serverName) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Context context = Context.getInstance(provider);
|
||||
context.load();
|
||||
PaintComponent.getInstance().startPainting(context);
|
||||
public void finalize(final ServerProvider provider, final String serverName) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
BotUI.getInstance().getCacheClear().setEnabled(false);
|
||||
|
||||
Context.getInstance().getRandomHandler().init();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
Context context = Context.getInstance(provider);
|
||||
context.load();
|
||||
PaintComponent.getInstance().startPainting(context);
|
||||
|
||||
Context.getInstance().getRandomHandler().init();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user