mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 00:37:55 +00:00
Merge branch 'master' of https://github.com/Parabot/Parabot.git
This commit is contained in:
@@ -48,7 +48,6 @@ public class AddGetterAdapter implements Opcodes, Injectable {
|
||||
final ClassNode fieldLocation, final FieldNode fieldNode,
|
||||
final String methodName, final String returnDesc,
|
||||
final boolean staticMethod, final long multiplier) {
|
||||
Core.verbose("Injecting getter method: " + methodName);
|
||||
this.into = into;
|
||||
this.fieldLocation = fieldLocation;
|
||||
this.fieldNode = fieldNode;
|
||||
|
||||
@@ -29,7 +29,6 @@ public class ServerProviderInfo {
|
||||
Core.verbose("Reading info: " + providerInfo);
|
||||
BufferedReader br = WebUtil.getReader(new URL(providerInfo.toString() + "&method=json"), username, password);
|
||||
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
if ((line = br.readLine()) != null) {
|
||||
JSONObject jsonObject = (JSONObject) parser.parse(line);
|
||||
@@ -59,14 +58,23 @@ public class ServerProviderInfo {
|
||||
return null;
|
||||
}
|
||||
|
||||
public URL getHookFile() {
|
||||
public URL getExtendenHookFile() {
|
||||
try {
|
||||
return new URL(properties.get("hooks"));
|
||||
return new URL(properties.get("hooks") + "&extended=true");
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
return getHookFile();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public URL getHookFile() {
|
||||
try {
|
||||
return new URL(properties.get("hooks"));
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getClientClass() {
|
||||
return properties.get("clientClass");
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package org.parabot.core.forum;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class which holds parabot forum account user and pass, only specific classes
|
||||
@@ -15,8 +18,8 @@ public class Account {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param username - UTF-8 encoded forum account username
|
||||
* @param password - UTF-8 encoded forum account password
|
||||
* @param username - Forum account username
|
||||
* @param password - Forum account password
|
||||
*/
|
||||
public Account(final String username, final String password) {
|
||||
this.username = username;
|
||||
@@ -25,7 +28,7 @@ public class Account {
|
||||
|
||||
/**
|
||||
* Gets user's parabot account name
|
||||
* @return username, already URL UTF-8 encoded.
|
||||
* @return username.
|
||||
*/
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
@@ -33,10 +36,36 @@ public class Account {
|
||||
|
||||
/**
|
||||
* Gets user's parabot password
|
||||
* @return password, already URL UTF-8 encoded.
|
||||
* @return password.
|
||||
*/
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user's parabot account name
|
||||
* @return username, already URL UTF-8 encoded.
|
||||
*/
|
||||
public String getURLUsername(){
|
||||
try {
|
||||
return URLEncoder.encode(this.username, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets user's password
|
||||
* @return password, already URL UTF-8 encoded.
|
||||
*/
|
||||
public String getURLPassword(){
|
||||
try {
|
||||
return URLEncoder.encode(this.password, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.parabot.environment.api.utils.WebUtil;
|
||||
import org.parabot.environment.scripts.executers.SDNScriptExecuter;
|
||||
import org.parabot.environment.servers.executers.PublicServerExecuter;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -74,12 +73,8 @@ public final class AccountManager {
|
||||
}
|
||||
|
||||
if (contents.equals("correct")) {
|
||||
try {
|
||||
account = new Account(URLEncoder.encode(user, "UTF-8"), URLEncoder.encode(pass, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
account = new Account(user, pass);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class SDNScripts extends ScriptParser {
|
||||
JSONParser parser = new JSONParser();
|
||||
try {
|
||||
BufferedReader br = WebUtil.getReader(new URL(String.format(Configuration.SDN_SCRIPTS_JSON, manager.getAccount()
|
||||
.getUsername())));
|
||||
.getURLUsername())));
|
||||
|
||||
String line;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class PublicServers extends ServerParser {
|
||||
public void execute() {
|
||||
try {
|
||||
BufferedReader br = WebUtil.getReader(new URL(
|
||||
Configuration.GET_SERVER_PROVIDERS_JSON), manager.getAccount().getUsername(), manager.getAccount().getPassword());
|
||||
Configuration.GET_SERVER_PROVIDERS_JSON), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
||||
String line;
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
|
||||
@@ -154,7 +154,5 @@ public class Script implements Runnable {
|
||||
public final void sleep(int ms) {
|
||||
Time.sleep(ms);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
package org.parabot.environment.scripts.executers;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.parabot.core.Configuration;
|
||||
import org.parabot.core.classpath.ClassPath;
|
||||
import org.parabot.core.forum.AccountManager;
|
||||
@@ -15,6 +9,11 @@ import org.parabot.environment.api.utils.WebUtil;
|
||||
import org.parabot.environment.scripts.Script;
|
||||
import org.parabot.environment.scripts.loader.JavaScriptLoader;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
*
|
||||
* Loads a script from the SDN
|
||||
@@ -44,7 +43,7 @@ public class SDNScriptExecuter extends ScriptExecuter {
|
||||
@Override
|
||||
public void run(ThreadGroup tg) {
|
||||
try {
|
||||
final URLConnection urlConnection = WebUtil.getConnection(new URL(String.format(Configuration.GET_SDN_SCRIPT, manager.getAccount().getUsername(), manager.getAccount().getPassword(), this.id)));
|
||||
final URLConnection urlConnection = WebUtil.getConnection(new URL(String.format(Configuration.GET_SDN_SCRIPT, manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword(), this.id)));
|
||||
final String contentType = urlConnection.getHeaderField("Content-type");
|
||||
if(contentType.equals("text/html")) {
|
||||
// failed to fetch script
|
||||
|
||||
@@ -52,7 +52,7 @@ public class PublicServerExecuter extends ServerExecuter {
|
||||
public void run() {
|
||||
try {
|
||||
ServerProviderInfo serverProviderInfo = new ServerProviderInfo(new URL(Configuration.GET_SERVER_PROVIDER_INFO
|
||||
+ this.serverID), manager.getAccount().getUsername(), manager.getAccount().getPassword());
|
||||
+ this.serverID), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
||||
|
||||
final File destination = new File(Directories.getCachePath(),
|
||||
serverProviderInfo.getCRC32() + ".jar");
|
||||
@@ -66,7 +66,7 @@ public class PublicServerExecuter extends ServerExecuter {
|
||||
Core.verbose("Found cached server provider [CRC32: " + serverProviderInfo.getCRC32() + "]");
|
||||
} else {
|
||||
WebUtil.downloadFile(new URL(jarUrl), destination,
|
||||
VerboseLoader.get(), manager.getAccount().getUsername(), manager.getAccount().getPassword());
|
||||
VerboseLoader.get(), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
||||
Core.verbose("Server provider downloaded...");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user