mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-10-01 02:17:22 +00:00
Merge pull request #42 from Parabot/development
[MERGE] Development into master
This commit is contained in:
@@ -120,3 +120,5 @@ buildNumber.properties
|
|||||||
parabotv2
|
parabotv2
|
||||||
releases
|
releases
|
||||||
._*
|
._*
|
||||||
|
|
||||||
|
Test.java
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
<version>2.4.1</version>
|
<version>2.4.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<descriptorRefs>
|
<descriptorRefs>
|
||||||
<descriptorRef>fat</descriptorRef>
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
</descriptorRefs>
|
</descriptorRefs>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.parabot.core.network.proxy.ProxyType;
|
|||||||
import org.parabot.core.ui.BotUI;
|
import org.parabot.core.ui.BotUI;
|
||||||
import org.parabot.core.ui.ServerSelector;
|
import org.parabot.core.ui.ServerSelector;
|
||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
import org.parabot.environment.api.utils.JavaUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -112,14 +113,7 @@ public final class Landing {
|
|||||||
Directories.setServerCompiledDirectory(new File(args[++i]));
|
Directories.setServerCompiledDirectory(new File(args[++i]));
|
||||||
break;
|
break;
|
||||||
case "-clearcache":
|
case "-clearcache":
|
||||||
File[] cache = Directories.getCachePath().listFiles();
|
Directories.clearCache();
|
||||||
if (cache != null) {
|
|
||||||
for (File f : cache) {
|
|
||||||
if (f.exists() && f.canWrite()) {
|
|
||||||
f.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "-mac":
|
case "-mac":
|
||||||
byte[] mac = new byte[6];
|
byte[] mac = new byte[6];
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class Configuration {
|
|||||||
public static final String GET_SERVER_PROVIDERS = "http://bdn.parabot.org/api/get.php?action=server_providers";
|
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://bdn.parabot.org/api/get.php?action=server_provider&name=";
|
public static final String GET_SERVER_PROVIDER = "http://bdn.parabot.org/api/get.php?action=server_provider&name=";
|
||||||
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_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";
|
public static final String GET_BOT_VERSION = "http://bdn.parabot.org/api/v2/bot/version";
|
||||||
public static final String API_DOWNLOAD_BOT = "http://bdn.parabot.org/api/v2/bot/download/client/";
|
public static final String API_DOWNLOAD_BOT = "http://bdn.parabot.org/api/v2/bot/download/client/";
|
||||||
public static final String DOWNLOAD_BOT = "http://bdn.parabot.org/versions/";
|
public static final String DOWNLOAD_BOT = "http://bdn.parabot.org/versions/";
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ import org.parabot.environment.scripts.uliratha.UlirathaClient;
|
|||||||
import org.parabot.environment.servers.ServerProvider;
|
import org.parabot.environment.servers.ServerProvider;
|
||||||
|
|
||||||
import java.applet.Applet;
|
import java.applet.Applet;
|
||||||
import java.awt.Dimension;
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.PrintStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
@@ -27,7 +28,7 @@ import java.util.TimerTask;
|
|||||||
/**
|
/**
|
||||||
* Game context
|
* Game context
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel, JKetelaar, Matt
|
||||||
*/
|
*/
|
||||||
public class Context {
|
public class Context {
|
||||||
public static final HashMap<ThreadGroup, Context> threadGroups = new HashMap<ThreadGroup, Context>();
|
public static final HashMap<ThreadGroup, Context> threadGroups = new HashMap<ThreadGroup, Context>();
|
||||||
@@ -36,7 +37,6 @@ public class Context {
|
|||||||
private static Context instance;
|
private static Context instance;
|
||||||
private static String username;
|
private static String username;
|
||||||
|
|
||||||
public boolean added;
|
|
||||||
private ASMClassLoader classLoader;
|
private ASMClassLoader classLoader;
|
||||||
private ClassPath classPath;
|
private ClassPath classPath;
|
||||||
private ServerProvider serverProvider;
|
private ServerProvider serverProvider;
|
||||||
@@ -52,6 +52,9 @@ public class Context {
|
|||||||
private UlirathaClient ulirathaClient;
|
private UlirathaClient ulirathaClient;
|
||||||
private JSONParser jsonParser;
|
private JSONParser jsonParser;
|
||||||
|
|
||||||
|
private PrintStream defaultOut;
|
||||||
|
private PrintStream defaultErr = System.err;
|
||||||
|
|
||||||
private Context(final ServerProvider serverProvider) {
|
private Context(final ServerProvider serverProvider) {
|
||||||
threadGroups.put(Thread.currentThread().getThreadGroup(), this);
|
threadGroups.put(Thread.currentThread().getThreadGroup(), this);
|
||||||
|
|
||||||
@@ -63,7 +66,9 @@ public class Context {
|
|||||||
this.randomHandler = new RandomHandler();
|
this.randomHandler = new RandomHandler();
|
||||||
|
|
||||||
this.jsonParser = new JSONParser();
|
this.jsonParser = new JSONParser();
|
||||||
|
|
||||||
|
this.defaultOut = System.out;
|
||||||
|
this.defaultErr = System.err;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Context getInstance(ServerProvider serverProvider) {
|
public static Context getInstance(ServerProvider serverProvider) {
|
||||||
@@ -174,7 +179,7 @@ public class Context {
|
|||||||
Applet applet = serverProvider.fetchApplet();
|
Applet applet = serverProvider.fetchApplet();
|
||||||
// if applet is null the server provider will call setApplet itself
|
// if applet is null the server provider will call setApplet itself
|
||||||
if(applet != null) {
|
if(applet != null) {
|
||||||
setApplet(applet);
|
setApplet(applet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +193,7 @@ public class Context {
|
|||||||
if (getClient() == null) {
|
if (getClient() == null) {
|
||||||
setClientInstance(gameApplet);
|
setClientInstance(gameApplet);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core.verbose("Applet fetched.");
|
Core.verbose("Applet fetched.");
|
||||||
|
|
||||||
final GamePanel panel = GamePanel.getInstance();
|
final GamePanel panel = GamePanel.getInstance();
|
||||||
@@ -206,6 +211,7 @@ public class Context {
|
|||||||
|
|
||||||
gameApplet.init();
|
gameApplet.init();
|
||||||
gameApplet.start();
|
gameApplet.start();
|
||||||
|
|
||||||
java.util.Timer t = new java.util.Timer();
|
java.util.Timer t = new java.util.Timer();
|
||||||
t.schedule(new TimerTask() {
|
t.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
@@ -222,6 +228,8 @@ public class Context {
|
|||||||
Core.verbose("Done.");
|
Core.verbose("Done.");
|
||||||
|
|
||||||
BotDialog.getInstance().validate();
|
BotDialog.getInstance().validate();
|
||||||
|
System.setOut(this.defaultOut);
|
||||||
|
System.setErr(this.defaultErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package org.parabot.core;
|
package org.parabot.core;
|
||||||
|
|
||||||
|
import com.bugsnag.BeforeNotify;
|
||||||
import com.bugsnag.Client;
|
import com.bugsnag.Client;
|
||||||
|
import com.bugsnag.Error;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
import org.parabot.Landing;
|
import org.parabot.Landing;
|
||||||
@@ -301,11 +303,21 @@ public class Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setBugsnagVersion(){
|
public static void setBugsnagVersion(){
|
||||||
Core.bugsnagInstance.setReleaseStage(currentVersion.compareTo(latestVersion) >= 0 ? "development" : "production");
|
Core.bugsnagInstance.setReleaseStage(currentVersion != latestVersion ? "development" : "production");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBugsnagUser(String id, String email, String username){
|
public static void setBugsnagUser(String id, String email, String username){
|
||||||
Core.bugsnagInstance.setUser(id, email, username);
|
// TODO Check order of parameters
|
||||||
|
Core.bugsnagInstance.setUser(username, email, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setBugsnagServer(String server){
|
||||||
|
Core.setBugsnagInformation("Server", "Server", server);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setBugsnagInformation(String tab, String key, String value){
|
||||||
|
// TODO Should be checked if correct
|
||||||
|
Core.bugsnagInstance.addToTab(tab, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(int i) {
|
public static void debug(int i) {
|
||||||
|
|||||||
@@ -7,16 +7,14 @@ import org.parabot.environment.api.utils.StringUtils;
|
|||||||
import org.parabot.environment.api.utils.WebUtil;
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds parabot's used directories
|
* Holds and manages Parabot's used directories
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
|
* @author JKetelaar
|
||||||
* @author Matt
|
* @author Matt
|
||||||
*/
|
*/
|
||||||
public class Directories {
|
public class Directories {
|
||||||
@@ -45,34 +43,48 @@ public class Directories {
|
|||||||
Core.verbose("Directories cached.");
|
Core.verbose("Directories cached.");
|
||||||
|
|
||||||
clearCache(259200);
|
clearCache(259200);
|
||||||
setHomeDirectory();
|
if (Core.isSecure()) {
|
||||||
|
setHomeDirectory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setHomeDirectory(){
|
private static void setHomeDirectory(){
|
||||||
File cache;
|
File cache;
|
||||||
tempDir = StringUtils.randomString(12);
|
tempDir = StringUtils.randomString(12);
|
||||||
try {
|
try {
|
||||||
if ((cache = new File(Directories.getCachePath(), "cache.json")).exists()){
|
if ((cache = new File(Directories.getSettingsPath(), "cache.json")).exists()){
|
||||||
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(new FileReader(cache));
|
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(new FileReader(cache));
|
||||||
String temp;
|
String temp;
|
||||||
if ((temp = (String) object.get("homedir")) != null){
|
if ((temp = (String) object.get("homedir")) != null){
|
||||||
cached.put("Home", new File(cached.get("Root"), "/" + temp + "/"));
|
cached.put("Home", new File(cached.get("Root"), "/" + temp + "/"));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
cache.createNewFile();
|
cached.put("Home", createCacheDirectory(cache));
|
||||||
JSONObject object = new JSONObject();
|
|
||||||
object.put("homedir", tempDir);
|
|
||||||
FileWriter file = new FileWriter(cache);
|
|
||||||
file.write(object.toJSONString());
|
|
||||||
file.flush();
|
|
||||||
file.close();
|
|
||||||
cached.put("Home", new File(cached.get("Root"), "/" + tempDir + "/"));
|
|
||||||
}
|
}
|
||||||
} catch (IOException | ParseException ignored) {
|
} catch (IOException | ParseException ignored) {
|
||||||
cached.put("Home", new File(cached.get("Root"), "/" + tempDir + "/"));
|
cached.put("Home", new File(cached.get("Root"), "/" + tempDir + "/"));
|
||||||
}
|
}
|
||||||
System.out.println("Setting server cache directory to: " + cached.get("Home"));
|
if (!cached.get("Home").exists()) {
|
||||||
cached.get("Home").mkdirs();
|
cached.get("Home").mkdirs();
|
||||||
|
}
|
||||||
|
System.out.println("Set temporary cache directory to: " + cached.get("Home"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File createCacheDirectory(File cacheFile) throws IOException {
|
||||||
|
cacheFile.createNewFile();
|
||||||
|
JSONObject object = new JSONObject();
|
||||||
|
object.put("homedir", tempDir);
|
||||||
|
FileWriter file = new FileWriter(cacheFile);
|
||||||
|
file.write(object.toJSONString());
|
||||||
|
file.flush();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
File cacheDir = new File(cached.get("Root"), "/" + tempDir + "/");
|
||||||
|
if (!cacheDir.exists()) {
|
||||||
|
cacheDir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
return cacheDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -219,8 +231,9 @@ public class Directories {
|
|||||||
* Clears the cache based on the latest modification
|
* Clears the cache based on the latest modification
|
||||||
*
|
*
|
||||||
* @param remove A long that represents the amount of seconds that a file may have since the latest modification
|
* @param remove A long that represents the amount of seconds that a file may have since the latest modification
|
||||||
|
* @param force Defines if the cache folder, within user.home, should also be removed
|
||||||
*/
|
*/
|
||||||
private static void clearCache(int remove) {
|
public static void clearCache(int remove, boolean force){
|
||||||
File[] cache = getCachePath().listFiles();
|
File[] cache = getCachePath().listFiles();
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
for (File f : cache) {
|
for (File f : cache) {
|
||||||
@@ -230,15 +243,84 @@ public class Directories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearCache() {
|
if (force){
|
||||||
File[] cache = getCachePath().listFiles();
|
File cacheFile;
|
||||||
if (cache != null) {
|
|
||||||
for (File f : cache) {
|
if ((cacheFile = new File(Directories.getSettingsPath(), "cache.json")).exists()){
|
||||||
Core.verbose("Clearing " + f.getName() + " from cache...");
|
try {
|
||||||
f.delete();
|
JSONObject jsonObject = (JSONObject) WebUtil.getJsonParser().parse(new FileReader(cacheFile));
|
||||||
|
if (jsonObject != null){
|
||||||
|
Object dirObject;
|
||||||
|
if ((dirObject = jsonObject.get("homedir")) != null) {
|
||||||
|
String dir = (String) dirObject;
|
||||||
|
if (dir.length() > 0) {
|
||||||
|
File cacheDir = new File(cached.get("Root"), "/" + dir + "/");
|
||||||
|
removeDirectory(cacheDir);
|
||||||
|
createCacheDirectory(cacheFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException | ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void clearCache(int remove) {
|
||||||
|
clearCache(remove, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearCache() {
|
||||||
|
clearCache(0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param file Directory to be removed
|
||||||
|
*/
|
||||||
|
private static void removeDirectory(File file) {
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
if (file.list().length == 0) {
|
||||||
|
file.delete();
|
||||||
|
Core.verbose("Directory is deleted : "
|
||||||
|
+ file.getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
String files[] = file.list();
|
||||||
|
for (String temp : files) {
|
||||||
|
File fileDelete = new File(file, temp);
|
||||||
|
removeDirectory(fileDelete);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.list().length == 0) {
|
||||||
|
file.delete();
|
||||||
|
Core.verbose("Directory is deleted : "
|
||||||
|
+ file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
file.delete();
|
||||||
|
Core.verbose("File is deleted : " + file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of files with from a given directory and a given extension
|
||||||
|
*
|
||||||
|
* @param directory The directory where should be searched
|
||||||
|
* @param extension The extension to be searched for, including the dot (like .json)
|
||||||
|
* @return An array of of files that match the request
|
||||||
|
*/
|
||||||
|
public static File[] listFilesWithExtension(File directory, final String extension){
|
||||||
|
return directory.listFiles(new FilenameFilter() {
|
||||||
|
public boolean accept(File dir, String filename) {
|
||||||
|
return filename.endsWith(extension);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File[] listJSONFiles(File directory) {
|
||||||
|
return listFilesWithExtension(directory, ".json");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
|||||||
|
|
||||||
private String className;
|
private String className;
|
||||||
|
|
||||||
private static PrintStream str_out, class_out;
|
private static PrintStream str_out, class_out, dec_out;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
redirects.put("java/awt/Toolkit", ToolkitRedirect.class);
|
redirects.put("java/awt/Toolkit", ToolkitRedirect.class);
|
||||||
@@ -40,6 +40,7 @@ public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
|||||||
if (str_out == null && Core.shouldDump())
|
if (str_out == null && Core.shouldDump())
|
||||||
try {
|
try {
|
||||||
str_out = new PrintStream(new FileOutputStream(new File(Directories.getWorkspace(),"strings.txt")));
|
str_out = new PrintStream(new FileOutputStream(new File(Directories.getWorkspace(),"strings.txt")));
|
||||||
|
dec_out = new PrintStream(new FileOutputStream(new File(Directories.getWorkspace(),"decrypted_strings.txt")));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -89,8 +90,13 @@ public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitLdcInsn(Object o) {
|
public void visitLdcInsn(Object o) {
|
||||||
if (o instanceof String && str_out != null)
|
if (o instanceof String && str_out != null) {
|
||||||
str_out.println(className + " " + o);
|
str_out.println(className + " " + o);
|
||||||
|
if (!className.toLowerCase().contains("parabot")) {
|
||||||
|
dec_out.println(o + ":");
|
||||||
|
dec_out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
super.visitLdcInsn(o);
|
super.visitLdcInsn(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ public class AddGetterAdapter implements Opcodes, Injectable {
|
|||||||
final ClassNode fieldLocation, final FieldNode fieldNode,
|
final ClassNode fieldLocation, final FieldNode fieldNode,
|
||||||
final String methodName, final String returnDesc,
|
final String methodName, final String returnDesc,
|
||||||
final boolean staticMethod, final long multiplier) {
|
final boolean staticMethod, final long multiplier) {
|
||||||
System.out.println(fieldNode.name);
|
|
||||||
this.into = into;
|
this.into = into;
|
||||||
this.fieldLocation = fieldLocation;
|
this.fieldLocation = fieldLocation;
|
||||||
this.fieldNode = fieldNode;
|
this.fieldNode = fieldNode;
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package org.parabot.core.asm.redirect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JKetelaar
|
||||||
|
*/
|
||||||
|
public class URLRedirect{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,17 +2,21 @@ package org.parabot.core.desc;
|
|||||||
|
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
import org.parabot.core.Configuration;
|
||||||
import org.parabot.core.Core;
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
import org.parabot.environment.api.utils.WebUtil;
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the information for the selected server provider
|
* Gets the information for the selected server provider
|
||||||
@@ -29,40 +33,63 @@ public class ServerProviderInfo {
|
|||||||
this.properties = new Properties();
|
this.properties = new Properties();
|
||||||
this.settings = new HashMap<>();
|
this.settings = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
String line;
|
|
||||||
Core.verbose("Reading info: " + providerInfo);
|
Core.verbose("Reading info: " + providerInfo);
|
||||||
BufferedReader br = WebUtil.getReader(new URL(providerInfo.toString()), username, password);
|
BufferedReader br = WebUtil.getReader(new URL(providerInfo.toString()), username, password);
|
||||||
|
|
||||||
//TODO Make this one line (web sided)
|
JSONObject jsonObject = (JSONObject) WebUtil.getJsonParser().parse(br);
|
||||||
JSONParser parser = new JSONParser();
|
for (Object o : jsonObject.entrySet()) {
|
||||||
if ((line = br.readLine()) != null) {
|
Map.Entry<?, ?> pairs = (Map.Entry<?, ?>) o;
|
||||||
JSONObject jsonObject = (JSONObject) parser.parse(line);
|
if (String.valueOf(pairs.getKey()).equalsIgnoreCase("settings")){
|
||||||
for (Object o : jsonObject.entrySet()) {
|
JSONObject object = (JSONObject) pairs.getValue();
|
||||||
Map.Entry<?, ?> pairs = (Map.Entry<?, ?>) o;
|
parseSettings(object);
|
||||||
if (String.valueOf(pairs.getKey()).equalsIgnoreCase("settings")){
|
}else {
|
||||||
JSONObject object = (JSONObject) pairs.getValue();
|
properties.put(String.valueOf(pairs.getKey()), String.valueOf(pairs.getValue()));
|
||||||
for (Object settingObject : object.entrySet()){
|
}
|
||||||
Map.Entry<?, ?> settingValue = (Map.Entry<?, ?>) settingObject;
|
}
|
||||||
String key = (String) settingValue.getKey();
|
if (br != null) {
|
||||||
long value = (Long) settingValue.getValue();
|
br.close();
|
||||||
settings.put(key, (int) value);
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
}else {
|
|
||||||
properties.put(String.valueOf(pairs.getKey()), String.valueOf(pairs.getValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
UILog.log(
|
|
||||||
"Error",
|
|
||||||
"Failed to load server provider, error: [No information about the provider found.]",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
br.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServerProviderInfo(String clientJar, String hooks, String name, String clientClass, int bankTabs){
|
||||||
|
this.properties = new Properties();
|
||||||
|
this.settings = new HashMap<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader br = WebUtil.getReader(new URL(Configuration.GET_SERVER_SETTINGS));
|
||||||
|
JSONObject settings = (JSONObject) WebUtil.getJsonParser().parse(br);
|
||||||
|
parseSettings(settings);
|
||||||
|
} catch (ParseException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.properties.setProperty("client_jar", clientJar);
|
||||||
|
this.properties.setProperty("hooks", hooks);
|
||||||
|
this.properties.setProperty("name", name);
|
||||||
|
this.properties.setProperty("client_class", clientClass);
|
||||||
|
this.properties.setProperty("provider_crc32", String.valueOf(getCRC32(name, "provider")));
|
||||||
|
this.properties.setProperty("client_crc32", String.valueOf(getCRC32(name, "client")));
|
||||||
|
this.properties.setProperty("bank_tabs", String.valueOf(bankTabs));
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getCRC32(String name, String type){
|
||||||
|
CRC32 crc = new CRC32();
|
||||||
|
name += "-" + type;
|
||||||
|
crc.update(name.getBytes());
|
||||||
|
return crc.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseSettings(JSONObject object){
|
||||||
|
for (Object settingObject : object.entrySet()){
|
||||||
|
Map.Entry<?, ?> settingValue = (Map.Entry<?, ?>) settingObject;
|
||||||
|
String key = (String) settingValue.getKey();
|
||||||
|
long value = (Long) settingValue.getValue();
|
||||||
|
settings.put(key, (int) value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public URL getClient() {
|
public URL getClient() {
|
||||||
try {
|
try {
|
||||||
@@ -100,7 +127,7 @@ public class ServerProviderInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long getCRC32() {
|
public long getCRC32() {
|
||||||
return Long.parseLong(properties.getProperty("provider_crc32"));
|
return Long.parseLong(properties.getProperty("provider_crc32"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getClientCRC32() {
|
public long getClientCRC32() {
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ public abstract class Library {
|
|||||||
* @return url
|
* @return url
|
||||||
*/
|
*/
|
||||||
public abstract URL getDownloadLink();
|
public abstract URL getDownloadLink();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines if the system requires a jar
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public abstract boolean requiresJar();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.parabot.core.Core;
|
|||||||
import org.parabot.core.Directories;
|
import org.parabot.core.Directories;
|
||||||
import org.parabot.core.build.BuildPath;
|
import org.parabot.core.build.BuildPath;
|
||||||
import org.parabot.core.lib.Library;
|
import org.parabot.core.lib.Library;
|
||||||
|
import org.parabot.environment.api.utils.JavaUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -59,6 +60,11 @@ public class JavaFX extends Library {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresJar() {
|
||||||
|
return JavaUtil.JAVA_VERSION <= 1.7;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLibraryName() {
|
public String getLibraryName() {
|
||||||
return "JavaFX";
|
return "JavaFX";
|
||||||
@@ -67,5 +73,4 @@ public class JavaFX extends Library {
|
|||||||
public static boolean isValid() {
|
public static boolean isValid() {
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ public class Naga extends Library {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresJar() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLibraryName() {
|
public String getLibraryName() {
|
||||||
return "Naga";
|
return "Naga";
|
||||||
|
|||||||
@@ -1,19 +1,41 @@
|
|||||||
package org.parabot.core.parsers.servers;
|
package org.parabot.core.parsers.servers;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FilenameFilter;
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
import org.parabot.core.Configuration;
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.Directories;
|
import org.parabot.core.Directories;
|
||||||
|
import org.parabot.core.build.BuildPath;
|
||||||
import org.parabot.core.classpath.ClassPath;
|
import org.parabot.core.classpath.ClassPath;
|
||||||
import org.parabot.core.desc.ServerDescription;
|
import org.parabot.core.desc.ServerDescription;
|
||||||
|
import org.parabot.core.desc.ServerProviderInfo;
|
||||||
|
import org.parabot.core.ui.components.VerboseLoader;
|
||||||
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
import org.parabot.environment.servers.ServerManifest;
|
import org.parabot.environment.servers.ServerManifest;
|
||||||
|
import org.parabot.environment.servers.ServerProvider;
|
||||||
|
import org.parabot.environment.servers.executers.LocalPublicServerExecuter;
|
||||||
import org.parabot.environment.servers.executers.LocalServerExecuter;
|
import org.parabot.environment.servers.executers.LocalServerExecuter;
|
||||||
|
import org.parabot.environment.servers.executers.PublicServerExecuter;
|
||||||
import org.parabot.environment.servers.loader.ServerLoader;
|
import org.parabot.environment.servers.loader.ServerLoader;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses local server providers located in the servers directory
|
* Parses local server providers located in the servers directory
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel, JKetelaar
|
||||||
*/
|
*/
|
||||||
public class LocalServers extends ServerParser {
|
public class LocalServers extends ServerParser {
|
||||||
|
|
||||||
@@ -24,7 +46,7 @@ public class LocalServers extends ServerParser {
|
|||||||
basePath.parseJarFiles(false);
|
basePath.parseJarFiles(false);
|
||||||
basePath.addClasses(Directories.getServerPath());
|
basePath.addClasses(Directories.getServerPath());
|
||||||
|
|
||||||
final ArrayList<ClassPath> classPaths = new ArrayList<ClassPath>();
|
final ArrayList<ClassPath> classPaths = new ArrayList<>();
|
||||||
classPaths.add(basePath);
|
classPaths.add(basePath);
|
||||||
for (final ClassPath classPath : basePath.getJarFiles()) {
|
for (final ClassPath classPath : basePath.getJarFiles()) {
|
||||||
classPaths.add(classPath);
|
classPaths.add(classPath);
|
||||||
@@ -64,6 +86,34 @@ public class LocalServers extends ServerParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (File file : Directories.listJSONFiles(Directories.getServerPath())){
|
||||||
|
try {
|
||||||
|
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(new FileReader(file));
|
||||||
|
String name = (String) object.get("name");
|
||||||
|
String author = (String) object.get("author");
|
||||||
|
double version = (Double) object.get("version");
|
||||||
|
String clientClass = (String) object.get("client-class");
|
||||||
|
Object bank;
|
||||||
|
int bankTabs = 0;
|
||||||
|
if ((bank = object.get("bank")) != null){
|
||||||
|
bankTabs = (int) bank;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject locations = (JSONObject) object.get("locations");
|
||||||
|
String server = (String) locations.get("server");
|
||||||
|
String provider = (String) locations.get("provider");
|
||||||
|
String hooks = (String) locations.get("hooks");
|
||||||
|
|
||||||
|
ServerProviderInfo serverProviderInfo = new ServerProviderInfo(server, hooks, name, clientClass, bankTabs);
|
||||||
|
|
||||||
|
System.out.println(server);
|
||||||
|
ServerDescription desc = new ServerDescription(name,
|
||||||
|
author, version);
|
||||||
|
SERVER_CACHE.put(desc, new LocalPublicServerExecuter(name, serverProviderInfo, server, provider));
|
||||||
|
} catch (IOException | ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class Environment {
|
|||||||
libs.add(new Naga());
|
libs.add(new Naga());
|
||||||
|
|
||||||
for(Library lib : libs) {
|
for(Library lib : libs) {
|
||||||
if(!lib.hasJar()) {
|
if(!lib.hasJar() && lib.requiresJar()) {
|
||||||
Core.verbose("Downloading " + lib.getLibraryName() + "...");
|
Core.verbose("Downloading " + lib.getLibraryName() + "...");
|
||||||
VerboseLoader.setState("Downloading " + lib.getLibraryName() + "...");
|
VerboseLoader.setState("Downloading " + lib.getLibraryName() + "...");
|
||||||
WebUtil.downloadFile(lib.getDownloadLink(), lib.getJarFile(), VerboseLoader.get());
|
WebUtil.downloadFile(lib.getDownloadLink(), lib.getJarFile(), VerboseLoader.get());
|
||||||
@@ -43,8 +43,7 @@ public class Environment {
|
|||||||
lib.init();
|
lib.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Core.verbose("Loading server: " + desc.toString() + "...");
|
||||||
Core.verbose("Loading server: " + desc.toString());
|
|
||||||
|
|
||||||
ServerParser.SERVER_CACHE.get(desc).run();
|
ServerParser.SERVER_CACHE.get(desc).run();
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package org.parabot.environment.api.utils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.channels.FileChannel;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
@@ -65,4 +67,25 @@ public class FileUtil {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void copyFile(File sourceFile, File destFile)
|
||||||
|
throws IOException {
|
||||||
|
if (!sourceFile.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!destFile.exists()) {
|
||||||
|
destFile.createNewFile();
|
||||||
|
}
|
||||||
|
FileChannel source = null;
|
||||||
|
FileChannel destination = null;
|
||||||
|
source = new FileInputStream(sourceFile).getChannel();
|
||||||
|
destination = new FileOutputStream(destFile).getChannel();
|
||||||
|
if (source != null) {
|
||||||
|
destination.transferFrom(source, 0, source.size());
|
||||||
|
}
|
||||||
|
if (source != null) {
|
||||||
|
source.close();
|
||||||
|
}
|
||||||
|
destination.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.parabot.environment.api.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author JKetelaar
|
||||||
|
*/
|
||||||
|
public class JavaUtil {
|
||||||
|
public static double JAVA_VERSION = getVersion();
|
||||||
|
|
||||||
|
static double getVersion () {
|
||||||
|
String version = System.getProperty("java.version");
|
||||||
|
int pos = version.indexOf('.');
|
||||||
|
pos = version.indexOf('.', pos+1);
|
||||||
|
return Double.parseDouble (version.substring (0, pos));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -156,6 +156,7 @@ public class Script implements Runnable {
|
|||||||
if(state < 0 || state > 2) {
|
if(state < 0 || state > 2) {
|
||||||
throw new IllegalArgumentException("Illegal state");
|
throw new IllegalArgumentException("Illegal state");
|
||||||
}
|
}
|
||||||
|
Core.setBugsnagInformation("Script", "State", String.valueOf(state));
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,5 +181,6 @@ public class Script implements Runnable {
|
|||||||
|
|
||||||
public void setScriptID(int scriptID){
|
public void setScriptID(int scriptID){
|
||||||
this.scriptID = scriptID;
|
this.scriptID = scriptID;
|
||||||
|
Core.setBugsnagInformation("Script", "State", String.valueOf(scriptID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import java.net.MalformedURLException;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("Duplicates")
|
||||||
|
@Deprecated
|
||||||
public class LocalServerExecuter extends ServerExecuter {
|
public class LocalServerExecuter extends ServerExecuter {
|
||||||
private final ServerProvider serverProvider;
|
private final ServerProvider serverProvider;
|
||||||
private ClassPath classPath;
|
private ClassPath classPath;
|
||||||
|
|||||||
+134
@@ -0,0 +1,134 @@
|
|||||||
|
package org.parabot.environment.servers.executers;
|
||||||
|
|
||||||
|
import org.parabot.core.Configuration;
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.Core;
|
||||||
|
import org.parabot.core.Directories;
|
||||||
|
import org.parabot.core.build.BuildPath;
|
||||||
|
import org.parabot.core.classpath.ClassPath;
|
||||||
|
import org.parabot.core.desc.ServerProviderInfo;
|
||||||
|
import org.parabot.core.forum.AccountManager;
|
||||||
|
import org.parabot.core.forum.AccountManagerAccess;
|
||||||
|
import org.parabot.core.ui.components.VerboseLoader;
|
||||||
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
import org.parabot.environment.api.utils.FileUtil;
|
||||||
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
|
import org.parabot.environment.servers.ServerProvider;
|
||||||
|
import org.parabot.environment.servers.loader.ServerLoader;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Fetches a server provider from the local config file
|
||||||
|
*
|
||||||
|
* @author JKetelaar
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class LocalPublicServerExecuter extends ServerExecuter {
|
||||||
|
private String serverName;
|
||||||
|
private String serverUrl;
|
||||||
|
private String providerUrl;
|
||||||
|
private ServerProviderInfo serverProviderInfo;
|
||||||
|
|
||||||
|
public LocalPublicServerExecuter(final String serverName, final ServerProviderInfo serverProviderInfo, String serverUrl, String providerUrl) {
|
||||||
|
this.serverName = serverName;
|
||||||
|
this.serverUrl = serverUrl;
|
||||||
|
this.providerUrl = providerUrl;
|
||||||
|
this.serverProviderInfo = serverProviderInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
final File destination = new File(Directories.getCachePath(),
|
||||||
|
serverProviderInfo.getCRC32() + ".jar");
|
||||||
|
|
||||||
|
Core.verbose("Downloading: " + providerUrl + " ...");
|
||||||
|
|
||||||
|
if(destination.exists()) {
|
||||||
|
Core.verbose("Found cached server provider [CRC32: " + serverProviderInfo.getCRC32() + "]");
|
||||||
|
} else {
|
||||||
|
File local;
|
||||||
|
if ((local = new File(providerUrl)).exists()){
|
||||||
|
FileUtil.copyFile(local, destination);
|
||||||
|
Core.verbose("Server provider copied...");
|
||||||
|
}else {
|
||||||
|
WebUtil.downloadFile(new URL(providerUrl), destination, VerboseLoader.get());
|
||||||
|
Core.verbose("Server provider downloaded...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final File clientDestination = new File(Directories.getCachePath(),
|
||||||
|
serverProviderInfo.getClientCRC32() + ".jar");
|
||||||
|
|
||||||
|
Core.verbose("Downloading: " + serverUrl + " ...");
|
||||||
|
|
||||||
|
if(clientDestination.exists()) {
|
||||||
|
Core.verbose("Found cached client [CRC32: " + serverProviderInfo.getClientCRC32() + "]");
|
||||||
|
} else {
|
||||||
|
File local;
|
||||||
|
if ((local = new File(serverUrl)).exists()){
|
||||||
|
FileUtil.copyFile(local, clientDestination);
|
||||||
|
Core.verbose("Server client copied...");
|
||||||
|
}else {
|
||||||
|
WebUtil.downloadFile(new URL(serverUrl), clientDestination, VerboseLoader.get());
|
||||||
|
Core.verbose("Server client downloaded...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final ClassPath classPath = new ClassPath();
|
||||||
|
classPath.addJar(destination);
|
||||||
|
|
||||||
|
BuildPath.add(destination.toURI().toURL());
|
||||||
|
|
||||||
|
ServerLoader serverLoader = new ServerLoader(classPath);
|
||||||
|
final String[] classNames = serverLoader.getServerClassNames();
|
||||||
|
if (classNames.length == 0) {
|
||||||
|
UILog.log(
|
||||||
|
"Error",
|
||||||
|
"Failed to load server provider, error: [No provider found in jar file.]",
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
} else if (classNames.length > 1) {
|
||||||
|
UILog.log(
|
||||||
|
"Error",
|
||||||
|
"Failed to load server provider, error: [Multiple providers found in jar file.]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String className = classNames[0];
|
||||||
|
try {
|
||||||
|
final Class<?> providerClass = serverLoader
|
||||||
|
.loadClass(className);
|
||||||
|
final Constructor<?> con = providerClass.getConstructor();
|
||||||
|
final ServerProvider serverProvider = (ServerProvider) con
|
||||||
|
.newInstance();
|
||||||
|
Context.getInstance(serverProvider).setProviderInfo(serverProviderInfo);
|
||||||
|
super.finalize(serverProvider, this.serverName);
|
||||||
|
} catch (NoClassDefFoundError | ClassNotFoundException ignored) {
|
||||||
|
UILog.log(
|
||||||
|
"Error",
|
||||||
|
"Failed to load server provider, error: [This server provider is not compatible with this version of parabot]",
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
UILog.log(
|
||||||
|
"Error",
|
||||||
|
"Failed to load server provider.",
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
UILog.log(
|
||||||
|
"Error",
|
||||||
|
"Failed to load server provider, post the stacktrace/error on the parabot forums.",
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -58,7 +58,6 @@ public class PublicServerExecuter extends ServerExecuter {
|
|||||||
+ this.serverName;
|
+ this.serverName;
|
||||||
|
|
||||||
Core.verbose("Downloading: " + jarUrl + " ...");
|
Core.verbose("Downloading: " + jarUrl + " ...");
|
||||||
|
|
||||||
|
|
||||||
if(destination.exists()) {
|
if(destination.exists()) {
|
||||||
Core.verbose("Found cached server provider [CRC32: " + serverProviderInfo.getCRC32() + "]");
|
Core.verbose("Found cached server provider [CRC32: " + serverProviderInfo.getCRC32() + "]");
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
package org.parabot.environment.servers.executers;
|
package org.parabot.environment.servers.executers;
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.parsers.randoms.RandomParser;
|
import org.parabot.core.parsers.randoms.RandomParser;
|
||||||
import org.parabot.core.ui.components.PaintComponent;
|
import org.parabot.core.ui.components.PaintComponent;
|
||||||
import org.parabot.environment.servers.ServerProvider;
|
import org.parabot.environment.servers.ServerProvider;
|
||||||
|
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Executes a server provider
|
* Executes a server provider
|
||||||
@@ -21,11 +24,7 @@ public abstract class ServerExecuter {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
try{
|
Core.setBugsnagServer(serverName);
|
||||||
org.parabot.environment.api.utils.WindowsPreferences.userRoot().remove("Software\\JavaSoft\\Prefs");
|
|
||||||
}catch (Exception e){
|
|
||||||
// Ikov likes to creates preference keys, doesn't it?
|
|
||||||
}
|
|
||||||
|
|
||||||
Context context = Context.getInstance(provider);
|
Context context = Context.getInstance(provider);
|
||||||
context.load();
|
context.load();
|
||||||
|
|||||||
Reference in New Issue
Block a user