mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 16:49:10 +00:00
Whole new revision for BDN support
This commit is contained in:
@@ -7,18 +7,13 @@ package org.parabot.core;
|
|||||||
*/
|
*/
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
public static final String LOGIN_SERVER = "https://www.parabot.org/community/api/login.php?username=%s&password=%s";
|
public static final String LOGIN_SERVER = "https://www.parabot.org/community/api/login.php?username=%s&password=%s";
|
||||||
public static final String SDN_SCRIPTS_JSON = "http://sdn.parabot.org/scripts.php?method=json&user=%s";
|
public static final String GET_SCRIPTS = "http://bdn.parabot.org/api/get.php?action=scripts_scripts&server=";
|
||||||
public static final String GET_SDN_SCRIPT = "http://sdn.parabot.org/getscript.php?user=%s&pass=%s&scriptid=%d";
|
public static final String GET_SCRIPT = "http://bdn.parabot.org/api/get.php?action=scripts_script&id=";
|
||||||
public static final String GET_SERVER_PROVIDERS_JSON = "http://sdn.parabot.org/providers/index.php?method=json";
|
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://sdn.parabot.org/providers/provider.php?id=";
|
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://sdn.parabot.org/providers/getInformation.php?id=";
|
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 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 REGISTRATION_PAGE = "https://www.parabot.org/community/index.php?app=core&module=global§ion=register";
|
||||||
|
|
||||||
public static final double BOT_VERSION = 2.1;
|
public static final double BOT_VERSION = 2.1;
|
||||||
|
|
||||||
/* Unused - But might be useful in the future
|
|
||||||
public static final String SDN_SCRIPTS = "http://sdn.parabot.org/scripts.php?user=%s";
|
|
||||||
public static final String GET_SERVER_PROVIDERS = "http://sdn.parabot.org/providers/index.php";
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public class ScriptDescription implements Comparable<ScriptDescription> {
|
|||||||
public String isVip;
|
public String isVip;
|
||||||
public String isPremium;
|
public String isPremium;
|
||||||
public int sdnId;
|
public int sdnId;
|
||||||
public String jarName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ScriptManifest
|
* The ScriptManifest
|
||||||
@@ -32,13 +31,12 @@ public class ScriptDescription implements Comparable<ScriptDescription> {
|
|||||||
final String category, final double version,
|
final String category, final double version,
|
||||||
final String description, final String[] servers) {
|
final String description, final String[] servers) {
|
||||||
this(scriptName, author, category, version, description, servers, null,
|
this(scriptName, author, category, version, description, servers, null,
|
||||||
null, -1, null);
|
null, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for SDN script (see SDNScripts parser)
|
* Used for SDN script (see SDNScripts parser)
|
||||||
*
|
*
|
||||||
* @param jarName
|
|
||||||
* @param scriptName
|
* @param scriptName
|
||||||
* @param author
|
* @param author
|
||||||
* @param category
|
* @param category
|
||||||
@@ -47,11 +45,11 @@ public class ScriptDescription implements Comparable<ScriptDescription> {
|
|||||||
* @param servers
|
* @param servers
|
||||||
* @param sdnId
|
* @param sdnId
|
||||||
*/
|
*/
|
||||||
public ScriptDescription(final String jarName, final String scriptName,
|
public ScriptDescription(final String scriptName,
|
||||||
final String author, final String category, final double version,
|
final String author, final String category, final double version,
|
||||||
final String description, final String[] servers, final int sdnId) {
|
final String description, final String[] servers, final int sdnId) {
|
||||||
this(scriptName, author, category, version, description, servers, null,
|
this(scriptName, author, category, version, description, servers, null,
|
||||||
null, sdnId, jarName);
|
null, sdnId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,7 +70,7 @@ public class ScriptDescription implements Comparable<ScriptDescription> {
|
|||||||
final String description, final String[] servers, final String vip,
|
final String description, final String[] servers, final String vip,
|
||||||
final String premium) {
|
final String premium) {
|
||||||
this(scriptName, author, category, version, description, servers, vip,
|
this(scriptName, author, category, version, description, servers, vip,
|
||||||
premium, -1, null);
|
premium, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,12 +85,11 @@ public class ScriptDescription implements Comparable<ScriptDescription> {
|
|||||||
* @param vip
|
* @param vip
|
||||||
* @param premium
|
* @param premium
|
||||||
* @param sdnId
|
* @param sdnId
|
||||||
* @param jarName
|
|
||||||
*/
|
*/
|
||||||
public ScriptDescription(final String scriptName, final String author,
|
public ScriptDescription(final String scriptName, final String author,
|
||||||
final String category, final double version,
|
final String category, final double version,
|
||||||
final String description, final String[] servers, final String vip,
|
final String description, final String[] servers, final String vip,
|
||||||
final String premium, final int sdnId, final String jarName) {
|
final String premium, final int sdnId) {
|
||||||
this.scriptName = scriptName;
|
this.scriptName = scriptName;
|
||||||
this.author = author;
|
this.author = author;
|
||||||
this.category = category;
|
this.category = category;
|
||||||
@@ -102,7 +99,6 @@ public class ScriptDescription implements Comparable<ScriptDescription> {
|
|||||||
this.isVip = vip;
|
this.isVip = vip;
|
||||||
this.isPremium = premium;
|
this.isPremium = premium;
|
||||||
this.sdnId = sdnId;
|
this.sdnId = sdnId;
|
||||||
this.jarName = jarName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -127,8 +123,7 @@ public class ScriptDescription implements Comparable<ScriptDescription> {
|
|||||||
.append(this.isPremium == null ? "unknown" : this.isPremium)
|
.append(this.isPremium == null ? "unknown" : this.isPremium)
|
||||||
.append(", sdn id: ")
|
.append(", sdn id: ")
|
||||||
.append(this.sdnId == -1 ? "unknown" : Integer
|
.append(this.sdnId == -1 ? "unknown" : Integer
|
||||||
.toString(this.sdnId)).append(", jarname: ")
|
.toString(this.sdnId))
|
||||||
.append(this.jarName == null ? "unknown" : this.jarName)
|
|
||||||
.append("]");
|
.append("]");
|
||||||
|
|
||||||
return b.toString();
|
return b.toString();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class ServerProviderInfo {
|
|||||||
try {
|
try {
|
||||||
String line;
|
String line;
|
||||||
Core.verbose("Reading info: " + providerInfo);
|
Core.verbose("Reading info: " + providerInfo);
|
||||||
BufferedReader br = WebUtil.getReader(new URL(providerInfo.toString() + "&method=json"), username, password);
|
BufferedReader br = WebUtil.getReader(new URL(providerInfo.toString()), username, password);
|
||||||
|
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
if ((line = br.readLine()) != null) {
|
if ((line = br.readLine()) != null) {
|
||||||
@@ -52,7 +52,7 @@ public class ServerProviderInfo {
|
|||||||
|
|
||||||
public URL getClient() {
|
public URL getClient() {
|
||||||
try {
|
try {
|
||||||
return new URL(properties.getProperty("client"));
|
return new URL(properties.getProperty("client_jar"));
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ public class ServerProviderInfo {
|
|||||||
|
|
||||||
public URL getExtendedHookFile() {
|
public URL getExtendedHookFile() {
|
||||||
try {
|
try {
|
||||||
return new URL(properties.get("hooks") + "&extended=true");
|
return new URL(properties.getProperty("hooks") /*+ "&extended=true"*/);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return getHookFile();
|
return getHookFile();
|
||||||
@@ -78,27 +78,23 @@ public class ServerProviderInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getClientClass() {
|
public String getClientClass() {
|
||||||
return properties.getProperty("clientClass");
|
return properties.getProperty("client_class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerName() {
|
public String getServerName() {
|
||||||
return properties.getProperty("serverName");
|
return properties.getProperty("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCRC32() {
|
public long getCRC32() {
|
||||||
if (properties.get("crc32") != null) {
|
return Long.parseLong(properties.getProperty("provider_crc32"));
|
||||||
return Long.parseLong(properties.getProperty("crc32"));
|
|
||||||
} else {
|
|
||||||
return System.currentTimeMillis() / 1000 / 60 / 60 / 24;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getClientCRC32() {
|
public long getClientCRC32() {
|
||||||
return Long.parseLong(properties.getProperty("clientCrc32"));
|
return Long.parseLong(properties.getProperty("client_crc32"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBankTabs() {
|
public int getBankTabs() {
|
||||||
return Integer.parseInt(properties.getProperty("bankTabs"));
|
return Integer.parseInt(properties.getProperty("bank_tabs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Properties getProperties() {
|
public Properties getProperties() {
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
package org.parabot.core.parsers.scripts;
|
package org.parabot.core.parsers.scripts;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.parabot.core.Configuration;
|
import org.parabot.core.Configuration;
|
||||||
|
import org.parabot.core.Context;
|
||||||
import org.parabot.core.desc.ScriptDescription;
|
import org.parabot.core.desc.ScriptDescription;
|
||||||
import org.parabot.core.forum.AccountManager;
|
import org.parabot.core.forum.AccountManager;
|
||||||
import org.parabot.core.forum.AccountManagerAccess;
|
import org.parabot.core.forum.AccountManagerAccess;
|
||||||
import org.parabot.environment.api.utils.WebUtil;
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
import org.parabot.environment.scripts.executers.SDNScriptExecuter;
|
import org.parabot.environment.scripts.executers.SDNScriptExecuter;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses scripts stored on the SDN of Parabot
|
* Parses scripts stored on the SDN of Parabot
|
||||||
*
|
*
|
||||||
@@ -38,22 +39,22 @@ public class SDNScripts extends ScriptParser {
|
|||||||
|
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
try {
|
try {
|
||||||
BufferedReader br = WebUtil.getReader(new URL(String.format(Configuration.SDN_SCRIPTS_JSON, manager.getAccount()
|
BufferedReader br = WebUtil.getReader(new URL(
|
||||||
.getURLUsername())));
|
Configuration.GET_SCRIPTS + Context.getInstance().getServerProviderInfo().getServerName()),
|
||||||
|
manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
JSONObject jsonObject = (JSONObject) parser.parse(line);
|
JSONObject jsonObject = (JSONObject) parser.parse(line);
|
||||||
String jarName = String.valueOf(jsonObject.get("jarname"));
|
int sdnId = Integer.parseInt(String.valueOf(jsonObject.get("id")));
|
||||||
int sdnId = Integer.parseInt(String.valueOf(jsonObject.get("scriptid")));
|
String scriptName = String.valueOf(jsonObject.get("name"));
|
||||||
String scriptName = String.valueOf(jsonObject.get("scriptname"));
|
|
||||||
String author = String.valueOf(jsonObject.get("author"));
|
String author = String.valueOf(jsonObject.get("author"));
|
||||||
double version = Double.parseDouble(String.valueOf(jsonObject.get("version")));
|
double version = Double.parseDouble(String.valueOf(jsonObject.get("version")));
|
||||||
String category = String.valueOf(jsonObject.get("category"));
|
String category = String.valueOf(jsonObject.get("category"));
|
||||||
String description = String.valueOf(jsonObject.get("description"));
|
String description = String.valueOf(jsonObject.get("description"));
|
||||||
|
|
||||||
final ScriptDescription desc = new ScriptDescription(jarName, scriptName,
|
final ScriptDescription desc = new ScriptDescription(scriptName,
|
||||||
author, category, version, description,
|
author, category, version, description,
|
||||||
null, sdnId);
|
null, sdnId);
|
||||||
SCRIPT_CACHE.put(desc, new SDNScriptExecuter(sdnId));
|
SCRIPT_CACHE.put(desc, new SDNScriptExecuter(sdnId));
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class PublicServers extends ServerParser {
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
try {
|
try {
|
||||||
BufferedReader br = WebUtil.getReader(new URL(
|
BufferedReader br = WebUtil.getReader(new URL(
|
||||||
Configuration.GET_SERVER_PROVIDERS_JSON), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
Configuration.GET_SERVER_PROVIDERS), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
@@ -44,11 +44,10 @@ public class PublicServers extends ServerParser {
|
|||||||
String name = String.valueOf(jsonObject.get("name"));
|
String name = String.valueOf(jsonObject.get("name"));
|
||||||
String author = String.valueOf(jsonObject.get("author"));
|
String author = String.valueOf(jsonObject.get("author"));
|
||||||
double version = Double.parseDouble(String.valueOf(jsonObject.get("version")));
|
double version = Double.parseDouble(String.valueOf(jsonObject.get("version")));
|
||||||
int serverID = Integer.parseInt(String.valueOf(jsonObject.get("id")));
|
|
||||||
|
|
||||||
ServerDescription desc = new ServerDescription(name,
|
ServerDescription desc = new ServerDescription(name,
|
||||||
author, version);
|
author, version);
|
||||||
SERVER_CACHE.put(desc, new PublicServerExecuter(name, serverID));
|
SERVER_CACHE.put(desc, new PublicServerExecuter(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
br.close();
|
br.close();
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package org.parabot.environment.input;
|
package org.parabot.environment.input;
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Point;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.awt.event.MouseMotionListener;
|
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.environment.api.utils.Time;
|
import org.parabot.environment.api.utils.Time;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.event.MouseMotionListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* A virtual mouse, dispatches mouse events to a component
|
* A virtual mouse, dispatches mouse events to a component
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ public class SDNScriptExecuter extends ScriptExecuter {
|
|||||||
@Override
|
@Override
|
||||||
public void run(ThreadGroup tg) {
|
public void run(ThreadGroup tg) {
|
||||||
try {
|
try {
|
||||||
final URLConnection urlConnection = WebUtil.getConnection(new URL(String.format(Configuration.GET_SDN_SCRIPT, manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword(), this.id)));
|
final URLConnection urlConnection = WebUtil.getConnection(new URL(
|
||||||
|
Configuration.GET_SCRIPT + this.id), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
||||||
|
|
||||||
final String contentType = urlConnection.getHeaderField("Content-type");
|
final String contentType = urlConnection.getHeaderField("Content-type");
|
||||||
if(contentType.equals("text/html")) {
|
if(contentType.equals("text/html")) {
|
||||||
// failed to fetch script
|
// failed to fetch script
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import java.net.URL;
|
|||||||
*/
|
*/
|
||||||
public class PublicServerExecuter extends ServerExecuter {
|
public class PublicServerExecuter extends ServerExecuter {
|
||||||
private String serverName;
|
private String serverName;
|
||||||
private int serverID;
|
|
||||||
|
|
||||||
private static AccountManager manager;
|
private static AccountManager manager;
|
||||||
|
|
||||||
@@ -43,21 +42,20 @@ public class PublicServerExecuter extends ServerExecuter {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public PublicServerExecuter(final String serverName, final int serverID) {
|
public PublicServerExecuter(final String serverName) {
|
||||||
this.serverName = serverName;
|
this.serverName = serverName;
|
||||||
this.serverID = serverID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
ServerProviderInfo serverProviderInfo = new ServerProviderInfo(new URL(Configuration.GET_SERVER_PROVIDER_INFO
|
ServerProviderInfo serverProviderInfo = new ServerProviderInfo(new URL(Configuration.GET_SERVER_PROVIDER_INFO
|
||||||
+ this.serverID), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
+ this.serverName), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
||||||
|
|
||||||
final File destination = new File(Directories.getCachePath(),
|
final File destination = new File(Directories.getCachePath(),
|
||||||
serverProviderInfo.getCRC32() + ".jar");
|
serverProviderInfo.getCRC32() + ".jar");
|
||||||
final String jarUrl = Configuration.GET_SERVER_PROVIDER
|
final String jarUrl = Configuration.GET_SERVER_PROVIDER
|
||||||
+ this.serverID;
|
+ this.serverName;
|
||||||
|
|
||||||
Core.verbose("Downloading: " + jarUrl + " ...");
|
Core.verbose("Downloading: " + jarUrl + " ...");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user