mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 16:49:10 +00:00
Merge branch 'feature/timer-days' of https://github.com/Parabot/Parabot into feature/timer-days
This commit is contained in:
+5
-3
@@ -1,5 +1,7 @@
|
|||||||
language: java
|
language: java
|
||||||
|
|
||||||
|
dist: trusty
|
||||||
|
|
||||||
jdk:
|
jdk:
|
||||||
- openjdk7
|
- openjdk7
|
||||||
- oraclejdk8
|
- oraclejdk8
|
||||||
@@ -32,7 +34,7 @@ env:
|
|||||||
- secure: UG+b1tEgc8xv9x4r//2OAIK1RrYv6n209KTTFMMwcnAa7DI8HaP8nljRa5/VhDhuKHdlVrYH/tI90v7UVBs0GDVNwK5V17Io0fMm3FUGZekSthTCqqno5wAGa9r6a6mMLtSaSmIFeIKi0+0d2ZwplRuhj/dtEYjjBBj+kK8g4nE=
|
- secure: UG+b1tEgc8xv9x4r//2OAIK1RrYv6n209KTTFMMwcnAa7DI8HaP8nljRa5/VhDhuKHdlVrYH/tI90v7UVBs0GDVNwK5V17Io0fMm3FUGZekSthTCqqno5wAGa9r6a6mMLtSaSmIFeIKi0+0d2ZwplRuhj/dtEYjjBBj+kK8g4nE=
|
||||||
- secure: St/fecUDInFBCRriYqgp2F8PU9/SooorgxD9Mrs+b0EsC7AbtSsQXvdIv2Lp6xzdQ0VSXPcLIhULPOYrmBKnGQ/NjXTIZXxnroyQxxnI6xyEWIZwiHRY/bKRJDRbQTxD9NL32szKiDSwnw7pu6llF4D64UqQvziq4Gm6VohU75M=
|
- secure: St/fecUDInFBCRriYqgp2F8PU9/SooorgxD9Mrs+b0EsC7AbtSsQXvdIv2Lp6xzdQ0VSXPcLIhULPOYrmBKnGQ/NjXTIZXxnroyQxxnI6xyEWIZwiHRY/bKRJDRbQTxD9NL32szKiDSwnw7pu6llF4D64UqQvziq4Gm6VohU75M=
|
||||||
- secure: bD15GVZWowiknbfLavh8CxSh0GsnF5kT4kZ6ggCuUDGyj0mzqf7dNRnchQIKkCG0WRYyTrFN4pEiygeywWsipEeAVv9Xhx3cuUZmzeQaR5KCWabSwJ8gK6jZd1YhcWmM9vrdPHobZr65MP0y/8mu/Fovgky9dY7KDf4G3SebNrM=
|
- secure: bD15GVZWowiknbfLavh8CxSh0GsnF5kT4kZ6ggCuUDGyj0mzqf7dNRnchQIKkCG0WRYyTrFN4pEiygeywWsipEeAVv9Xhx3cuUZmzeQaR5KCWabSwJ8gK6jZd1YhcWmM9vrdPHobZr65MP0y/8mu/Fovgky9dY7KDf4G3SebNrM=
|
||||||
- PARABOT_VERSION=2.6.6.6
|
- PARABOT_VERSION=2.6.8
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
@@ -56,7 +58,7 @@ deploy:
|
|||||||
branch:
|
branch:
|
||||||
- master
|
- master
|
||||||
- development
|
- development
|
||||||
jdk: 'oraclejdk7'
|
jdk: 'openjdk7'
|
||||||
|
|
||||||
- provider: script
|
- provider: script
|
||||||
script: "cp ./.travis/.travis.settings.xml $HOME/.m2/settings.xml && mvn package javadoc:javadoc deploy site:deploy"
|
script: "cp ./.travis/.travis.settings.xml $HOME/.m2/settings.xml && mvn package javadoc:javadoc deploy site:deploy"
|
||||||
@@ -65,4 +67,4 @@ deploy:
|
|||||||
repo: Parabot/Parabot
|
repo: Parabot/Parabot
|
||||||
branch:
|
branch:
|
||||||
- master
|
- master
|
||||||
jdk: 'oraclejdk7'
|
jdk: 'openjdk7'
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
# Parabot
|
# Parabot
|
||||||
|
|
||||||
Parabot V2.6.3.
|
Parabot V2.6.8.
|
||||||
|
|
||||||
#### Links
|
#### Links
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>org.parabot</groupId>
|
<groupId>org.parabot</groupId>
|
||||||
<artifactId>client</artifactId>
|
<artifactId>client</artifactId>
|
||||||
<version>2.6.6.6</version>
|
<version>2.6.8</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,14 @@ public class Context {
|
|||||||
return getInstance(null);
|
return getInstance(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setUsername(String username) {
|
||||||
|
Context.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the main client instance
|
* Sets the main client instance
|
||||||
*/
|
*/
|
||||||
@@ -88,12 +96,12 @@ public class Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the hook parser
|
* Gets the mouse
|
||||||
*
|
*
|
||||||
* @param hookParser
|
* @return mouse
|
||||||
*/
|
*/
|
||||||
public void setHookParser(final HookParser hookParser) {
|
public Mouse getMouse() {
|
||||||
this.hookParser = hookParser;
|
return mouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,15 +114,14 @@ public class Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the mouse
|
* Gets the keyboard
|
||||||
*
|
*
|
||||||
* @return mouse
|
* @return keyboard
|
||||||
*/
|
*/
|
||||||
public Mouse getMouse() {
|
public Keyboard getKeyboard() {
|
||||||
return mouse;
|
return keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the keyboard
|
* Sets the keyboard
|
||||||
*
|
*
|
||||||
@@ -124,15 +131,6 @@ public class Context {
|
|||||||
this.keyboard = keyboard;
|
this.keyboard = keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the keyboard
|
|
||||||
*
|
|
||||||
* @return keyboard
|
|
||||||
*/
|
|
||||||
public Keyboard getKeyboard() {
|
|
||||||
return keyboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClassPath
|
* ClassPath
|
||||||
*
|
*
|
||||||
@@ -160,32 +158,9 @@ public class Context {
|
|||||||
return gameApplet;
|
return gameApplet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the game
|
|
||||||
*/
|
|
||||||
public void load() {
|
|
||||||
Core.verbose(TranslationHelper.translate("PARSING_SERVER_JAR"));
|
|
||||||
serverProvider.init();
|
|
||||||
serverProvider.parseJar();
|
|
||||||
Core.verbose(TranslationHelper.translate("DONE"));
|
|
||||||
Core.verbose(TranslationHelper.translate("INJECTING_HOOKS"));
|
|
||||||
serverProvider.injectHooks();
|
|
||||||
Core.verbose(TranslationHelper.translate("DONE"));
|
|
||||||
Core.verbose(TranslationHelper.translate("FETCHING_GAME_APPLET"));
|
|
||||||
if(Core.shouldDump()) {
|
|
||||||
Core.verbose(TranslationHelper.translate("DUMPING_INJECTED_CLIENT"));
|
|
||||||
classPath.dump(new File(Directories.getWorkspace(), "dump.jar"));
|
|
||||||
Core.verbose(TranslationHelper.translate("DONE"));
|
|
||||||
}
|
|
||||||
Applet applet = serverProvider.fetchApplet();
|
|
||||||
// if applet is null the server provider will call setApplet itself
|
|
||||||
if(applet != null) {
|
|
||||||
setApplet(applet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the bot target applet
|
* Sets the bot target applet
|
||||||
|
*
|
||||||
* @param applet
|
* @param applet
|
||||||
*/
|
*/
|
||||||
public void setApplet(final Applet applet) {
|
public void setApplet(final Applet applet) {
|
||||||
@@ -237,6 +212,30 @@ public class Context {
|
|||||||
System.setErr(this.defaultErr);
|
System.setErr(this.defaultErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the game
|
||||||
|
*/
|
||||||
|
public void load() {
|
||||||
|
Core.verbose(TranslationHelper.translate("PARSING_SERVER_JAR"));
|
||||||
|
serverProvider.init();
|
||||||
|
serverProvider.parseJar();
|
||||||
|
Core.verbose(TranslationHelper.translate("DONE"));
|
||||||
|
Core.verbose(TranslationHelper.translate("INJECTING_HOOKS"));
|
||||||
|
serverProvider.injectHooks();
|
||||||
|
Core.verbose(TranslationHelper.translate("DONE"));
|
||||||
|
Core.verbose(TranslationHelper.translate("FETCHING_GAME_APPLET"));
|
||||||
|
if (Core.shouldDump()) {
|
||||||
|
Core.verbose(TranslationHelper.translate("DUMPING_INJECTED_CLIENT"));
|
||||||
|
classPath.dump(new File(Directories.getWorkspace(), "dump.jar"));
|
||||||
|
Core.verbose(TranslationHelper.translate("DONE"));
|
||||||
|
}
|
||||||
|
Applet applet = serverProvider.fetchApplet();
|
||||||
|
// if applet is null the server provider will call setApplet itself
|
||||||
|
if (applet != null) {
|
||||||
|
setApplet(applet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the server prodiver belonging to this context
|
* Gets the server prodiver belonging to this context
|
||||||
*
|
*
|
||||||
@@ -247,7 +246,6 @@ public class Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Sets provider info of this context
|
* Sets provider info of this context
|
||||||
*
|
*
|
||||||
* @param providerInfo
|
* @param providerInfo
|
||||||
@@ -259,6 +257,7 @@ public class Context {
|
|||||||
/**
|
/**
|
||||||
* Gets ServerProvider info
|
* Gets ServerProvider info
|
||||||
* Can be null if this is not a public server provider
|
* Can be null if this is not a public server provider
|
||||||
|
*
|
||||||
* @return info about this provider
|
* @return info about this provider
|
||||||
*/
|
*/
|
||||||
public ServerProviderInfo getServerProviderInfo() {
|
public ServerProviderInfo getServerProviderInfo() {
|
||||||
@@ -329,12 +328,12 @@ public class Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current running script, if a script stops it will call this method with a null argument
|
* Sets the hook parser
|
||||||
*
|
*
|
||||||
* @param script
|
* @param hookParser
|
||||||
*/
|
*/
|
||||||
public void setRunningScript(final Script script) {
|
public void setHookParser(final HookParser hookParser) {
|
||||||
this.runningScript = script;
|
this.hookParser = hookParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -346,22 +345,24 @@ public class Context {
|
|||||||
return this.runningScript;
|
return this.runningScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current running script, if a script stops it will call this method with a null argument
|
||||||
|
*
|
||||||
|
* @param script
|
||||||
|
*/
|
||||||
|
public void setRunningScript(final Script script) {
|
||||||
|
this.runningScript = script;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the random handler
|
* Gets the random handler
|
||||||
|
*
|
||||||
* @return random handler
|
* @return random handler
|
||||||
*/
|
*/
|
||||||
public RandomHandler getRandomHandler() {
|
public RandomHandler getRandomHandler() {
|
||||||
return this.randomHandler;
|
return this.randomHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setUsername(String username) {
|
|
||||||
Context.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONParser getJsonParser() {
|
public JSONParser getJsonParser() {
|
||||||
return jsonParser;
|
return jsonParser;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,14 @@ public class ProjectProperties {
|
|||||||
setProperties();
|
setProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Version getProjectVersion() {
|
||||||
|
return new Version(getInstance().getCached().getProperty("application.version"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ProjectProperties getInstance() {
|
||||||
|
return instance == null ? instance = new ProjectProperties() : instance;
|
||||||
|
}
|
||||||
|
|
||||||
private void setProperties() {
|
private void setProperties() {
|
||||||
InputStream input;
|
InputStream input;
|
||||||
try {
|
try {
|
||||||
@@ -35,12 +43,4 @@ public class ProjectProperties {
|
|||||||
private Properties getCached() {
|
private Properties getCached() {
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Version getProjectVersion() {
|
|
||||||
return new Version(getInstance().getCached().getProperty("application.version"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ProjectProperties getInstance() {
|
|
||||||
return instance == null ? instance = new ProjectProperties() : instance;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.parabot.core.asm;
|
package org.parabot.core.asm;
|
||||||
|
|
||||||
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.parabot.core.classpath.ClassPath;
|
import org.parabot.core.classpath.ClassPath;
|
||||||
@@ -16,17 +15,15 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Makes classnodes into runnable classes
|
* Makes classnodes into runnable classes
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
* @author Matt
|
* @author Matt
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ASMClassLoader extends ClassLoader {
|
public class ASMClassLoader extends ClassLoader {
|
||||||
|
|
||||||
private Map<String, Class<?>> classCache;
|
|
||||||
public ClassPath classPath;
|
public ClassPath classPath;
|
||||||
|
private Map<String, Class<?>> classCache;
|
||||||
|
|
||||||
public ASMClassLoader(final ClassPath classPath) {
|
public ASMClassLoader(final ClassPath classPath) {
|
||||||
this.classCache = new HashMap<String, Class<?>>();
|
this.classCache = new HashMap<String, Class<?>>();
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ import org.parabot.core.Context;
|
|||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* A collection of various asm util methods
|
* A collection of various asm util methods
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ASMUtils implements Opcodes {
|
public class ASMUtils implements Opcodes {
|
||||||
|
|
||||||
@@ -28,7 +26,7 @@ public class ASMUtils implements Opcodes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static FieldNode getField(ClassNode node, String fieldName, String desc) {
|
public static FieldNode getField(ClassNode node, String fieldName, String desc) {
|
||||||
if(desc == null) {
|
if (desc == null) {
|
||||||
return getField(node, fieldName);
|
return getField(node, fieldName);
|
||||||
}
|
}
|
||||||
for (final Object fieldNode : node.fields) {
|
for (final Object fieldNode : node.fields) {
|
||||||
@@ -70,6 +68,7 @@ public class ASMUtils implements Opcodes {
|
|||||||
* Return right opcode for desc
|
* Return right opcode for desc
|
||||||
*
|
*
|
||||||
* @param desc
|
* @param desc
|
||||||
|
*
|
||||||
* @return return opcode
|
* @return return opcode
|
||||||
*/
|
*/
|
||||||
public static int getReturnOpcode(String desc) {
|
public static int getReturnOpcode(String desc) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
public class ClassRemapper extends Remapper {
|
public class ClassRemapper extends Remapper {
|
||||||
private static HashMap<String, String> remapNames = new HashMap<String, String>();
|
private static HashMap<String, String> remapNames = new HashMap<String, String>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
remapNames.put("java/net/Socket", "org/parabot/core/network/proxy/ProxySocket");
|
remapNames.put("java/net/Socket", "org/parabot/core/network/proxy/ProxySocket");
|
||||||
remapNames.put("java/net/NetworkInterface", "org/parabot/core/network/NetworkInterface");
|
remapNames.put("java/net/NetworkInterface", "org/parabot/core/network/NetworkInterface");
|
||||||
|
|||||||
@@ -17,9 +17,6 @@ import java.util.Map;
|
|||||||
public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
||||||
|
|
||||||
private static final Map<String, Class<?>> redirects = new HashMap<String, Class<?>>();
|
private static final Map<String, Class<?>> redirects = new HashMap<String, Class<?>>();
|
||||||
|
|
||||||
private String className;
|
|
||||||
|
|
||||||
private static PrintStream str_out, class_out;
|
private static PrintStream str_out, class_out;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -34,36 +31,47 @@ public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
|||||||
redirects.put("java/lang/System", SystemRedirect.class);
|
redirects.put("java/lang/System", SystemRedirect.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String className;
|
||||||
|
|
||||||
public RedirectClassAdapter(ClassVisitor cv) {
|
public RedirectClassAdapter(ClassVisitor cv) {
|
||||||
super(ASM5, cv);
|
super(ASM5, cv);
|
||||||
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")));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if(class_out == null && Core.shouldDump())
|
}
|
||||||
|
if (class_out == null && Core.shouldDump()) {
|
||||||
try {
|
try {
|
||||||
class_out = new PrintStream(new FileOutputStream(new File(Directories.getWorkspace(),"classes.txt")));
|
class_out = new PrintStream(new FileOutputStream(new File(Directories.getWorkspace(), "classes.txt")));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SecurityException createSecurityException() {
|
||||||
|
Exception e = new Exception();
|
||||||
|
StackTraceElement[] elements = e.getStackTrace();
|
||||||
|
return new SecurityException("Unsafe operation blocked. Op:"
|
||||||
|
+ elements[1].getMethodName());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(int version, int access, String name, String signature,
|
public void visit(int version, int access, String name, String signature,
|
||||||
String superName, String[] interfaces) {
|
String superName, String[] interfaces) {
|
||||||
this.className = name;
|
this.className = name;
|
||||||
super.visit(version, access, name, signature, superName, interfaces);
|
super.visit(version, access, name, signature, superName, interfaces);
|
||||||
if(class_out != null) {
|
if (class_out != null) {
|
||||||
class_out.println(className + " References:");
|
class_out.println(className + " References:");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitEnd(){
|
public void visitEnd() {
|
||||||
super.visitEnd();
|
super.visitEnd();
|
||||||
if(class_out != null){
|
if (class_out != null) {
|
||||||
class_out.println();
|
class_out.println();
|
||||||
class_out.println();
|
class_out.println();
|
||||||
}
|
}
|
||||||
@@ -106,7 +114,7 @@ public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(class_out != null) {
|
if (class_out != null) {
|
||||||
class_out.println(owner);
|
class_out.println(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,25 +123,19 @@ public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitFieldInsn(int opcode, String owner, String name,
|
public void visitFieldInsn(int opcode, String owner, String name,
|
||||||
String desc){
|
String desc) {
|
||||||
if (Core.isSecure() && (opcode == GETSTATIC || opcode == PUTSTATIC)) {
|
if (Core.isSecure() && (opcode == GETSTATIC || opcode == PUTSTATIC)) {
|
||||||
if (redirects.containsKey(owner)) {
|
if (redirects.containsKey(owner)) {
|
||||||
owner = redirects.get(owner).getName()
|
owner = redirects.get(owner).getName()
|
||||||
.replaceAll("\\.", "/");
|
.replaceAll("\\.", "/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(class_out != null)
|
if (class_out != null) {
|
||||||
class_out.println(owner);
|
class_out.println(owner);
|
||||||
|
}
|
||||||
super.visitFieldInsn(opcode, owner, name, desc);
|
super.visitFieldInsn(opcode, owner, name, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SecurityException createSecurityException() {
|
|
||||||
Exception e = new Exception();
|
|
||||||
StackTraceElement[] elements = e.getStackTrace();
|
|
||||||
return new SecurityException("Unsafe operation blocked. Op:"
|
|
||||||
+ elements[1].getMethodName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,18 @@
|
|||||||
package org.parabot.core.asm.adapters;
|
package org.parabot.core.asm.adapters;
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
|
|
||||||
import org.objectweb.asm.Label;
|
import org.objectweb.asm.Label;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
import org.objectweb.asm.tree.*;
|
||||||
import org.objectweb.asm.tree.InsnList;
|
|
||||||
import org.objectweb.asm.tree.InsnNode;
|
|
||||||
import org.objectweb.asm.tree.JumpInsnNode;
|
|
||||||
import org.objectweb.asm.tree.LabelNode;
|
|
||||||
import org.objectweb.asm.tree.MethodInsnNode;
|
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
|
||||||
import org.objectweb.asm.tree.VarInsnNode;
|
|
||||||
import org.parabot.core.asm.ASMUtils;
|
import org.parabot.core.asm.ASMUtils;
|
||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Injects a callback, invokes a given static method
|
* Injects a callback, invokes a given static method
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class AddCallbackAdapter implements Injectable, Opcodes {
|
public class AddCallbackAdapter implements Injectable, Opcodes {
|
||||||
private MethodNode method;
|
private MethodNode method;
|
||||||
@@ -50,11 +41,11 @@ public class AddCallbackAdapter implements Injectable, Opcodes {
|
|||||||
inject.add(new LabelNode(l0));
|
inject.add(new LabelNode(l0));
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for (int arg : args) {
|
for (int arg : args) {
|
||||||
if(Modifier.isStatic(method.access)) {
|
if (Modifier.isStatic(method.access)) {
|
||||||
int loadOpcode = ASMUtils.getLoadOpcode(types[arg]
|
int loadOpcode = ASMUtils.getLoadOpcode(types[arg]
|
||||||
.getDescriptor());
|
.getDescriptor());
|
||||||
inject.add(new VarInsnNode(loadOpcode, arg + offset));
|
inject.add(new VarInsnNode(loadOpcode, arg + offset));
|
||||||
if(loadOpcode == Opcodes.LLOAD) {
|
if (loadOpcode == Opcodes.LLOAD) {
|
||||||
offset++;
|
offset++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -65,10 +56,10 @@ public class AddCallbackAdapter implements Injectable, Opcodes {
|
|||||||
inject.add(new MethodInsnNode(INVOKESTATIC,
|
inject.add(new MethodInsnNode(INVOKESTATIC,
|
||||||
this.invokeClass, this.invokeMethod,
|
this.invokeClass, this.invokeMethod,
|
||||||
this.desc));
|
this.desc));
|
||||||
if(this.conditional) {
|
if (this.conditional) {
|
||||||
LabelNode ln = new LabelNode(new Label());
|
LabelNode ln = new LabelNode(new Label());
|
||||||
inject.add(new JumpInsnNode(IFEQ, ln));
|
inject.add(new JumpInsnNode(IFEQ, ln));
|
||||||
if(Type.getReturnType(method.desc).equals(Type.BOOLEAN_TYPE)) {
|
if (Type.getReturnType(method.desc).equals(Type.BOOLEAN_TYPE)) {
|
||||||
inject.add(new InsnNode(ICONST_1));
|
inject.add(new InsnNode(ICONST_1));
|
||||||
inject.add(new InsnNode(IRETURN));
|
inject.add(new InsnNode(IRETURN));
|
||||||
} else {
|
} else {
|
||||||
@@ -77,17 +68,17 @@ public class AddCallbackAdapter implements Injectable, Opcodes {
|
|||||||
inject.add(ln);
|
inject.add(ln);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(method.name.startsWith("<") && !Modifier.isStatic(method.access)) {
|
if (method.name.startsWith("<") && !Modifier.isStatic(method.access)) {
|
||||||
// find target
|
// find target
|
||||||
AbstractInsnNode target = null;
|
AbstractInsnNode target = null;
|
||||||
for(AbstractInsnNode node : this.method.instructions.toArray()) {
|
for (AbstractInsnNode node : this.method.instructions.toArray()) {
|
||||||
if(node.getOpcode() == Opcodes.INVOKESPECIAL) {
|
if (node.getOpcode() == Opcodes.INVOKESPECIAL) {
|
||||||
target = node;
|
target = node;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target != null) {
|
if (target != null) {
|
||||||
this.method.instructions.insert(target, inject);
|
this.method.instructions.insert(target, inject);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,12 +2,7 @@ package org.parabot.core.asm.adapters;
|
|||||||
|
|
||||||
import org.objectweb.asm.Label;
|
import org.objectweb.asm.Label;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.*;
|
||||||
import org.objectweb.asm.tree.InsnList;
|
|
||||||
import org.objectweb.asm.tree.LabelNode;
|
|
||||||
import org.objectweb.asm.tree.LdcInsnNode;
|
|
||||||
import org.objectweb.asm.tree.MethodInsnNode;
|
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
|
||||||
|
|
||||||
public class AddDebugAdapter {
|
public class AddDebugAdapter {
|
||||||
private ClassNode owner;
|
private ClassNode owner;
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.parabot.core.asm.adapters;
|
package org.parabot.core.asm.adapters;
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
|
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
@@ -11,11 +9,12 @@ import org.parabot.core.Core;
|
|||||||
import org.parabot.core.asm.ASMUtils;
|
import org.parabot.core.asm.ASMUtils;
|
||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a method into a Classnode which returns a field
|
* Adds a method into a Classnode which returns a field
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class AddGetterAdapter implements Opcodes, Injectable {
|
public class AddGetterAdapter implements Opcodes, Injectable {
|
||||||
private ClassNode into;
|
private ClassNode into;
|
||||||
@@ -28,21 +27,13 @@ public class AddGetterAdapter implements Opcodes, Injectable {
|
|||||||
private long multiplier;
|
private long multiplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param into - classnode to inject getter method in
|
||||||
* @param into
|
* @param fieldLocation - classnode where field is located
|
||||||
* - classnode to inject getter method in
|
* @param fieldNode - field name to get
|
||||||
* @param fieldLocation
|
* @param methodName - method name of getter
|
||||||
* - classnode where field is located
|
* @param returnDesc - return type of method, can be null for default return
|
||||||
* @param fieldNode
|
* @param staticMethod - pass true if you want the method to be static
|
||||||
* - field name to get
|
* @param multiplier - if this field requires a multipli
|
||||||
* @param methodName
|
|
||||||
* - method name of getter
|
|
||||||
* @param returnDesc
|
|
||||||
* - return type of method, can be null for default return
|
|
||||||
* @param staticMethod
|
|
||||||
* - pass true if you want the method to be static
|
|
||||||
* @param multiplier
|
|
||||||
* - if this field requires a multipli
|
|
||||||
*/
|
*/
|
||||||
public AddGetterAdapter(final ClassNode into,
|
public AddGetterAdapter(final ClassNode into,
|
||||||
final ClassNode fieldLocation, final FieldNode fieldNode,
|
final ClassNode fieldLocation, final FieldNode fieldNode,
|
||||||
@@ -59,7 +50,6 @@ public class AddGetterAdapter implements Opcodes, Injectable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param fieldLocation
|
* @param fieldLocation
|
||||||
* @param fieldNode
|
* @param fieldNode
|
||||||
* @param methodName
|
* @param methodName
|
||||||
@@ -129,7 +119,7 @@ public class AddGetterAdapter implements Opcodes, Injectable {
|
|||||||
if (!staticField) {
|
if (!staticField) {
|
||||||
method.visitVarInsn(ALOAD, 0);
|
method.visitVarInsn(ALOAD, 0);
|
||||||
}
|
}
|
||||||
if(staticField) {
|
if (staticField) {
|
||||||
ASMUtils.makePublic(fieldNode);
|
ASMUtils.makePublic(fieldNode);
|
||||||
}
|
}
|
||||||
method.visitFieldInsn(staticField ? GETSTATIC : GETFIELD,
|
method.visitFieldInsn(staticField ? GETSTATIC : GETFIELD,
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ import org.parabot.core.asm.ASMUtils;
|
|||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* This class appends an interface to a class
|
* This class appends an interface to a class
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class AddInterfaceAdapter implements Injectable {
|
public class AddInterfaceAdapter implements Injectable {
|
||||||
private static String accessorPackage;
|
private static String accessorPackage;
|
||||||
@@ -29,12 +27,23 @@ public class AddInterfaceAdapter implements Injectable {
|
|||||||
this.interfaceClass = interfaceClass;
|
this.interfaceClass = interfaceClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getAccessorPackage() {
|
||||||
|
return accessorPackage;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setAccessorPackage(String packageName) {
|
public static void setAccessorPackage(String packageName) {
|
||||||
accessorPackage = packageName;
|
accessorPackage = packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAccessorPackage() {
|
protected static void addInterface(ClassNode node, String i) {
|
||||||
return accessorPackage;
|
ASMUtils.makePublic(node);
|
||||||
|
for (Object mn : node.methods) {
|
||||||
|
MethodNode methodNode = (MethodNode) mn;
|
||||||
|
if (methodNode.name.startsWith("<init")) {
|
||||||
|
ASMUtils.makePublic(methodNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node.interfaces.add(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,17 +52,6 @@ public class AddInterfaceAdapter implements Injectable {
|
|||||||
addInterface(node, accessorPackage + interfaceClass);
|
addInterface(node, accessorPackage + interfaceClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void addInterface(ClassNode node, String i) {
|
|
||||||
ASMUtils.makePublic(node);
|
|
||||||
for(Object mn : node.methods) {
|
|
||||||
MethodNode methodNode = (MethodNode) mn;
|
|
||||||
if(methodNode.name.startsWith("<init")) {
|
|
||||||
ASMUtils.makePublic(methodNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node.interfaces.add(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new StringBuilder("[Injectable: interface, into classname: ").append(node.name).append(", interface: ").append(accessorPackage).append(interfaceClass).append("]").toString();
|
return new StringBuilder("[Injectable: interface, into classname: ").append(node.name).append(", interface: ").append(accessorPackage).append(interfaceClass).append("]").toString();
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.parabot.core.asm.adapters;
|
package org.parabot.core.asm.adapters;
|
||||||
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
|
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
@@ -9,12 +7,12 @@ import org.objectweb.asm.tree.MethodNode;
|
|||||||
import org.parabot.core.asm.ASMUtils;
|
import org.parabot.core.asm.ASMUtils;
|
||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Injects a method which invokes an other method
|
* Injects a method which invokes an other method
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class AddInvokerAdapter implements Opcodes, Injectable {
|
public class AddInvokerAdapter implements Opcodes, Injectable {
|
||||||
private ClassNode into;
|
private ClassNode into;
|
||||||
@@ -56,7 +54,7 @@ public class AddInvokerAdapter implements Opcodes, Injectable {
|
|||||||
MethodNode m = new MethodNode(ACC_PUBLIC, this.methodName,
|
MethodNode m = new MethodNode(ACC_PUBLIC, this.methodName,
|
||||||
mArgsDesc + this.returnDesc, null, null);
|
mArgsDesc + this.returnDesc, null, null);
|
||||||
|
|
||||||
if(!isInterface) {
|
if (!isInterface) {
|
||||||
isStatic = (this.mn.access & ACC_STATIC) != 0;
|
isStatic = (this.mn.access & ACC_STATIC) != 0;
|
||||||
|
|
||||||
if (!Modifier.isPublic(mn.access)) {
|
if (!Modifier.isPublic(mn.access)) {
|
||||||
@@ -71,11 +69,11 @@ public class AddInvokerAdapter implements Opcodes, Injectable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isStatic || isInterface) {
|
if (!isStatic || isInterface) {
|
||||||
m.visitVarInsn(ALOAD, 0);
|
m.visitVarInsn(ALOAD, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(instanceCast != null) {
|
if (instanceCast != null) {
|
||||||
m.visitTypeInsn(CHECKCAST, instanceCast);
|
m.visitTypeInsn(CHECKCAST, instanceCast);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,11 +81,11 @@ public class AddInvokerAdapter implements Opcodes, Injectable {
|
|||||||
Type[] castArgs = argsCheckCast == null ? null : Type.getArgumentTypes(argsCheckCast + "V");
|
Type[] castArgs = argsCheckCast == null ? null : Type.getArgumentTypes(argsCheckCast + "V");
|
||||||
Type[] methodArgs = Type.getArgumentTypes(argsDesc + "V");
|
Type[] methodArgs = Type.getArgumentTypes(argsDesc + "V");
|
||||||
|
|
||||||
for(int i = 0; i < methodArgs.length; i++) {
|
for (int i = 0; i < methodArgs.length; i++) {
|
||||||
m.visitVarInsn(ASMUtils.getLoadOpcode(methodArgs[i].getDescriptor()), i + 1);
|
m.visitVarInsn(ASMUtils.getLoadOpcode(methodArgs[i].getDescriptor()), i + 1);
|
||||||
if(castArgs != null && !castArgs[i].getDescriptor().equals(methodArgs[i].getDescriptor())) {
|
if (castArgs != null && !castArgs[i].getDescriptor().equals(methodArgs[i].getDescriptor())) {
|
||||||
String cast = methodArgs[i].getDescriptor();
|
String cast = methodArgs[i].getDescriptor();
|
||||||
if(cast.startsWith("L")) {
|
if (cast.startsWith("L")) {
|
||||||
cast = cast.substring(1).replace(";", "");
|
cast = cast.substring(1).replace(";", "");
|
||||||
}
|
}
|
||||||
m.visitTypeInsn(CHECKCAST, cast);
|
m.visitTypeInsn(CHECKCAST, cast);
|
||||||
@@ -95,7 +93,7 @@ public class AddInvokerAdapter implements Opcodes, Injectable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isInterface) {
|
if (isInterface) {
|
||||||
m.visitMethodInsn(INVOKEINTERFACE, instanceCast, mName, mDesc);
|
m.visitMethodInsn(INVOKEINTERFACE, instanceCast, mName, mDesc);
|
||||||
} else {
|
} else {
|
||||||
m.visitMethodInsn(isStatic ? INVOKESTATIC : INVOKEVIRTUAL, methodLocation.name, mn.name, mn.desc);
|
m.visitMethodInsn(isStatic ? INVOKESTATIC : INVOKEVIRTUAL, methodLocation.name, mn.name, mn.desc);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import org.parabot.core.asm.interfaces.Injectable;
|
|||||||
* Injects methods which sets a field
|
* Injects methods which sets a field
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class AddSetterAdapter implements Opcodes, Injectable {
|
public class AddSetterAdapter implements Opcodes, Injectable {
|
||||||
private ClassNode fieldLocation;
|
private ClassNode fieldLocation;
|
||||||
@@ -38,8 +37,9 @@ public class AddSetterAdapter implements Opcodes, Injectable {
|
|||||||
|
|
||||||
private static void addSetter(ClassNode fieldLocation, ClassNode into,
|
private static void addSetter(ClassNode fieldLocation, ClassNode into,
|
||||||
FieldNode field, String name, String desc, boolean methodStatic) {
|
FieldNode field, String name, String desc, boolean methodStatic) {
|
||||||
if (desc.contains("L") && !desc.endsWith("Ljava/lang/String;"))
|
if (desc.contains("L") && !desc.endsWith("Ljava/lang/String;")) {
|
||||||
desc = "Ljava/lang/Object;";
|
desc = "Ljava/lang/Object;";
|
||||||
|
}
|
||||||
MethodNode method = new MethodNode(ACC_PUBLIC
|
MethodNode method = new MethodNode(ACC_PUBLIC
|
||||||
| (methodStatic ? ACC_STATIC : 0), name, "(" + desc + ")V",
|
| (methodStatic ? ACC_STATIC : 0), name, "(" + desc + ")V",
|
||||||
null, null);
|
null, null);
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package org.parabot.core.asm.adapters;
|
package org.parabot.core.asm.adapters;
|
||||||
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
@@ -11,12 +9,12 @@ import org.parabot.core.Core;
|
|||||||
import org.parabot.core.asm.ASMUtils;
|
import org.parabot.core.asm.ASMUtils;
|
||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* This class is used for changing the super class of a class
|
* This class is used for changing the super class of a class
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class AddSuperAdapter implements Injectable {
|
public class AddSuperAdapter implements Injectable {
|
||||||
private ClassNode node;
|
private ClassNode node;
|
||||||
@@ -32,12 +30,6 @@ public class AddSuperAdapter implements Injectable {
|
|||||||
this.superClass = superClass;
|
this.superClass = superClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void inject() {
|
|
||||||
Core.verbose("Injecting: " + this.toString());
|
|
||||||
setSuper(node, superClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final void setSuper(final ClassNode node,
|
private static final void setSuper(final ClassNode node,
|
||||||
final String superClass) {
|
final String superClass) {
|
||||||
ListIterator<?> mli = node.methods.listIterator();
|
ListIterator<?> mli = node.methods.listIterator();
|
||||||
@@ -49,7 +41,7 @@ public class AddSuperAdapter implements Injectable {
|
|||||||
AbstractInsnNode ain = (AbstractInsnNode) ili.next();
|
AbstractInsnNode ain = (AbstractInsnNode) ili.next();
|
||||||
if (ain.getOpcode() == Opcodes.INVOKESPECIAL) {
|
if (ain.getOpcode() == Opcodes.INVOKESPECIAL) {
|
||||||
MethodInsnNode min = (MethodInsnNode) ain;
|
MethodInsnNode min = (MethodInsnNode) ain;
|
||||||
if(!min.owner.equals(node.name)) {
|
if (!min.owner.equals(node.name)) {
|
||||||
min.owner = superClass;
|
min.owner = superClass;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -60,6 +52,12 @@ public class AddSuperAdapter implements Injectable {
|
|||||||
node.superName = superClass;
|
node.superName = superClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inject() {
|
||||||
|
Core.verbose("Injecting: " + this.toString());
|
||||||
|
setSuper(node, superClass);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new StringBuilder("[Injectable: super, class name: ")
|
return new StringBuilder("[Injectable: super, class name: ")
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package org.parabot.core.asm.hooks;
|
package org.parabot.core.asm.hooks;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import org.parabot.core.parsers.hooks.HookParser;
|
import org.parabot.core.parsers.hooks.HookParser;
|
||||||
import org.parabot.core.parsers.hooks.JSONHookParser;
|
import org.parabot.core.parsers.hooks.JSONHookParser;
|
||||||
import org.parabot.core.parsers.hooks.XMLHookParser;
|
import org.parabot.core.parsers.hooks.XMLHookParser;
|
||||||
import org.parabot.environment.api.utils.WebUtil;
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
public class HookFile {
|
public class HookFile {
|
||||||
public static final int TYPE_XML = 0;
|
public static final int TYPE_XML = 0;
|
||||||
public static final int TYPE_JSON = 1;
|
public static final int TYPE_JSON = 1;
|
||||||
@@ -27,7 +27,7 @@ public class HookFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setType(int type) {
|
private void setType(int type) {
|
||||||
if(type < 0 || type > 1) {
|
if (type < 0 || type > 1) {
|
||||||
throw new IllegalArgumentException("This type does not exist");
|
throw new IllegalArgumentException("This type does not exist");
|
||||||
}
|
}
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@@ -38,7 +38,7 @@ public class HookFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HookParser getParser() {
|
public HookParser getParser() {
|
||||||
switch(type) {
|
switch (type) {
|
||||||
case TYPE_XML:
|
case TYPE_XML:
|
||||||
return new XMLHookParser(this);
|
return new XMLHookParser(this);
|
||||||
case TYPE_JSON:
|
case TYPE_JSON:
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package org.parabot.core.asm.interfaces;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injectable
|
* Injectable
|
||||||
* @author Everel
|
|
||||||
*
|
*
|
||||||
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public interface Injectable {
|
public interface Injectable {
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ public class ClassLoaderRedirect extends ClassLoader {
|
|||||||
|
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
|
|
||||||
public static Class<?>loadClass(ClassLoader c,String name){
|
public static Class<?> loadClass(ClassLoader c, String name) {
|
||||||
throw RedirectClassAdapter.createSecurityException();
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClassLoader getParent(ClassLoader c){
|
public static ClassLoader getParent(ClassLoader c) {
|
||||||
throw RedirectClassAdapter.createSecurityException();
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,22 @@ import java.io.InputStream;
|
|||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
|
import java.security.ProtectionDomain;
|
||||||
|
|
||||||
public class ClassRedirect {
|
public class ClassRedirect {
|
||||||
|
|
||||||
|
public static ProtectionDomain getProtectionDomain(final Class<?> clazz) {
|
||||||
|
System.err.println(clazz.getName() + " getProtectionDomain request granted.");
|
||||||
|
|
||||||
|
return AccessController.doPrivileged(new PrivilegedAction<ProtectionDomain>() {
|
||||||
|
public ProtectionDomain run() {
|
||||||
|
return clazz.getProtectionDomain();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static Object newInstance(Class<?> c) throws IllegalAccessException, InstantiationException {
|
public static Object newInstance(Class<?> c) throws IllegalAccessException, InstantiationException {
|
||||||
if (validStack()) {
|
if (validStack()) {
|
||||||
return c.newInstance();
|
return c.newInstance();
|
||||||
@@ -136,9 +149,10 @@ public class ClassRedirect {
|
|||||||
private static boolean validStack() {
|
private static boolean validStack() {
|
||||||
Exception e = new Exception();
|
Exception e = new Exception();
|
||||||
for (StackTraceElement elem : e.getStackTrace()) {
|
for (StackTraceElement elem : e.getStackTrace()) {
|
||||||
if (elem.getClassName().equals(Script.class.getName()))
|
if (elem.getClassName().equals(Script.class.getName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.util.ArrayList;
|
|||||||
/**
|
/**
|
||||||
* @author JKetelaar
|
* @author JKetelaar
|
||||||
*/
|
*/
|
||||||
public class FileRedirect extends File{
|
public class FileRedirect extends File {
|
||||||
|
|
||||||
private static ArrayList<String> cachedFiles = new ArrayList<>();
|
private static ArrayList<String> cachedFiles = new ArrayList<>();
|
||||||
|
|
||||||
@@ -35,57 +35,57 @@ public class FileRedirect extends File{
|
|||||||
sout(uri.toString());
|
sout(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean exists(File file){
|
public static boolean exists(File file) {
|
||||||
sout(file.toString());
|
sout(file.toString());
|
||||||
return file.exists();
|
return file.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFile(File file){
|
public static boolean isFile(File file) {
|
||||||
sout(file.toString());
|
sout(file.toString());
|
||||||
return file.isFile();
|
return file.isFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long length(File file){
|
public static long length(File file) {
|
||||||
sout(file.toString());
|
sout(file.toString());
|
||||||
return file.length();
|
return file.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean mkdirs(File file){
|
public static boolean mkdirs(File file) {
|
||||||
sout(file.toString());
|
sout(file.toString());
|
||||||
return file.mkdirs();
|
return file.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean mkdir(File file){
|
public static boolean mkdir(File file) {
|
||||||
sout(file.toString());
|
sout(file.toString());
|
||||||
return file.mkdir();
|
return file.mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDirectory(File file){
|
public static boolean isDirectory(File file) {
|
||||||
sout(file.toString());
|
sout(file.toString());
|
||||||
return file.isDirectory();
|
return file.isDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAbsolutePath(File file){
|
public static String getAbsolutePath(File file) {
|
||||||
sout(file.toString());
|
sout(file.toString());
|
||||||
return file.getAbsolutePath();
|
return file.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getAbsoluteFile(File file){
|
public static File getAbsoluteFile(File file) {
|
||||||
sout(file.toString());
|
sout(file.toString());
|
||||||
return file.getAbsoluteFile();
|
return file.getAbsoluteFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File[] listFiles(File file){
|
public static File[] listFiles(File file) {
|
||||||
sout(file.toString());
|
sout(file.toString());
|
||||||
return file.listFiles();
|
return file.listFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName(File file){
|
public static String getName(File file) {
|
||||||
sout(file.getName());
|
sout(file.getName());
|
||||||
return file.getName();
|
return file.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sout(String s){
|
private static void sout(String s) {
|
||||||
if (!cachedFiles.contains(s)) {
|
if (!cachedFiles.contains(s)) {
|
||||||
Core.verbose("Server requested file: " + s);
|
Core.verbose("Server requested file: " + s);
|
||||||
cachedFiles.add(s);
|
cachedFiles.add(s);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package org.parabot.core.asm.redirect;
|
|||||||
|
|
||||||
public class PacketCallback {
|
public class PacketCallback {
|
||||||
|
|
||||||
public static void onPacket(String methodName,int value){
|
public static void onPacket(String methodName, int value) {
|
||||||
System.out.println(methodName + "(" + value + ")");
|
System.out.println(methodName + "(" + value + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.parabot.core.asm.redirect;
|
package org.parabot.core.asm.redirect;
|
||||||
|
|
||||||
import org.parabot.core.Core;
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.Directories;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|||||||
@@ -1,66 +1,64 @@
|
|||||||
package org.parabot.core.asm.redirect;
|
package org.parabot.core.asm.redirect;
|
||||||
|
|
||||||
import org.parabot.core.Core;
|
|
||||||
import org.parabot.core.asm.RedirectClassAdapter;
|
import org.parabot.core.asm.RedirectClassAdapter;
|
||||||
|
|
||||||
public class ThreadRedirect {
|
public class ThreadRedirect {
|
||||||
|
|
||||||
private static int count = 0;
|
private static int count = 0;
|
||||||
|
|
||||||
public static void start(Thread t){
|
public static void start(Thread t) {
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPriority(Thread t,int i){
|
public static void setPriority(Thread t, int i) {
|
||||||
t.setPriority(i);
|
t.setPriority(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDaemon(Thread t,boolean b){
|
public static void setDaemon(Thread t, boolean b) {
|
||||||
t.setDaemon(b);
|
t.setDaemon(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void interrupt(Thread t){
|
public static void interrupt(Thread t) {
|
||||||
t.interrupt();
|
t.interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Thread currentThread(){
|
public static Thread currentThread() {
|
||||||
return null;
|
return new Thread();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void join(Thread t) throws InterruptedException{
|
public static void join(Thread t) throws InterruptedException {
|
||||||
t.join();
|
t.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void join(Thread t,long l) throws InterruptedException{
|
public static void join(Thread t, long l) throws InterruptedException {
|
||||||
t.join(l);
|
t.join(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void join(Thread t, long l,int i) throws InterruptedException{
|
public static void join(Thread t, long l, int i) throws InterruptedException {
|
||||||
t.join(l, i);
|
t.join(l, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClassLoader getContextClassLoader(Thread t){
|
public static ClassLoader getContextClassLoader(Thread t) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ThreadGroup getThreadGroup(Thread t){
|
public static ThreadGroup getThreadGroup(Thread t) {
|
||||||
throw RedirectClassAdapter.createSecurityException();
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setName(Thread t, String name){
|
public static void setName(Thread t, String name) {
|
||||||
t.setName(name);
|
t.setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName(Thread t){
|
public static String getName(Thread t) {
|
||||||
return t.getName();
|
return t.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sleep(long time) throws InterruptedException{
|
public static void sleep(long time) throws InterruptedException {
|
||||||
Thread.sleep(time);
|
Thread.sleep(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setUncaughtExceptionHandler(Thread t, Thread.UncaughtExceptionHandler handler) {
|
||||||
public static void setUncaughtExceptionHandler(Thread t, Thread.UncaughtExceptionHandler handler){
|
|
||||||
t.setUncaughtExceptionHandler(handler);
|
t.setUncaughtExceptionHandler(handler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.awt.datatransfer.Clipboard;
|
|||||||
import java.awt.datatransfer.DataFlavor;
|
import java.awt.datatransfer.DataFlavor;
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||||
|
import java.awt.image.ImageProducer;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ public class ToolkitRedirect {
|
|||||||
|
|
||||||
private static final Clipboard clipboard = new Clipboard("default");
|
private static final Clipboard clipboard = new Clipboard("default");
|
||||||
|
|
||||||
static{
|
static {
|
||||||
clipboard.setContents(new Transferable() {
|
clipboard.setContents(new Transferable() {
|
||||||
@Override
|
@Override
|
||||||
public DataFlavor[] getTransferDataFlavors() {
|
public DataFlavor[] getTransferDataFlavors() {
|
||||||
@@ -31,43 +32,47 @@ public class ToolkitRedirect {
|
|||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Toolkit getDefaultToolkit(){
|
public static Toolkit getDefaultToolkit() {
|
||||||
return Toolkit.getDefaultToolkit();
|
return Toolkit.getDefaultToolkit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dimension getScreenSize(Toolkit t){
|
public static Dimension getScreenSize(Toolkit t) {
|
||||||
return new Dimension(0,0);
|
return new Dimension(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image createImage(Toolkit t,byte[] b){
|
public static Image createImage(Toolkit t, byte[] b) {
|
||||||
return null;
|
return t.createImage(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image createImage(Toolkit t, String s){
|
public static Image createImage(Toolkit t, String s) {
|
||||||
return null;
|
return t.createImage(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image getImage(Toolkit t,URL u){
|
public static Image createImage(Toolkit t, ImageProducer i) {
|
||||||
|
return t.createImage(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Image getImage(Toolkit t, URL u) {
|
||||||
return t.getImage(u);
|
return t.getImage(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image getImage(Toolkit t,String str){
|
public static Image getImage(Toolkit t, String str) {
|
||||||
return t.getImage(str);
|
return t.getImage(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Cursor createCustomCursor(Toolkit t, Image i, Point p, String s){
|
public static Cursor createCustomCursor(Toolkit t, Image i, Point p, String s) {
|
||||||
return Cursor.getDefaultCursor();
|
return Cursor.getDefaultCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Clipboard getSystemClipboard(Toolkit toolkit){
|
public static Clipboard getSystemClipboard(Toolkit toolkit) {
|
||||||
return clipboard;
|
return clipboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sync(Toolkit toolkit){
|
public static void sync(Toolkit toolkit) {
|
||||||
toolkit.sync();
|
toolkit.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sync(){
|
public static void sync() {
|
||||||
Toolkit.getDefaultToolkit().sync();
|
Toolkit.getDefaultToolkit().sync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ package org.parabot.core.asm.redirect;
|
|||||||
/**
|
/**
|
||||||
* @author JKetelaar
|
* @author JKetelaar
|
||||||
*/
|
*/
|
||||||
public class URLRedirect{
|
public class URLRedirect {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,9 @@ import org.parabot.core.asm.adapters.AddCallbackAdapter;
|
|||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* This class is used for injecting a callback into a methodnode
|
* This class is used for injecting a callback into a methodnode
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Callback implements Injectable {
|
public class Callback implements Injectable {
|
||||||
private MethodNode method;
|
private MethodNode method;
|
||||||
@@ -35,7 +33,7 @@ public class Callback implements Injectable {
|
|||||||
this.args[i] = Integer.parseInt(strArgs[i]);
|
this.args[i] = Integer.parseInt(strArgs[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.args = new int[] { Integer.parseInt(args) };
|
this.args = new int[]{ Integer.parseInt(args) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,9 @@ import org.parabot.core.asm.adapters.AddGetterAdapter;
|
|||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* This class injects a getter which gets a specific field
|
* This class injects a getter which gets a specific field
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Getter implements Injectable {
|
public class Getter implements Injectable {
|
||||||
private ClassNode into;
|
private ClassNode into;
|
||||||
@@ -24,7 +22,6 @@ public class Getter implements Injectable {
|
|||||||
private long multiplier;
|
private long multiplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param into - classnode to inject getter method in
|
* @param into - classnode to inject getter method in
|
||||||
* @param fieldLocation - classnode where field is located
|
* @param fieldLocation - classnode where field is located
|
||||||
* @param fieldNode - field name to get
|
* @param fieldNode - field name to get
|
||||||
@@ -48,7 +45,6 @@ public class Getter implements Injectable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param fieldLocation
|
* @param fieldLocation
|
||||||
* @param fieldNode
|
* @param fieldNode
|
||||||
* @param methodName
|
* @param methodName
|
||||||
@@ -64,6 +60,7 @@ public class Getter implements Injectable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Short route for getAdaptar().inject();
|
* Short route for getAdaptar().inject();
|
||||||
|
*
|
||||||
* @see AddGetterAdapter#inject
|
* @see AddGetterAdapter#inject
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -73,6 +70,7 @@ public class Getter implements Injectable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the AddGetterAdapter
|
* Gets the AddGetterAdapter
|
||||||
|
*
|
||||||
* @return AddGetterAdapter
|
* @return AddGetterAdapter
|
||||||
*/
|
*/
|
||||||
public AddGetterAdapter getAdapter() {
|
public AddGetterAdapter getAdapter() {
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
|||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* This class appends an interface to a class
|
* This class appends an interface to a class
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Interface implements Injectable {
|
public class Interface implements Injectable {
|
||||||
private String className;
|
private String className;
|
||||||
@@ -30,6 +28,7 @@ public class Interface implements Injectable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the add interface adapter
|
* Gets the add interface adapter
|
||||||
|
*
|
||||||
* @return AddInterface adapter
|
* @return AddInterface adapter
|
||||||
*/
|
*/
|
||||||
public AddInterfaceAdapter getAdapter() {
|
public AddInterfaceAdapter getAdapter() {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.parabot.core.asm.wrappers;
|
package org.parabot.core.asm.wrappers;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
import org.objectweb.asm.tree.MethodNode;
|
||||||
import org.parabot.core.asm.ASMUtils;
|
import org.parabot.core.asm.ASMUtils;
|
||||||
@@ -7,11 +8,9 @@ import org.parabot.core.asm.adapters.AddInvokerAdapter;
|
|||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* This class is used for injecting an invoker into a methodnode
|
* This class is used for injecting an invoker into a methodnode
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Invoker implements Injectable {
|
public class Invoker implements Injectable {
|
||||||
private ClassNode into;
|
private ClassNode into;
|
||||||
@@ -37,7 +36,7 @@ public class Invoker implements Injectable {
|
|||||||
String argsDesc, String returnDesc, String methodName, boolean isInterface, String instanceCast, String argsCheckCastDesc) {
|
String argsDesc, String returnDesc, String methodName, boolean isInterface, String instanceCast, String argsCheckCastDesc) {
|
||||||
this.into = ASMUtils.getClass(into);
|
this.into = ASMUtils.getClass(into);
|
||||||
this.methodLocation = ASMUtils.getClass(methodLoc);
|
this.methodLocation = ASMUtils.getClass(methodLoc);
|
||||||
this.mn = getMethod(this.methodLocation, invMethName, argsDesc);
|
this.mn = getMethod(this.methodLocation, invMethName, argsDesc, returnDesc);
|
||||||
this.returnDesc = returnDesc;
|
this.returnDesc = returnDesc;
|
||||||
this.methodName = methodName;
|
this.methodName = methodName;
|
||||||
this.argsDesc = argsDesc;
|
this.argsDesc = argsDesc;
|
||||||
@@ -49,12 +48,12 @@ public class Invoker implements Injectable {
|
|||||||
this.argsCheckCastDesc = argsCheckCastDesc;
|
this.argsCheckCastDesc = argsCheckCastDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MethodNode getMethod(ClassNode into, String name, String desc) {
|
private static MethodNode getMethod(ClassNode into, String name, String argsDesc, String returnDesc) {
|
||||||
for (Object m : into.methods) {
|
for (Object method : into.methods) {
|
||||||
MethodNode methodNode = (MethodNode) m;
|
MethodNode m = (MethodNode) method;
|
||||||
String s = methodNode.desc.substring(0, methodNode.desc.indexOf(')') + 1);
|
if (m.name.equals(name) && m.desc.substring(0, m.desc.indexOf(')') + 1).equals(argsDesc)
|
||||||
if (methodNode.name.equals(name) && s.equals(desc)) {
|
&& (returnDesc == null || Type.getType(m.desc).getReturnType().getDescriptor().equals(returnDesc))) {
|
||||||
return methodNode;
|
return m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ import org.parabot.core.asm.adapters.AddSetterAdapter;
|
|||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* This class is used for injecting a setter for a specific field
|
* This class is used for injecting a setter for a specific field
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Setter implements Injectable {
|
public class Setter implements Injectable {
|
||||||
private ClassNode fieldLocation;
|
private ClassNode fieldLocation;
|
||||||
@@ -37,6 +35,7 @@ public class Setter implements Injectable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Short route for getAdaptar().inject();
|
* Short route for getAdaptar().inject();
|
||||||
|
*
|
||||||
* @see AddSetterAdapter#inject
|
* @see AddSetterAdapter#inject
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -46,6 +45,7 @@ public class Setter implements Injectable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the AddGetterAdapter
|
* Gets the AddGetterAdapter
|
||||||
|
*
|
||||||
* @return AddGetterAdapter
|
* @return AddGetterAdapter
|
||||||
*/
|
*/
|
||||||
public AddSetterAdapter getAdapter() {
|
public AddSetterAdapter getAdapter() {
|
||||||
|
|||||||
@@ -2,12 +2,11 @@ package org.parabot.core.asm.wrappers;
|
|||||||
|
|
||||||
import org.parabot.core.asm.adapters.AddSuperAdapter;
|
import org.parabot.core.asm.adapters.AddSuperAdapter;
|
||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* This class is used for changing the super class of a class
|
* This class is used for changing the super class of a class
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Super implements Injectable {
|
public class Super implements Injectable {
|
||||||
private String className;
|
private String className;
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package org.parabot.core.build;
|
package org.parabot.core.build;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Class used for adding urls to the buildpath
|
* Class used for adding urls to the buildpath
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class BuildPath extends org.parabot.api.io.build.BuildPath {
|
public class BuildPath extends org.parabot.api.io.build.BuildPath {
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
package org.parabot.core.classpath;
|
package org.parabot.core.classpath;
|
||||||
|
|
||||||
import java.io.File;
|
import org.objectweb.asm.ClassReader;
|
||||||
import java.io.FileInputStream;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import java.io.FileNotFoundException;
|
import org.objectweb.asm.commons.RemappingClassAdapter;
|
||||||
import java.io.FileOutputStream;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import java.io.IOException;
|
import org.parabot.core.Directories;
|
||||||
import java.io.InputStream;
|
import org.parabot.core.asm.ClassRemapper;
|
||||||
import java.io.OutputStream;
|
import org.parabot.core.asm.RedirectClassAdapter;
|
||||||
|
import org.parabot.core.build.BuildPath;
|
||||||
|
import org.parabot.core.io.SizeInputStream;
|
||||||
|
import org.parabot.core.ui.components.VerboseLoader;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
@@ -20,17 +25,6 @@ import java.util.jar.JarOutputStream;
|
|||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.commons.RemappingClassAdapter;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
import org.parabot.core.Directories;
|
|
||||||
import org.parabot.core.asm.ClassRemapper;
|
|
||||||
import org.parabot.core.asm.RedirectClassAdapter;
|
|
||||||
import org.parabot.core.build.BuildPath;
|
|
||||||
import org.parabot.core.io.SizeInputStream;
|
|
||||||
import org.parabot.core.ui.components.VerboseLoader;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages, parses and dumps class files & jars
|
* Manages, parses and dumps class files & jars
|
||||||
*
|
*
|
||||||
@@ -47,7 +41,6 @@ public class ClassPath {
|
|||||||
private boolean parseJar;
|
private boolean parseJar;
|
||||||
private ArrayList<URL> jarFiles;
|
private ArrayList<URL> jarFiles;
|
||||||
|
|
||||||
|
|
||||||
public ClassPath() {
|
public ClassPath() {
|
||||||
this(false);
|
this(false);
|
||||||
}
|
}
|
||||||
@@ -92,8 +85,9 @@ public class ClassPath {
|
|||||||
final ZipInputStream zin = new ZipInputStream(sizeInputStream);
|
final ZipInputStream zin = new ZipInputStream(sizeInputStream);
|
||||||
ZipEntry e;
|
ZipEntry e;
|
||||||
while ((e = zin.getNextEntry()) != null) {
|
while ((e = zin.getNextEntry()) != null) {
|
||||||
if (e.isDirectory())
|
if (e.isDirectory()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (e.getName().endsWith(".class")) {
|
if (e.getName().endsWith(".class")) {
|
||||||
loadClass(zin);
|
loadClass(zin);
|
||||||
} else {
|
} else {
|
||||||
@@ -108,13 +102,10 @@ public class ClassPath {
|
|||||||
VerboseLoader.get().onProgressUpdate(100);
|
VerboseLoader.get().onProgressUpdate(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a jar to this classpath
|
* Adds a jar to this classpath
|
||||||
*
|
*
|
||||||
* @param url
|
* @param url - in string format
|
||||||
* - in string format
|
|
||||||
*/
|
*/
|
||||||
public void addJar(final String url) {
|
public void addJar(final String url) {
|
||||||
try {
|
try {
|
||||||
@@ -135,10 +126,11 @@ public class ClassPath {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds and loads all classes/jar files in folder
|
* Finds and loads all classes/jar files in folder
|
||||||
|
*
|
||||||
* @param directory
|
* @param directory
|
||||||
*/
|
*/
|
||||||
public void addClasses(final File directory) {
|
public void addClasses(final File directory) {
|
||||||
if(directory == null || !directory.isDirectory()) {
|
if (directory == null || !directory.isDirectory()) {
|
||||||
throw new IllegalArgumentException("Not a valid directory.");
|
throw new IllegalArgumentException("Not a valid directory.");
|
||||||
}
|
}
|
||||||
addClasses(directory, null);
|
addClasses(directory, null);
|
||||||
@@ -147,13 +139,13 @@ public class ClassPath {
|
|||||||
/**
|
/**
|
||||||
* Finds and loads all classes/jar files in folder
|
* Finds and loads all classes/jar files in folder
|
||||||
*
|
*
|
||||||
* @param f
|
* @param f to find class / jar files
|
||||||
* to find class / jar files
|
|
||||||
* @param root
|
* @param root
|
||||||
*/
|
*/
|
||||||
public void addClasses(final File f, File root) {
|
public void addClasses(final File f, File root) {
|
||||||
if (f == null)
|
if (f == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (!f.exists()) {
|
if (!f.exists()) {
|
||||||
f.mkdirs();
|
f.mkdirs();
|
||||||
}
|
}
|
||||||
@@ -167,9 +159,9 @@ public class ClassPath {
|
|||||||
addClasses(f1, root);
|
addClasses(f1, root);
|
||||||
} else {
|
} else {
|
||||||
try (FileInputStream fin = new FileInputStream(f1)) {
|
try (FileInputStream fin = new FileInputStream(f1)) {
|
||||||
if (f1.getName().endsWith(".class"))
|
if (f1.getName().endsWith(".class")) {
|
||||||
loadClass(fin);
|
loadClass(fin);
|
||||||
else if (f.equals(root) && f1.getName().endsWith(".jar")) {
|
} else if (f.equals(root) && f1.getName().endsWith(".jar")) {
|
||||||
jarFiles.add(f1.toURI().toURL());
|
jarFiles.add(f1.toURI().toURL());
|
||||||
if (this.parseJar) {
|
if (this.parseJar) {
|
||||||
// if enabled, there may be problem with duplicate
|
// if enabled, there may be problem with duplicate
|
||||||
@@ -192,20 +184,19 @@ public class ClassPath {
|
|||||||
* Loads class from input stream
|
* Loads class from input stream
|
||||||
*
|
*
|
||||||
* @param in
|
* @param in
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
protected void loadClass(InputStream in) throws IOException {
|
protected void loadClass(InputStream in) throws IOException {
|
||||||
ClassReader cr = new ClassReader(in);
|
ClassReader cr = new ClassReader(in);
|
||||||
ClassNode cn = new ClassNode();
|
ClassNode cn = new ClassNode();
|
||||||
RemappingClassAdapter rca = new RemappingClassAdapter(cn,classRemapper);
|
RemappingClassAdapter rca = new RemappingClassAdapter(cn, classRemapper);
|
||||||
RedirectClassAdapter redir = new RedirectClassAdapter(rca);
|
RedirectClassAdapter redir = new RedirectClassAdapter(rca);
|
||||||
cr.accept(redir, ClassReader.EXPAND_FRAMES);
|
cr.accept(redir, ClassReader.EXPAND_FRAMES);
|
||||||
classNames.add(cn.name.replace('/', '.'));
|
classNames.add(cn.name.replace('/', '.'));
|
||||||
classes.put(cn.name, cn);
|
classes.put(cn.name, cn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if this classpath represents a jar file
|
* Determines if this classpath represents a jar file
|
||||||
*
|
*
|
||||||
@@ -236,6 +227,7 @@ public class ClassPath {
|
|||||||
* @param classPath
|
* @param classPath
|
||||||
* @param name
|
* @param name
|
||||||
* @param inputstream
|
* @param inputstream
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void loadResource(final String name, final InputStream in)
|
private void loadResource(final String name, final InputStream in)
|
||||||
@@ -246,8 +238,9 @@ public class ClassPath {
|
|||||||
try (OutputStream out = new FileOutputStream(f)) {
|
try (OutputStream out = new FileOutputStream(f)) {
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
int len;
|
int len;
|
||||||
while ((len = in.read(buffer)) != -1)
|
while ((len = in.read(buffer)) != -1) {
|
||||||
out.write(buffer, 0, len);
|
out.write(buffer, 0, len);
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
this.resources.put(name, f);
|
this.resources.put(name, f);
|
||||||
@@ -284,6 +277,7 @@ public class ClassPath {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Dumps this classPath classes to a jar file
|
* Dumps this classPath classes to a jar file
|
||||||
|
*
|
||||||
* @param stream
|
* @param stream
|
||||||
*/
|
*/
|
||||||
public void dump(final FileOutputStream stream) {
|
public void dump(final FileOutputStream stream) {
|
||||||
@@ -296,7 +290,7 @@ public class ClassPath {
|
|||||||
cn.accept(cw);
|
cn.accept(cw);
|
||||||
out.write(cw.toByteArray());
|
out.write(cw.toByteArray());
|
||||||
}
|
}
|
||||||
for(Entry<String, File> entry : this.resources.entrySet()) {
|
for (Entry<String, File> entry : this.resources.entrySet()) {
|
||||||
JarEntry je = new JarEntry(entry.getKey());
|
JarEntry je = new JarEntry(entry.getKey());
|
||||||
out.putNextEntry(je);
|
out.putNextEntry(je);
|
||||||
out.write(Files.readAllBytes(entry.getValue().toPath()));
|
out.write(Files.readAllBytes(entry.getValue().toPath()));
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ package org.parabot.core.desc;
|
|||||||
* Holds information about a script
|
* Holds information about a script
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ScriptDescription implements Comparable<ScriptDescription> {
|
public class ScriptDescription implements Comparable<ScriptDescription> {
|
||||||
public String scriptName;
|
public String scriptName;
|
||||||
@@ -109,7 +108,7 @@ public class ScriptDescription implements Comparable<ScriptDescription> {
|
|||||||
.append(this.category).append(", version: ")
|
.append(this.category).append(", version: ")
|
||||||
.append(this.version).append(", description: ")
|
.append(this.version).append(", description: ")
|
||||||
.append(this.description).append(", servers: ");
|
.append(this.description).append(", servers: ");
|
||||||
if(this.servers != null) {
|
if (this.servers != null) {
|
||||||
for (int i = 0; i < this.servers.length; i++) {
|
for (int i = 0; i < this.servers.length; i++) {
|
||||||
b.append(this.servers[i]);
|
b.append(this.servers[i]);
|
||||||
if (i < (this.servers.length - 1)) {
|
if (i < (this.servers.length - 1)) {
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package org.parabot.core.desc;
|
package org.parabot.core.desc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Holds information about a server
|
* Holds information about a server
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ServerDescription implements Comparable<ServerDescription> {
|
public class ServerDescription implements Comparable<ServerDescription> {
|
||||||
private String serverName;
|
private String serverName;
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package org.parabot.core.desc;
|
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.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
import org.parabot.core.Configuration;
|
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.environment.api.utils.WebUtil;
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@@ -22,7 +19,6 @@ import java.util.zip.CRC32;
|
|||||||
* Gets the information for the selected server provider
|
* Gets the information for the selected server provider
|
||||||
*
|
*
|
||||||
* @author Paradox, Everel
|
* @author Paradox, Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ServerProviderInfo {
|
public class ServerProviderInfo {
|
||||||
|
|
||||||
@@ -39,10 +35,10 @@ public class ServerProviderInfo {
|
|||||||
JSONObject jsonObject = (JSONObject) WebUtil.getJsonParser().parse(br);
|
JSONObject jsonObject = (JSONObject) WebUtil.getJsonParser().parse(br);
|
||||||
for (Object o : jsonObject.entrySet()) {
|
for (Object o : jsonObject.entrySet()) {
|
||||||
Map.Entry<?, ?> pairs = (Map.Entry<?, ?>) o;
|
Map.Entry<?, ?> pairs = (Map.Entry<?, ?>) o;
|
||||||
if (String.valueOf(pairs.getKey()).equalsIgnoreCase("settings")){
|
if (String.valueOf(pairs.getKey()).equalsIgnoreCase("settings")) {
|
||||||
JSONObject object = (JSONObject) pairs.getValue();
|
JSONObject object = (JSONObject) pairs.getValue();
|
||||||
parseSettings(object);
|
parseSettings(object);
|
||||||
}else {
|
} else {
|
||||||
properties.put(String.valueOf(pairs.getKey()), String.valueOf(pairs.getValue()));
|
properties.put(String.valueOf(pairs.getKey()), String.valueOf(pairs.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +50,7 @@ public class ServerProviderInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerProviderInfo(String clientJar, String hooks, String name, String clientClass, int bankTabs){
|
public ServerProviderInfo(String clientJar, String hooks, String name, String clientClass, int bankTabs) {
|
||||||
this.properties = new Properties();
|
this.properties = new Properties();
|
||||||
this.settings = new HashMap<>();
|
this.settings = new HashMap<>();
|
||||||
|
|
||||||
@@ -75,15 +71,15 @@ public class ServerProviderInfo {
|
|||||||
this.properties.setProperty("bank_tabs", String.valueOf(bankTabs));
|
this.properties.setProperty("bank_tabs", String.valueOf(bankTabs));
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getCRC32(String name, String type){
|
private long getCRC32(String name, String type) {
|
||||||
CRC32 crc = new CRC32();
|
CRC32 crc = new CRC32();
|
||||||
name += "-" + type;
|
name += "-" + type;
|
||||||
crc.update(name.getBytes());
|
crc.update(name.getBytes());
|
||||||
return crc.getValue();
|
return crc.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseSettings(JSONObject object){
|
private void parseSettings(JSONObject object) {
|
||||||
for (Object settingObject : object.entrySet()){
|
for (Object settingObject : object.entrySet()) {
|
||||||
Map.Entry<?, ?> settingValue = (Map.Entry<?, ?>) settingObject;
|
Map.Entry<?, ?> settingValue = (Map.Entry<?, ?>) settingObject;
|
||||||
String key = (String) settingValue.getKey();
|
String key = (String) settingValue.getKey();
|
||||||
long value = (Long) settingValue.getValue();
|
long value = (Long) settingValue.getValue();
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
package org.parabot.core.forum;
|
package org.parabot.core.forum;
|
||||||
|
|
||||||
import org.parabot.core.Core;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Class which holds parabot forum account user and pass, only specific classes
|
* Class which holds parabot forum account user and pass, only specific classes
|
||||||
* have access to it unless it's a modified version of parabot intended to
|
* have access to it unless it's a modified version of parabot intended to
|
||||||
* steal user information.
|
* steal user information.
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Account {
|
public class Account {
|
||||||
private String username;
|
private String username;
|
||||||
@@ -20,7 +16,6 @@ public class Account {
|
|||||||
private String api;
|
private String api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param username - Forum account username
|
* @param username - Forum account username
|
||||||
* @param password - Forum account password
|
* @param password - Forum account password
|
||||||
*/
|
*/
|
||||||
@@ -37,6 +32,7 @@ public class Account {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets user's parabot account name
|
* Gets user's parabot account name
|
||||||
|
*
|
||||||
* @return username.
|
* @return username.
|
||||||
*/
|
*/
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
@@ -45,6 +41,7 @@ public class Account {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets user's parabot password
|
* Gets user's parabot password
|
||||||
|
*
|
||||||
* @return password.
|
* @return password.
|
||||||
*/
|
*/
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
@@ -53,9 +50,10 @@ public class Account {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets user's parabot account name
|
* Gets user's parabot account name
|
||||||
|
*
|
||||||
* @return username, already URL UTF-8 encoded.
|
* @return username, already URL UTF-8 encoded.
|
||||||
*/
|
*/
|
||||||
public String getURLUsername(){
|
public String getURLUsername() {
|
||||||
try {
|
try {
|
||||||
return URLEncoder.encode(this.username, "UTF-8");
|
return URLEncoder.encode(this.username, "UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
@@ -66,9 +64,10 @@ public class Account {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets user's password
|
* Gets user's password
|
||||||
|
*
|
||||||
* @return password, already URL UTF-8 encoded.
|
* @return password, already URL UTF-8 encoded.
|
||||||
*/
|
*/
|
||||||
public String getURLPassword(){
|
public String getURLPassword() {
|
||||||
try {
|
try {
|
||||||
return URLEncoder.encode(this.password, "UTF-8");
|
return URLEncoder.encode(this.password, "UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import java.util.ArrayList;
|
|||||||
* Handles logging in to parabot forum, only certain classes may use this class.
|
* Handles logging in to parabot forum, only certain classes may use this class.
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class AccountManager {
|
public final class AccountManager {
|
||||||
private static boolean validated;
|
private static boolean validated;
|
||||||
@@ -69,7 +68,7 @@ public final class AccountManager {
|
|||||||
throw new IllegalStateException("Already logged in.");
|
throw new IllegalStateException("Already logged in.");
|
||||||
}
|
}
|
||||||
JSONObject result = null;
|
JSONObject result = null;
|
||||||
if (!requestTwoStep){
|
if (!requestTwoStep) {
|
||||||
try {
|
try {
|
||||||
BufferedReader contents = WebUtil.getReader(WebUtil.getConnection(
|
BufferedReader contents = WebUtil.getReader(WebUtil.getConnection(
|
||||||
new URL(Configuration.LOGIN_SERVER),
|
new URL(Configuration.LOGIN_SERVER),
|
||||||
@@ -82,7 +81,7 @@ public final class AccountManager {
|
|||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
try {
|
try {
|
||||||
String two = JOptionPane.showInputDialog("Please provide your two factor authentication code\nYou can find this in either your email or the app you've setup");
|
String two = JOptionPane.showInputDialog("Please provide your two factor authentication code\nYou can find this in either your email or the app you've setup");
|
||||||
if (two != null && two.length() > 0) {
|
if (two != null && two.length() > 0) {
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package org.parabot.core.forum;
|
package org.parabot.core.forum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Gives access to account details
|
* Gives access to account details
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface AccountManagerAccess {
|
public interface AccountManagerAccess {
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package org.parabot.core.io;
|
package org.parabot.core.io;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Keeps track of a progress
|
* Keeps track of a progress
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface ProgressListener extends org.parabot.api.io.ProgressListener{
|
public interface ProgressListener extends org.parabot.api.io.ProgressListener {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class SizeInputStream extends InputStream {
|
public class SizeInputStream extends InputStream {
|
||||||
public int bytesRead;
|
public int bytesRead;
|
||||||
@@ -50,8 +48,8 @@ public class SizeInputStream extends InputStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateListener() {
|
private void updateListener() {
|
||||||
if(l != null) {
|
if (l != null) {
|
||||||
double percent = ( bytesRead / size) * 100.0D;
|
double percent = (bytesRead / size) * 100.0D;
|
||||||
l.onProgressUpdate(percent);
|
l.onProgressUpdate(percent);
|
||||||
|
|
||||||
long curTime = System.currentTimeMillis();
|
long curTime = System.currentTimeMillis();
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package org.parabot.core.lib;
|
package org.parabot.core.lib;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class Library extends org.parabot.api.io.libraries.Library {
|
public abstract class Library extends org.parabot.api.io.libraries.Library {
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
package org.parabot.core.lib.javafx;
|
package org.parabot.core.lib.javafx;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import org.parabot.core.Core;
|
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;
|
import org.parabot.environment.api.utils.JavaUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Jython util class
|
* Jython util class
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class JavaFX extends Library {
|
public class JavaFX extends Library {
|
||||||
private static boolean valid;
|
private static boolean valid;
|
||||||
|
|
||||||
|
public static boolean isValid() {
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
if (!hasJar()) {
|
if (!hasJar()) {
|
||||||
@@ -69,8 +71,4 @@ public class JavaFX extends Library {
|
|||||||
public String getLibraryName() {
|
public String getLibraryName() {
|
||||||
return "JavaFX";
|
return "JavaFX";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isValid() {
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.util.Enumeration;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
public class NetworkInterface {
|
public class NetworkInterface {
|
||||||
public static byte[] mac = new byte[] { 11, 11, 11, 11, 11, 11 };
|
public static byte[] mac = new byte[]{ 11, 11, 11, 11, 11, 11 };
|
||||||
private static byte[] realMac;
|
private static byte[] realMac;
|
||||||
private static NetworkInterface cached;
|
private static NetworkInterface cached;
|
||||||
|
|
||||||
@@ -18,16 +18,13 @@ public class NetworkInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getHardwareAddress() {
|
|
||||||
return mac;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Enumeration<NetworkInterface> getNetworkInterfaces()
|
public static Enumeration<NetworkInterface> getNetworkInterfaces()
|
||||||
throws SocketException {
|
throws SocketException {
|
||||||
final ArrayList<NetworkInterface> netifs = new ArrayList<>();
|
final ArrayList<NetworkInterface> netifs = new ArrayList<>();
|
||||||
|
|
||||||
return new Enumeration<NetworkInterface>() {
|
return new Enumeration<NetworkInterface>() {
|
||||||
private int i = 0;
|
private int i = 0;
|
||||||
|
|
||||||
public NetworkInterface nextElement() {
|
public NetworkInterface nextElement() {
|
||||||
if (i < netifs.size()) {
|
if (i < netifs.size()) {
|
||||||
NetworkInterface netif = netifs.get(i++);
|
NetworkInterface netif = netifs.get(i++);
|
||||||
@@ -43,9 +40,10 @@ public class NetworkInterface {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] getRealHardwareAddress() throws SocketException{
|
public static byte[] getRealHardwareAddress() throws SocketException {
|
||||||
if (realMac != null)
|
if (realMac != null) {
|
||||||
return realMac;
|
return realMac;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return realMac = java.net.NetworkInterface.getByInetAddress(
|
return realMac = java.net.NetworkInterface.getByInetAddress(
|
||||||
InetAddress.getLocalHost()).getHardwareAddress();
|
InetAddress.getLocalHost()).getHardwareAddress();
|
||||||
@@ -55,8 +53,9 @@ public class NetworkInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static NetworkInterface getByInetAddress(InetAddress addr) {
|
public static NetworkInterface getByInetAddress(InetAddress addr) {
|
||||||
if (cached == null)
|
if (cached == null) {
|
||||||
cached = new NetworkInterface();
|
cached = new NetworkInterface();
|
||||||
|
}
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,13 +64,18 @@ public class NetworkInterface {
|
|||||||
mac = mac2;
|
mac = mac2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatMac(byte[] mac){
|
public static String formatMac(byte[] mac) {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
for(int i = 0; i < 6;i++){
|
for (int i = 0; i < 6; i++) {
|
||||||
b.append(String.format("%02X", mac[i]));
|
b.append(String.format("%02X", mac[i]));
|
||||||
if(i < 5)
|
if (i < 5) {
|
||||||
b.append(':');
|
b.append(':');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] getHardwareAddress() {
|
||||||
|
return mac;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,36 +4,41 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class Runtime {
|
public class Runtime {
|
||||||
|
|
||||||
|
private static Runtime cached;
|
||||||
private java.lang.Runtime rt;
|
private java.lang.Runtime rt;
|
||||||
|
|
||||||
private static Runtime cached;
|
private Runtime(java.lang.Runtime rt) {
|
||||||
|
|
||||||
private Runtime(java.lang.Runtime rt){
|
|
||||||
this.rt = rt;
|
this.rt = rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Runtime getRuntime() {
|
||||||
|
if (cached == null) {
|
||||||
|
cached = new Runtime(java.lang.Runtime.getRuntime());
|
||||||
|
}
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
public void addShutdownHook(Thread t){
|
public void addShutdownHook(Thread t) {
|
||||||
rt.addShutdownHook(t);
|
rt.addShutdownHook(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int availableProcessors(){
|
public int availableProcessors() {
|
||||||
return rt.availableProcessors();
|
return rt.availableProcessors();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exit(int i){
|
public void exit(int i) {
|
||||||
rt.exit(i);
|
rt.exit(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Process exec(String str) throws IOException{
|
public Process exec(String str) throws IOException {
|
||||||
System.out.println("RT:" + str);
|
System.out.println("RT:" + str);
|
||||||
System.out.println("RT:" + str);
|
System.out.println("RT:" + str);
|
||||||
return rt.exec(str);
|
return rt.exec(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Process exec(String[] cmdarray) throws IOException{
|
public Process exec(String[] cmdarray) throws IOException {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
for(int i = 0; i < cmdarray.length;i++){
|
for (int i = 0; i < cmdarray.length; i++) {
|
||||||
sb.append(cmdarray[i] + (i < cmdarray.length - 1 ? "," : ""));
|
sb.append(cmdarray[i] + (i < cmdarray.length - 1 ? "," : ""));
|
||||||
}
|
}
|
||||||
System.out.println("RT: {" + sb + "}");
|
System.out.println("RT: {" + sb + "}");
|
||||||
@@ -49,18 +54,12 @@ public class Runtime {
|
|||||||
return rt.totalMemory();
|
return rt.totalMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gc(){
|
public void gc() {
|
||||||
rt.gc();
|
rt.gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long maxMemory(){
|
public long maxMemory() {
|
||||||
return rt.maxMemory();
|
return rt.maxMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Runtime getRuntime(){
|
|
||||||
if(cached == null)
|
|
||||||
cached = new Runtime(java.lang.Runtime.getRuntime());
|
|
||||||
return cached;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,38 +11,16 @@ import java.util.List;
|
|||||||
|
|
||||||
public class ProxySocket extends Socket {
|
public class ProxySocket extends Socket {
|
||||||
|
|
||||||
|
public static boolean auth = false;
|
||||||
private static List<ProxySocket> connections = new ArrayList<ProxySocket>();
|
private static List<ProxySocket> connections = new ArrayList<ProxySocket>();
|
||||||
|
|
||||||
private static ProxyType proxyType = ProxyType.NONE;
|
private static ProxyType proxyType = ProxyType.NONE;
|
||||||
|
|
||||||
private static int proxyPort = 0;
|
private static int proxyPort = 0;
|
||||||
|
private static String username = null, password = null;
|
||||||
|
private static InetAddress proxyInetAddress = null;
|
||||||
private InetAddress addr;
|
private InetAddress addr;
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
private static String username = null, password = null;
|
|
||||||
|
|
||||||
public static boolean auth = false;
|
|
||||||
|
|
||||||
private static InetAddress proxyInetAddress = null;
|
|
||||||
|
|
||||||
private InetSocketAddress cachedAddr;
|
private InetSocketAddress cachedAddr;
|
||||||
|
|
||||||
public static int closeConnections() {
|
|
||||||
int value = 0;
|
|
||||||
for (ProxySocket socket : connections)
|
|
||||||
try {
|
|
||||||
connections.remove(socket);
|
|
||||||
if (socket.isClosed())
|
|
||||||
continue;
|
|
||||||
socket.close();
|
|
||||||
value++;
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProxySocket(InetAddress addr, int port) throws IOException {
|
public ProxySocket(InetAddress addr, int port) throws IOException {
|
||||||
super(addr, port);
|
super(addr, port);
|
||||||
}
|
}
|
||||||
@@ -55,6 +33,23 @@ public class ProxySocket extends Socket {
|
|||||||
super(host, port);
|
super(host, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int closeConnections() {
|
||||||
|
int value = 0;
|
||||||
|
for (ProxySocket socket : connections) {
|
||||||
|
try {
|
||||||
|
connections.remove(socket);
|
||||||
|
if (socket.isClosed()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
socket.close();
|
||||||
|
value++;
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setProxy(ProxyType type, String host, int port) {
|
public static void setProxy(ProxyType type, String host, int port) {
|
||||||
try {
|
try {
|
||||||
proxyInetAddress = InetAddress.getByName(host);
|
proxyInetAddress = InetAddress.getByName(host);
|
||||||
@@ -77,6 +72,23 @@ public class ProxySocket extends Socket {
|
|||||||
return proxyType;
|
return proxyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setType(ProxyType pt) {
|
||||||
|
proxyType = pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getConnectionCount() {
|
||||||
|
return connections.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLogin(String user, char[] pass) {
|
||||||
|
setLogin(user, new String(pass));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLogin(String user, String pass) {
|
||||||
|
username = user;
|
||||||
|
password = pass;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(SocketAddress addr) throws IOException {
|
public void connect(SocketAddress addr) throws IOException {
|
||||||
connections.add(this);
|
connections.add(this);
|
||||||
@@ -94,9 +106,10 @@ public class ProxySocket extends Socket {
|
|||||||
UILog.log("Proxy Error", e.getMessage(),
|
UILog.log("Proxy Error", e.getMessage(),
|
||||||
JOptionPane.ERROR_MESSAGE);
|
JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
super.connect(addr);
|
super.connect(addr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initProxy() throws IOException {
|
private void initProxy() throws IOException {
|
||||||
System.out.println("Proxying:" + addr + ":" + port + " Over:"
|
System.out.println("Proxying:" + addr + ":" + port + " Over:"
|
||||||
@@ -126,10 +139,12 @@ public class ProxySocket extends Socket {
|
|||||||
out.write("\r\n".getBytes());
|
out.write("\r\n".getBytes());
|
||||||
String str;
|
String str;
|
||||||
while ((str = br.readLine()) != null) {
|
while ((str = br.readLine()) != null) {
|
||||||
if (str.length() == 0)
|
if (str.length() == 0) {
|
||||||
break;
|
break;
|
||||||
if (!str.startsWith("HTTP"))
|
}
|
||||||
|
if (!str.startsWith("HTTP")) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
int code = Integer.parseInt(str.substring(9, 12));
|
int code = Integer.parseInt(str.substring(9, 12));
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 404:
|
case 404:
|
||||||
@@ -140,12 +155,13 @@ public class ProxySocket extends Socket {
|
|||||||
"Proxy doesn't support connecting to port: " + port
|
"Proxy doesn't support connecting to port: " + port
|
||||||
+ "! Try a different proxy.");
|
+ "! Try a different proxy.");
|
||||||
}
|
}
|
||||||
if (code / 100 != 2)
|
if (code / 100 != 2) {
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
"Unable to connect to proxy server! HTTP Error code:"
|
"Unable to connect to proxy server! HTTP Error code:"
|
||||||
+ code);
|
+ code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void socks4_connect() throws IOException {
|
private void socks4_connect() throws IOException {
|
||||||
DataOutputStream out = new DataOutputStream(getOutputStream());
|
DataOutputStream out = new DataOutputStream(getOutputStream());
|
||||||
@@ -155,18 +171,22 @@ public class ProxySocket extends Socket {
|
|||||||
out.write(0x01); // connection type (TCP stream)
|
out.write(0x01); // connection type (TCP stream)
|
||||||
out.writeShort(port);
|
out.writeShort(port);
|
||||||
byte[] b = addr.getAddress();
|
byte[] b = addr.getAddress();
|
||||||
if (b.length != 4)
|
if (b.length != 4) {
|
||||||
throw new IOException("Unsupported IP type for socksv4!");
|
throw new IOException("Unsupported IP type for socksv4!");
|
||||||
|
}
|
||||||
out.write(b);
|
out.write(b);
|
||||||
out.write(0); // the userID stuff, 0 means end of string (null
|
out.write(0); // the userID stuff, 0 means end of string (null
|
||||||
// terminated)
|
// terminated)
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
if (in.read() != 0x00) // null byte
|
if (in.read() != 0x00) // null byte
|
||||||
|
{
|
||||||
throw new IOException("Proxy server dun goofed");
|
throw new IOException("Proxy server dun goofed");
|
||||||
if (in.read() != 0x5a)
|
}
|
||||||
|
if (in.read() != 0x5a) {
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
"Proxy server was unable to connect to server!");
|
"Proxy server was unable to connect to server!");
|
||||||
|
}
|
||||||
|
|
||||||
in.readShort(); // ignored
|
in.readShort(); // ignored
|
||||||
in.readFully(b); // ignored
|
in.readFully(b); // ignored
|
||||||
@@ -184,7 +204,9 @@ public class ProxySocket extends Socket {
|
|||||||
}
|
}
|
||||||
out.flush();
|
out.flush();
|
||||||
if (in.read() != 0x05) // remote proxy version
|
if (in.read() != 0x05) // remote proxy version
|
||||||
|
{
|
||||||
throw new IOException("Proxy server is not supported!");
|
throw new IOException("Proxy server is not supported!");
|
||||||
|
}
|
||||||
switch (in.read()) { // auth method
|
switch (in.read()) { // auth method
|
||||||
case 0:
|
case 0:
|
||||||
break; // no auth
|
break; // no auth
|
||||||
@@ -198,7 +220,9 @@ public class ProxySocket extends Socket {
|
|||||||
out.flush();
|
out.flush();
|
||||||
in.read(); // skip the version
|
in.read(); // skip the version
|
||||||
if (in.read() == 0) // Successful login, continue
|
if (in.read() == 0) // Successful login, continue
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw new IOException("Proxy server declined request!");
|
throw new IOException("Proxy server declined request!");
|
||||||
}
|
}
|
||||||
@@ -217,12 +241,16 @@ public class ProxySocket extends Socket {
|
|||||||
|
|
||||||
// now to read the server's reply
|
// now to read the server's reply
|
||||||
if (in.read() != 0x05) // socks version (again)
|
if (in.read() != 0x05) // socks version (again)
|
||||||
|
{
|
||||||
throw new IOException("Proxy server dun goofed");
|
throw new IOException("Proxy server dun goofed");
|
||||||
|
}
|
||||||
int reply = in.read();
|
int reply = in.read();
|
||||||
if (reply == 0x08)
|
if (reply == 0x08) {
|
||||||
throw new IOException("Bad address sent to proxy server");
|
throw new IOException("Bad address sent to proxy server");
|
||||||
if (reply != 0x00)
|
}
|
||||||
|
if (reply != 0x00) {
|
||||||
throw new IOException("Unable to connect to server!");
|
throw new IOException("Unable to connect to server!");
|
||||||
|
}
|
||||||
in.read(); // reserve byte
|
in.read(); // reserve byte
|
||||||
int addrType = in.read();
|
int addrType = in.read();
|
||||||
b = new byte[4];
|
b = new byte[4];
|
||||||
@@ -242,29 +270,33 @@ public class ProxySocket extends Socket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
if (super.getInetAddress().equals(proxyInetAddress))
|
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||||
return port;
|
return port;
|
||||||
|
}
|
||||||
return super.getPort();
|
return super.getPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InetAddress getInetAddress() {
|
public InetAddress getInetAddress() {
|
||||||
if (super.getInetAddress().equals(proxyInetAddress))
|
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||||
return addr;
|
return addr;
|
||||||
|
}
|
||||||
return super.getInetAddress();
|
return super.getInetAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SocketAddress getRemoteSocketAddress() {
|
public SocketAddress getRemoteSocketAddress() {
|
||||||
if (super.getInetAddress().equals(proxyInetAddress))
|
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||||
return cachedAddr;
|
return cachedAddr;
|
||||||
|
}
|
||||||
return super.getRemoteSocketAddress();
|
return super.getRemoteSocketAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SocketChannel getChannel() {
|
public SocketChannel getChannel() {
|
||||||
if (super.getInetAddress().equals(proxyInetAddress))
|
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
return super.getChannel();
|
return super.getChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,21 +306,4 @@ public class ProxySocket extends Socket {
|
|||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setType(ProxyType pt) {
|
|
||||||
proxyType = pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getConnectionCount() {
|
|
||||||
return connections.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setLogin(String user, char[] pass) {
|
|
||||||
setLogin(user, new String(pass));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setLogin(String user, String pass) {
|
|
||||||
username = user;
|
|
||||||
password = pass;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package org.parabot.core.network.proxy;
|
package org.parabot.core.network.proxy;
|
||||||
|
|
||||||
public enum ProxyType {
|
public enum ProxyType {
|
||||||
NONE,SOCKS5, SOCKS4, HTTP
|
NONE, SOCKS5, SOCKS4, HTTP
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,9 @@ package org.parabot.core.paint;
|
|||||||
import org.parabot.environment.api.interfaces.Paintable;
|
import org.parabot.environment.api.interfaces.Paintable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Abstract class for debugging in game values & more
|
* Abstract class for debugging in game values & more
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractDebugger implements Paintable {
|
public abstract class AbstractDebugger implements Paintable {
|
||||||
|
|
||||||
@@ -17,7 +15,6 @@ public abstract class AbstractDebugger implements Paintable {
|
|||||||
public abstract void toggle();
|
public abstract void toggle();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return True if this debugger is enabled, otherwise false
|
* @return True if this debugger is enabled, otherwise false
|
||||||
*/
|
*/
|
||||||
public abstract boolean isEnabled();
|
public abstract boolean isEnabled();
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
package org.parabot.core.paint;
|
package org.parabot.core.paint;
|
||||||
|
|
||||||
import java.awt.Color;
|
import org.parabot.core.Context;
|
||||||
import java.awt.Graphics;
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Manages and paints on a collection of AbstractDebuggers
|
* Manages and paints on a collection of AbstractDebuggers
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class PaintDebugger {
|
public class PaintDebugger {
|
||||||
private final HashMap<String, AbstractDebugger> debuggers;
|
private final HashMap<String, AbstractDebugger> debuggers;
|
||||||
@@ -24,28 +21,28 @@ public class PaintDebugger {
|
|||||||
this.stringDebug = new LinkedList<String>();
|
this.stringDebug = new LinkedList<String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final PaintDebugger getInstance() {
|
||||||
|
return Context.getInstance().getPaintDebugger();
|
||||||
|
}
|
||||||
|
|
||||||
public final void addDebugger(final String name, final AbstractDebugger debugger) {
|
public final void addDebugger(final String name, final AbstractDebugger debugger) {
|
||||||
debuggers.put(name, debugger);
|
debuggers.put(name, debugger);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void debug(Graphics g) {
|
public void debug(Graphics g) {
|
||||||
for(final AbstractDebugger d : debuggers.values()) {
|
for (final AbstractDebugger d : debuggers.values()) {
|
||||||
if(d.isEnabled()) {
|
if (d.isEnabled()) {
|
||||||
d.paint(g);
|
d.paint(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.setColor(Color.green);
|
g.setColor(Color.green);
|
||||||
int y = 40;
|
int y = 40;
|
||||||
while(stringDebug.size() > 0) {
|
while (stringDebug.size() > 0) {
|
||||||
g.drawString(stringDebug.poll(), 10, y);
|
g.drawString(stringDebug.poll(), 10, y);
|
||||||
y += 15;
|
y += 15;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final PaintDebugger getInstance() {
|
|
||||||
return Context.getInstance().getPaintDebugger();
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void addLine(final String debugLine) {
|
public final void addLine(final String debugLine) {
|
||||||
stringDebug.add(debugLine);
|
stringDebug.add(debugLine);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.parabot.core.parsers.hooks;
|
|||||||
import org.parabot.core.asm.hooks.HookFile;
|
import org.parabot.core.asm.hooks.HookFile;
|
||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
import org.parabot.core.asm.wrappers.*;
|
import org.parabot.core.asm.wrappers.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -15,7 +16,6 @@ import java.util.HashMap;
|
|||||||
*/
|
*/
|
||||||
public abstract class HookParser {
|
public abstract class HookParser {
|
||||||
|
|
||||||
|
|
||||||
public HookParser(HookFile hookFile) {
|
public HookParser(HookFile hookFile) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,18 @@
|
|||||||
package org.parabot.core.parsers.hooks;
|
package org.parabot.core.parsers.hooks;
|
||||||
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
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.asm.adapters.AddInterfaceAdapter;
|
import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
||||||
import org.parabot.core.asm.hooks.HookFile;
|
import org.parabot.core.asm.hooks.HookFile;
|
||||||
import org.parabot.core.asm.wrappers.Callback;
|
import org.parabot.core.asm.wrappers.*;
|
||||||
import org.parabot.core.asm.wrappers.Getter;
|
|
||||||
import org.parabot.core.asm.wrappers.Interface;
|
import java.io.InputStreamReader;
|
||||||
import org.parabot.core.asm.wrappers.Invoker;
|
import java.util.HashMap;
|
||||||
import org.parabot.core.asm.wrappers.Setter;
|
import java.util.Map;
|
||||||
import org.parabot.core.asm.wrappers.Super;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Dane
|
* @author Dane
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class JSONHookParser extends HookParser {
|
public class JSONHookParser extends HookParser {
|
||||||
private JSONObject root;
|
private JSONObject root;
|
||||||
|
|||||||
@@ -1,25 +1,19 @@
|
|||||||
package org.parabot.core.parsers.hooks;
|
package org.parabot.core.parsers.hooks;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
|
|
||||||
import org.parabot.core.Core;
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
||||||
import org.parabot.core.asm.hooks.HookFile;
|
import org.parabot.core.asm.hooks.HookFile;
|
||||||
import org.parabot.core.asm.wrappers.Callback;
|
import org.parabot.core.asm.wrappers.*;
|
||||||
import org.parabot.core.asm.wrappers.Getter;
|
|
||||||
import org.parabot.core.asm.wrappers.Interface;
|
|
||||||
import org.parabot.core.asm.wrappers.Invoker;
|
|
||||||
import org.parabot.core.asm.wrappers.Setter;
|
|
||||||
import org.parabot.core.asm.wrappers.Super;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class XMLHookParser extends HookParser {
|
public class XMLHookParser extends HookParser {
|
||||||
private Document doc;
|
private Document doc;
|
||||||
private HashMap<String, String> interfaceMap;
|
private HashMap<String, String> interfaceMap;
|
||||||
@@ -44,6 +38,39 @@ public class XMLHookParser extends HookParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String resolveDesc(String returnDesc) {
|
||||||
|
String array = "";
|
||||||
|
if (returnDesc != null && returnDesc.contains("%s")) {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
if (returnDesc.startsWith("[")) {
|
||||||
|
for (int i = 0; i < returnDesc.length(); i++) {
|
||||||
|
if (returnDesc.charAt(i) == '[') {
|
||||||
|
array += '[';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
returnDesc = returnDesc.replaceAll("\\[", "");
|
||||||
|
}
|
||||||
|
str.append(array)
|
||||||
|
.append('L')
|
||||||
|
.append(String.format(returnDesc,
|
||||||
|
AddInterfaceAdapter.getAccessorPackage()))
|
||||||
|
.append(";");
|
||||||
|
returnDesc = str.toString();
|
||||||
|
}
|
||||||
|
return returnDesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final boolean isSet(String tag, Element element) {
|
||||||
|
return element.getElementsByTagName(tag).getLength() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String getValue(String tag, Element element) {
|
||||||
|
NodeList nodes = element.getElementsByTagName(tag).item(0)
|
||||||
|
.getChildNodes();
|
||||||
|
Node node = (Node) nodes.item(0);
|
||||||
|
return node.getNodeValue();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Interface[] getInterfaces() {
|
public Interface[] getInterfaces() {
|
||||||
parsedInterfaces = true;
|
parsedInterfaces = true;
|
||||||
@@ -267,40 +294,6 @@ public class XMLHookParser extends HookParser {
|
|||||||
return setterList.toArray(new Setter[setterList.size()]);
|
return setterList.toArray(new Setter[setterList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String resolveDesc(String returnDesc) {
|
|
||||||
String array = "";
|
|
||||||
if (returnDesc != null && returnDesc.contains("%s")) {
|
|
||||||
StringBuilder str = new StringBuilder();
|
|
||||||
if (returnDesc.startsWith("[")) {
|
|
||||||
for (int i = 0; i < returnDesc.length(); i++) {
|
|
||||||
if (returnDesc.charAt(i) == '[') {
|
|
||||||
array += '[';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
returnDesc = returnDesc.replaceAll("\\[", "");
|
|
||||||
}
|
|
||||||
str.append(array)
|
|
||||||
.append('L')
|
|
||||||
.append(String.format(returnDesc,
|
|
||||||
AddInterfaceAdapter.getAccessorPackage()))
|
|
||||||
.append(";");
|
|
||||||
returnDesc = str.toString();
|
|
||||||
}
|
|
||||||
return returnDesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final boolean isSet(String tag, Element element) {
|
|
||||||
return element.getElementsByTagName(tag).getLength() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String getValue(String tag, Element element) {
|
|
||||||
NodeList nodes = element.getElementsByTagName(tag).item(0)
|
|
||||||
.getChildNodes();
|
|
||||||
Node node = (Node) nodes.item(0);
|
|
||||||
return node.getNodeValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Invoker[] getInvokers() {
|
public Invoker[] getInvokers() {
|
||||||
final NodeList invokerRootList = doc.getElementsByTagName("invokers");
|
final NodeList invokerRootList = doc.getElementsByTagName("invokers");
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class PublicRandoms extends RandomParser {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
URL url = myJar.toURI().toURL();
|
URL url = myJar.toURI().toURL();
|
||||||
URL[] urls = new URL[]{url};
|
URL[] urls = new URL[]{ url };
|
||||||
String server = Context.getInstance().getServerProviderInfo().getServerName();
|
String server = Context.getInstance().getServerProviderInfo().getServerName();
|
||||||
|
|
||||||
URLClassLoader child = new URLClassLoader(urls, this.getClass().getClassLoader());
|
URLClassLoader child = new URLClassLoader(urls, this.getClass().getClassLoader());
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package org.parabot.core.parsers.scripts;
|
package org.parabot.core.parsers.scripts;
|
||||||
|
|
||||||
|
import org.parabot.core.Core;
|
||||||
|
import org.parabot.core.desc.ScriptDescription;
|
||||||
|
import org.parabot.environment.scripts.executers.ScriptExecuter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.parabot.core.Core;
|
|
||||||
import org.parabot.core.desc.ScriptDescription;
|
|
||||||
import org.parabot.environment.scripts.executers.ScriptExecuter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for parsing scripts
|
* Abstract class for parsing scripts
|
||||||
*
|
*
|
||||||
@@ -18,8 +18,6 @@ public abstract class ScriptParser {
|
|||||||
|
|
||||||
public static final Map<ScriptDescription, ScriptExecuter> SCRIPT_CACHE = new HashMap<ScriptDescription, ScriptExecuter>();
|
public static final Map<ScriptDescription, ScriptExecuter> SCRIPT_CACHE = new HashMap<ScriptDescription, ScriptExecuter>();
|
||||||
|
|
||||||
public abstract void execute();
|
|
||||||
|
|
||||||
public static ScriptDescription[] getDescriptions() {
|
public static ScriptDescription[] getDescriptions() {
|
||||||
SCRIPT_CACHE.clear();
|
SCRIPT_CACHE.clear();
|
||||||
final ArrayList<ScriptParser> parsers = new ArrayList<ScriptParser>();
|
final ArrayList<ScriptParser> parsers = new ArrayList<ScriptParser>();
|
||||||
@@ -44,9 +42,11 @@ public abstract class ScriptParser {
|
|||||||
Core.verbose("Scripts parsed.");
|
Core.verbose("Scripts parsed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<ScriptDescription, ScriptExecuter> SORTED_SCRIPT_CACHE = new TreeMap<ScriptDescription, ScriptExecuter>( SCRIPT_CACHE );
|
Map<ScriptDescription, ScriptExecuter> SORTED_SCRIPT_CACHE = new TreeMap<ScriptDescription, ScriptExecuter>(SCRIPT_CACHE);
|
||||||
|
|
||||||
return SORTED_SCRIPT_CACHE.keySet().toArray(new ScriptDescription[SORTED_SCRIPT_CACHE.size()]);
|
return SORTED_SCRIPT_CACHE.keySet().toArray(new ScriptDescription[SORTED_SCRIPT_CACHE.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,36 +1,23 @@
|
|||||||
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.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
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.core.Configuration;
|
|
||||||
import org.parabot.core.Context;
|
|
||||||
import org.parabot.core.Core;
|
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.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.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.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.*;
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses local server providers located in the servers directory
|
* Parses local server providers located in the servers directory
|
||||||
@@ -86,7 +73,7 @@ public class LocalServers extends ServerParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (File file : Directories.listJSONFiles(Directories.getServerPath())){
|
for (File file : Directories.listJSONFiles(Directories.getServerPath())) {
|
||||||
Core.verbose("[Local server in]: " + file.getName());
|
Core.verbose("[Local server in]: " + file.getName());
|
||||||
try {
|
try {
|
||||||
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(new FileReader(file));
|
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(new FileReader(file));
|
||||||
@@ -96,7 +83,7 @@ public class LocalServers extends ServerParser {
|
|||||||
String clientClass = (String) object.get("client-class");
|
String clientClass = (String) object.get("client-class");
|
||||||
Object bank;
|
Object bank;
|
||||||
int bankTabs = 0;
|
int bankTabs = 0;
|
||||||
if ((bank = object.get("bank")) != null){
|
if ((bank = object.get("bank")) != null) {
|
||||||
bankTabs = (int) bank;
|
bankTabs = (int) bank;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ import java.util.TreeMap;
|
|||||||
public abstract class ServerParser {
|
public abstract class ServerParser {
|
||||||
public static final Map<ServerDescription, ServerExecuter> SERVER_CACHE = new HashMap<ServerDescription, ServerExecuter>();
|
public static final Map<ServerDescription, ServerExecuter> SERVER_CACHE = new HashMap<ServerDescription, ServerExecuter>();
|
||||||
|
|
||||||
public abstract void execute();
|
|
||||||
|
|
||||||
public static final ServerDescription[] getDescriptions() {
|
public static final ServerDescription[] getDescriptions() {
|
||||||
SERVER_CACHE.clear();
|
SERVER_CACHE.clear();
|
||||||
final ArrayList<ServerParser> parsers = new ArrayList<>();
|
final ArrayList<ServerParser> parsers = new ArrayList<>();
|
||||||
@@ -43,9 +41,11 @@ public abstract class ServerParser {
|
|||||||
Core.verbose("Server providers parsed.");
|
Core.verbose("Server providers parsed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<ServerDescription, ServerExecuter> SORTED_SERVER_CACHE = new TreeMap<ServerDescription, ServerExecuter>( SERVER_CACHE );
|
Map<ServerDescription, ServerExecuter> SORTED_SERVER_CACHE = new TreeMap<ServerDescription, ServerExecuter>(SERVER_CACHE);
|
||||||
|
|
||||||
return SORTED_SERVER_CACHE.keySet().toArray(new ServerDescription[SORTED_SERVER_CACHE.size()]);
|
return SORTED_SERVER_CACHE.keySet().toArray(new ServerDescription[SORTED_SERVER_CACHE.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,13 +9,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* A <code>RefClass</code> represents a class or an instance of that class, if
|
* A <code>RefClass</code> represents a class or an instance of that class, if
|
||||||
* no instance is provided this class can only get values from static fields and
|
* no instance is provided this class can only get values from static fields and
|
||||||
* only invoke static methods
|
* only invoke static methods
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RefClass extends RefModifiers {
|
public class RefClass extends RefModifiers {
|
||||||
private Object instance;
|
private Object instance;
|
||||||
@@ -35,12 +33,21 @@ public class RefClass extends RefModifiers {
|
|||||||
setInstance(instance);
|
setInstance(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the instance of this class
|
||||||
|
*
|
||||||
|
* @return if an instance of this class is known it will return that
|
||||||
|
* instance, otherwise it will return null.
|
||||||
|
*/
|
||||||
|
public Object getInstance() {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the instance of this class so now non static fields values can be
|
* Sets the instance of this class so now non static fields values can be
|
||||||
* retrieved and non static methods can be invoked
|
* retrieved and non static methods can be invoked
|
||||||
*
|
*
|
||||||
* @param instance
|
* @param instance instance of this class.
|
||||||
* instance of this class.
|
|
||||||
*/
|
*/
|
||||||
public void setInstance(Object instance) {
|
public void setInstance(Object instance) {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
@@ -56,16 +63,6 @@ public class RefClass extends RefModifiers {
|
|||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the instance of this class
|
|
||||||
*
|
|
||||||
* @return if an instance of this class is known it will return that
|
|
||||||
* instance, otherwise it will return null.
|
|
||||||
*/
|
|
||||||
public Object getInstance() {
|
|
||||||
return this.instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the class which this RefClass is representing
|
* Gets the class which this RefClass is representing
|
||||||
*
|
*
|
||||||
@@ -87,7 +84,7 @@ public class RefClass extends RefModifiers {
|
|||||||
return this.clazz.getCanonicalName();
|
return this.clazz.getCanonicalName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Annotation[] getAnnotations(){
|
public Annotation[] getAnnotations() {
|
||||||
return this.clazz.getAnnotations();
|
return this.clazz.getAnnotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +124,9 @@ public class RefClass extends RefModifiers {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if a object is an instance of this class
|
* Determines if a object is an instance of this class
|
||||||
|
*
|
||||||
* @param object the object you want to check
|
* @param object the object you want to check
|
||||||
|
*
|
||||||
* @return <code>true</code> if the object is an instance of this class; <code>false</code> otherwise
|
* @return <code>true</code> if the object is an instance of this class; <code>false</code> otherwise
|
||||||
*/
|
*/
|
||||||
public boolean instanceOf(Object object) {
|
public boolean instanceOf(Object object) {
|
||||||
@@ -137,8 +136,8 @@ public class RefClass extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Gets field by field name
|
* Gets field by field name
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name name of the field
|
||||||
* name of the field
|
*
|
||||||
* @return the field if found
|
* @return the field if found
|
||||||
*/
|
*/
|
||||||
public RefField getField(String name) {
|
public RefField getField(String name) {
|
||||||
@@ -148,10 +147,9 @@ public class RefClass extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Gets field by field name and desc
|
* Gets field by field name and desc
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name name of the field
|
||||||
* name of the field
|
* @param desc desc type of the field
|
||||||
* @param desc
|
*
|
||||||
* desc type of the field
|
|
||||||
* @return the field if found
|
* @return the field if found
|
||||||
*/
|
*/
|
||||||
public RefField getField(String name, String desc) {
|
public RefField getField(String name, String desc) {
|
||||||
@@ -182,9 +180,9 @@ public class RefClass extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Determines if this class has a super class
|
* Determines if this class has a super class
|
||||||
*
|
*
|
||||||
* @param ignoreObjectClass
|
* @param ignoreObjectClass if you want this method to return false when the superclass is
|
||||||
* if you want this method to return false when the superclass is
|
|
||||||
* the java/lang/Object class
|
* the java/lang/Object class
|
||||||
|
*
|
||||||
* @return <code>true</code> if this class has a superclass, otherwise
|
* @return <code>true</code> if this class has a superclass, otherwise
|
||||||
* <code>false</code>
|
* <code>false</code>
|
||||||
*/
|
*/
|
||||||
@@ -193,7 +191,7 @@ public class RefClass extends RefModifiers {
|
|||||||
return !clazz.equals(Object.class);
|
return !clazz.equals(Object.class);
|
||||||
}
|
}
|
||||||
Class<?> superClass = clazz.getSuperclass();
|
Class<?> superClass = clazz.getSuperclass();
|
||||||
if(superClass == null) {
|
if (superClass == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !superClass.equals(Object.class);
|
return !superClass.equals(Object.class);
|
||||||
@@ -228,14 +226,14 @@ public class RefClass extends RefModifiers {
|
|||||||
* @return empty constructor if there, otherwise <code>null</code>
|
* @return empty constructor if there, otherwise <code>null</code>
|
||||||
*/
|
*/
|
||||||
public RefConstructor getConstructor() {
|
public RefConstructor getConstructor() {
|
||||||
return getConstructor(new Class<?>[] {});
|
return getConstructor(new Class<?>[]{});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a RefConstructor from this class
|
* Gets a RefConstructor from this class
|
||||||
*
|
*
|
||||||
* @param parameters
|
* @param parameters the constructor it's parameters
|
||||||
* the constructor it's parameters
|
*
|
||||||
* @return the retrieved constructor
|
* @return the retrieved constructor
|
||||||
*/
|
*/
|
||||||
public RefConstructor getConstructor(Class<?>[] parameters) {
|
public RefConstructor getConstructor(Class<?>[] parameters) {
|
||||||
@@ -289,8 +287,8 @@ public class RefClass extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Finds and returns the first RefMethod match with given method name
|
* Finds and returns the first RefMethod match with given method name
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name method its name
|
||||||
* method its name
|
*
|
||||||
* @return the first match, or if not found <code>null</code>
|
* @return the first match, or if not found <code>null</code>
|
||||||
*/
|
*/
|
||||||
public RefMethod getMethod(String name) {
|
public RefMethod getMethod(String name) {
|
||||||
@@ -300,10 +298,9 @@ public class RefClass extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Finds a RefMethod in this RefClass
|
* Finds a RefMethod in this RefClass
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name the method its name
|
||||||
* the method its name
|
* @param parameters the method its parameters
|
||||||
* @param parameters
|
*
|
||||||
* the method its parameters
|
|
||||||
* @return the matched method or if not found null <code>null</code>
|
* @return the matched method or if not found null <code>null</code>
|
||||||
*/
|
*/
|
||||||
public RefMethod getMethod(String name, Class<?>[] parameters) {
|
public RefMethod getMethod(String name, Class<?>[] parameters) {
|
||||||
|
|||||||
@@ -3,12 +3,10 @@ package org.parabot.core.reflect;
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* A <code>RefConstructor</code> class represent a constructor method of a
|
* A <code>RefConstructor</code> class represent a constructor method of a
|
||||||
* <code>RefClass</code>.
|
* <code>RefClass</code>.
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RefConstructor extends RefModifiers {
|
public class RefConstructor extends RefModifiers {
|
||||||
private Constructor<?> constructor;
|
private Constructor<?> constructor;
|
||||||
@@ -24,14 +22,14 @@ public class RefConstructor extends RefModifiers {
|
|||||||
* @return the instance of the class
|
* @return the instance of the class
|
||||||
*/
|
*/
|
||||||
public RefClass newInstance() {
|
public RefClass newInstance() {
|
||||||
return newInstance(new Object[] {});
|
return newInstance(new Object[]{});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of this class by invoking this constructor
|
* Creates a new instance of this class by invoking this constructor
|
||||||
*
|
*
|
||||||
* @param args
|
* @param args the arguments for the constructor
|
||||||
* the arguments for the constructor
|
*
|
||||||
* @return the instance of the class
|
* @return the instance of the class
|
||||||
*/
|
*/
|
||||||
public RefClass newInstance(Object... args) {
|
public RefClass newInstance(Object... args) {
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ import java.lang.reflect.Field;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* A <code>RefField</code> represents a field in a <code>RefClass</code>
|
* A <code>RefField</code> represents a field in a <code>RefClass</code>
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RefField extends RefModifiers {
|
public class RefField extends RefModifiers {
|
||||||
private Field field;
|
private Field field;
|
||||||
@@ -129,8 +127,7 @@ public class RefField extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Sets the field value
|
* Sets the field value
|
||||||
*
|
*
|
||||||
* @param object
|
* @param object object to set
|
||||||
* object to set
|
|
||||||
*/
|
*/
|
||||||
public void set(Object object) {
|
public void set(Object object) {
|
||||||
if (instance == null && !isStatic()) {
|
if (instance == null && !isStatic()) {
|
||||||
@@ -150,8 +147,7 @@ public class RefField extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Sets the field integer value
|
* Sets the field integer value
|
||||||
*
|
*
|
||||||
* @param i
|
* @param i value to set
|
||||||
* value to set
|
|
||||||
*/
|
*/
|
||||||
public void setInt(int i) {
|
public void setInt(int i) {
|
||||||
set(i);
|
set(i);
|
||||||
@@ -160,8 +156,7 @@ public class RefField extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Sets the field long value
|
* Sets the field long value
|
||||||
*
|
*
|
||||||
* @param l
|
* @param l value to set
|
||||||
* value to set
|
|
||||||
*/
|
*/
|
||||||
public void setLong(long l) {
|
public void setLong(long l) {
|
||||||
set(l);
|
set(l);
|
||||||
@@ -170,8 +165,7 @@ public class RefField extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Sets the field double value
|
* Sets the field double value
|
||||||
*
|
*
|
||||||
* @param d
|
* @param d value to set
|
||||||
* value to set
|
|
||||||
*/
|
*/
|
||||||
public void setDouble(double d) {
|
public void setDouble(double d) {
|
||||||
set(d);
|
set(d);
|
||||||
@@ -180,8 +174,7 @@ public class RefField extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Sets the field float value
|
* Sets the field float value
|
||||||
*
|
*
|
||||||
* @param f
|
* @param f value to set
|
||||||
* value to set
|
|
||||||
*/
|
*/
|
||||||
public void setFloat(float f) {
|
public void setFloat(float f) {
|
||||||
set(f);
|
set(f);
|
||||||
@@ -190,8 +183,7 @@ public class RefField extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Sets the field boolean value
|
* Sets the field boolean value
|
||||||
*
|
*
|
||||||
* @param b
|
* @param b value to set
|
||||||
* value to set
|
|
||||||
*/
|
*/
|
||||||
public void setBoolean(boolean b) {
|
public void setBoolean(boolean b) {
|
||||||
set(b);
|
set(b);
|
||||||
@@ -200,8 +192,7 @@ public class RefField extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Sets the field short value
|
* Sets the field short value
|
||||||
*
|
*
|
||||||
* @param s
|
* @param s value to set
|
||||||
* value to set
|
|
||||||
*/
|
*/
|
||||||
public void setShort(short s) {
|
public void setShort(short s) {
|
||||||
set(s);
|
set(s);
|
||||||
@@ -210,28 +201,16 @@ public class RefField extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* Sets the byte integer value
|
* Sets the byte integer value
|
||||||
*
|
*
|
||||||
* @param b
|
* @param b value to set
|
||||||
* value to set
|
|
||||||
*/
|
*/
|
||||||
public void setByte(byte b) {
|
public void setByte(byte b) {
|
||||||
set(b);
|
set(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the field string value
|
|
||||||
*
|
|
||||||
* @param s
|
|
||||||
* value to set
|
|
||||||
*/
|
|
||||||
public void setString(String s) {
|
|
||||||
set(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the field char value
|
* Sets the field char value
|
||||||
*
|
*
|
||||||
* @param c
|
* @param c value to set
|
||||||
* value to set
|
|
||||||
*/
|
*/
|
||||||
public void setChar(char c) {
|
public void setChar(char c) {
|
||||||
set(c);
|
set(c);
|
||||||
@@ -312,6 +291,15 @@ public class RefField extends RefModifiers {
|
|||||||
return getType() == String.class;
|
return getType() == String.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the field string value
|
||||||
|
*
|
||||||
|
* @param s value to set
|
||||||
|
*/
|
||||||
|
public void setString(String s) {
|
||||||
|
set(s);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns <code>true</code> if this field represents an element of an
|
* Returns <code>true</code> if this field represents an element of an
|
||||||
* enumerated type; returns <code>false</code> otherwise.
|
* enumerated type; returns <code>false</code> otherwise.
|
||||||
@@ -363,6 +351,7 @@ public class RefField extends RefModifiers {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the declaring <code>RefClass</code> of this field
|
* Gets the declaring <code>RefClass</code> of this field
|
||||||
|
*
|
||||||
* @return <code>RefClass</code> holding this field
|
* @return <code>RefClass</code> holding this field
|
||||||
*/
|
*/
|
||||||
public RefClass getOwner() {
|
public RefClass getOwner() {
|
||||||
@@ -377,5 +366,4 @@ public class RefField extends RefModifiers {
|
|||||||
return field.toString();
|
return field.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,9 @@ package org.parabot.core.reflect;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* A <code>RefMethod</code> class represent a method of a <code>RefClass</code>.
|
* A <code>RefMethod</code> class represent a method of a <code>RefClass</code>.
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RefMethod extends RefModifiers {
|
public class RefMethod extends RefModifiers {
|
||||||
private Method method;
|
private Method method;
|
||||||
@@ -114,15 +112,14 @@ public class RefMethod extends RefModifiers {
|
|||||||
* @return object returned by the method
|
* @return object returned by the method
|
||||||
*/
|
*/
|
||||||
public Object invoke() {
|
public Object invoke() {
|
||||||
return invoke(new Object[] {});
|
return invoke(new Object[]{});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Invokes the method and returns it returned object
|
* Invokes the method and returns it returned object
|
||||||
*
|
*
|
||||||
* @param args
|
* @param args arguments for the invokable method
|
||||||
* arguments for the invokable method
|
*
|
||||||
* @return object returned by the method
|
* @return object returned by the method
|
||||||
*/
|
*/
|
||||||
public Object invoke(Object... args) {
|
public Object invoke(Object... args) {
|
||||||
@@ -130,7 +127,7 @@ public class RefMethod extends RefModifiers {
|
|||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Can not invoke non static method without an instance.");
|
"Can not invoke non static method without an instance.");
|
||||||
}
|
}
|
||||||
if(!isAccessible()) {
|
if (!isAccessible()) {
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ package org.parabot.core.reflect;
|
|||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RefModifiers {
|
public class RefModifiers {
|
||||||
private int modifiers;
|
private int modifiers;
|
||||||
@@ -18,14 +16,14 @@ public class RefModifiers {
|
|||||||
setModifiers(modifiers);
|
setModifiers(modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModifiers(int modifiers) {
|
|
||||||
this.modifiers = modifiers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getModifiers() {
|
public int getModifiers() {
|
||||||
return this.modifiers;
|
return this.modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setModifiers(int modifiers) {
|
||||||
|
this.modifiers = modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isStatic() {
|
public boolean isStatic() {
|
||||||
return Modifier.isStatic(modifiers);
|
return Modifier.isStatic(modifiers);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class RefUtils {
|
public class RefUtils {
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package org.parabot.core.ui;
|
package org.parabot.core.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
|
|
||||||
import javax.swing.JDialog;
|
|
||||||
|
|
||||||
import org.parabot.core.ui.components.PaintComponent;
|
import org.parabot.core.ui.components.PaintComponent;
|
||||||
import org.parabot.environment.OperatingSystem;
|
import org.parabot.environment.OperatingSystem;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class BotDialog extends JDialog {
|
public class BotDialog extends JDialog {
|
||||||
private static final long serialVersionUID = 521800552287194673L;
|
private static final long serialVersionUID = 521800552287194673L;
|
||||||
@@ -45,6 +41,14 @@ public class BotDialog extends JDialog {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BotDialog getInstance(BotUI botUI) {
|
||||||
|
return instance == null ? instance = new BotDialog(botUI) : instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BotDialog getInstance() {
|
||||||
|
return getInstance(null);
|
||||||
|
}
|
||||||
|
|
||||||
public void setDimensions(Dimension dimension) {
|
public void setDimensions(Dimension dimension) {
|
||||||
setUndecorated(true);
|
setUndecorated(true);
|
||||||
getRootPane().setOpaque(false);
|
getRootPane().setOpaque(false);
|
||||||
@@ -57,12 +61,4 @@ public class BotDialog extends JDialog {
|
|||||||
PaintComponent.getInstance().setDimensions(dimension);
|
PaintComponent.getInstance().setDimensions(dimension);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BotDialog getInstance(BotUI botUI) {
|
|
||||||
return instance == null ? instance = new BotDialog(botUI) : instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BotDialog getInstance() {
|
|
||||||
return getInstance(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
private JMenuItem run, pause, stop, cacheClear, notifications;
|
private JMenuItem run, pause, stop, cacheClear, notifications;
|
||||||
private boolean runScript, pauseScript;
|
private boolean runScript, pauseScript;
|
||||||
|
|
||||||
|
|
||||||
public BotUI(String username, String password) {
|
public BotUI(String username, String password) {
|
||||||
if (instance != null) {
|
if (instance != null) {
|
||||||
throw new IllegalStateException("BotUI already created");
|
throw new IllegalStateException("BotUI already created");
|
||||||
@@ -75,7 +74,6 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createMenu() {
|
private void createMenu() {
|
||||||
menuBar = new JMenuBar();
|
menuBar = new JMenuBar();
|
||||||
|
|
||||||
@@ -146,7 +144,6 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
menuBar.add(scripts);
|
menuBar.add(scripts);
|
||||||
menuBar.add(features);
|
menuBar.add(features);
|
||||||
|
|
||||||
|
|
||||||
setJMenuBar(menuBar);
|
setJMenuBar(menuBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +157,10 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
case "Create screenshot":
|
case "Create screenshot":
|
||||||
try {
|
try {
|
||||||
Robot robot = new Robot();
|
Robot robot = new Robot();
|
||||||
Rectangle parabotScreen = new Rectangle((int) getLocation().getX(), (int) getLocation().getY() + (menuBar.getHeight() + features.getHeight()), getWidth(), getHeight());
|
int menuBarHeight = menuBar.getHeight() + file.getHeight();
|
||||||
|
Rectangle parabotScreen = new Rectangle(
|
||||||
|
(int) getLocation().getX(), (int) getLocation().getY() + menuBarHeight,
|
||||||
|
getWidth(), getHeight() - menuBarHeight);
|
||||||
BufferedImage image = robot.createScreenCapture(parabotScreen);
|
BufferedImage image = robot.createScreenCapture(parabotScreen);
|
||||||
String randString = StringUtils.randomString(10);
|
String randString = StringUtils.randomString(10);
|
||||||
boolean search = true;
|
boolean search = true;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class Logger extends JPanel {
|
|||||||
|
|
||||||
private boolean clearable;
|
private boolean clearable;
|
||||||
|
|
||||||
private Logger(){
|
private Logger() {
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
list = new JList<>();
|
list = new JList<>();
|
||||||
|
|
||||||
@@ -45,34 +45,20 @@ public class Logger extends JPanel {
|
|||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListCellRenderer<? super String> getRenderer() {
|
|
||||||
return new DefaultListCellRenderer(){
|
|
||||||
private static final long serialVersionUID = -3589192791360628745L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getListCellRendererComponent(JList<?> list,
|
|
||||||
Object value, int index, boolean isSelected,
|
|
||||||
boolean cellHasFocus) {
|
|
||||||
JLabel listCellRendererComponent = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected,cellHasFocus);
|
|
||||||
listCellRendererComponent.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0,Color.BLACK));
|
|
||||||
return listCellRendererComponent;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Logger getInstance() {
|
public static Logger getInstance() {
|
||||||
return instance == null ? instance = new Logger() : instance;
|
return instance == null ? instance = new Logger() : instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a message in the logger ui
|
* Logs a message in the logger ui
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
* @param uliratha Determines if this should be sent to the uliratha server
|
* @param uliratha Determines if this should be sent to the uliratha server
|
||||||
*/
|
*/
|
||||||
public static void addMessage(String message, boolean uliratha){
|
public static void addMessage(String message, boolean uliratha) {
|
||||||
instance.model.addElement(message);
|
instance.model.addElement(message);
|
||||||
|
|
||||||
if (uliratha){
|
if (uliratha) {
|
||||||
// TODO: Implement latest Uliratha
|
// TODO: Implement latest Uliratha
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +66,7 @@ public class Logger extends JPanel {
|
|||||||
if (last >= 0) {
|
if (last >= 0) {
|
||||||
instance.list.ensureIndexIsVisible(last);
|
instance.list.ensureIndexIsVisible(last);
|
||||||
}
|
}
|
||||||
if (instance.list.getModel().getSize() > 100 && instance.list.getModel().getElementAt(0) != null){
|
if (instance.list.getModel().getSize() > 100 && instance.list.getModel().getElementAt(0) != null) {
|
||||||
instance.model.remove(0);
|
instance.model.remove(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,14 +74,29 @@ public class Logger extends JPanel {
|
|||||||
/**
|
/**
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public static void addMessage(String message){
|
public static void addMessage(String message) {
|
||||||
addMessage(message, true);
|
addMessage(message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void clearLogger(){
|
protected static void clearLogger() {
|
||||||
instance.model.clear();
|
instance.model.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ListCellRenderer<? super String> getRenderer() {
|
||||||
|
return new DefaultListCellRenderer() {
|
||||||
|
private static final long serialVersionUID = -3589192791360628745L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list,
|
||||||
|
Object value, int index, boolean isSelected,
|
||||||
|
boolean cellHasFocus) {
|
||||||
|
JLabel listCellRendererComponent = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
listCellRendererComponent.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLACK));
|
||||||
|
return listCellRendererComponent;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isClearable() {
|
public boolean isClearable() {
|
||||||
return clearable;
|
return clearable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,9 @@ import java.io.IOException;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Users must login with their parabot account through this LoginUI class
|
* Users must login with their parabot account through this LoginUI class
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class LoginUI extends JFrame {
|
public class LoginUI extends JFrame {
|
||||||
private static final long serialVersionUID = 2032832552863466297L;
|
private static final long serialVersionUID = 2032832552863466297L;
|
||||||
@@ -33,38 +31,6 @@ public class LoginUI extends JFrame {
|
|||||||
private JButton cmdLogin;
|
private JButton cmdLogin;
|
||||||
private JButton cmdRegister;
|
private JButton cmdRegister;
|
||||||
|
|
||||||
|
|
||||||
public void attemptLogin() {
|
|
||||||
String username = txtUsername.getText();
|
|
||||||
String password = new String(txtPassword.getPassword());
|
|
||||||
|
|
||||||
if (username.length() > 0 && password.length() > 0) {
|
|
||||||
if (manager.login(username, password, false)) {
|
|
||||||
Core.verbose("Logged in.");
|
|
||||||
instance.dispose();
|
|
||||||
Core.verbose("Running server selector.");
|
|
||||||
ServerSelector.getInstance();
|
|
||||||
} else {
|
|
||||||
Core.verbose("Failed to log in.");
|
|
||||||
UILog.log("Error", "Incorrect username or password. Have you tried logging into http://bdn.parabot.org/account/", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void attempt(String user, String pass) {
|
|
||||||
Core.verbose("Logging in...");
|
|
||||||
if (manager.login(user, pass, false)) {
|
|
||||||
Core.verbose("Logged in.");
|
|
||||||
instance.dispose();
|
|
||||||
Core.verbose("Running server selector.");
|
|
||||||
ServerSelector.getInstance();
|
|
||||||
} else {
|
|
||||||
Core.verbose("Failed to log in.");
|
|
||||||
UILog.log("Error", "Incorrect username or password. Have you tried logging into http://bdn.parabot.org/account/", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoginUI(String username, String password) {
|
public LoginUI(String username, String password) {
|
||||||
instance = this;
|
instance = this;
|
||||||
attempt(username, password);
|
attempt(username, password);
|
||||||
@@ -169,4 +135,35 @@ public class LoginUI extends JFrame {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void attemptLogin() {
|
||||||
|
String username = txtUsername.getText();
|
||||||
|
String password = new String(txtPassword.getPassword());
|
||||||
|
|
||||||
|
if (username.length() > 0 && password.length() > 0) {
|
||||||
|
if (manager.login(username, password, false)) {
|
||||||
|
Core.verbose("Logged in.");
|
||||||
|
instance.dispose();
|
||||||
|
Core.verbose("Running server selector.");
|
||||||
|
ServerSelector.getInstance();
|
||||||
|
} else {
|
||||||
|
Core.verbose("Failed to log in.");
|
||||||
|
UILog.log("Error", "Incorrect username or password. Have you tried logging into http://bdn.parabot.org/account/", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void attempt(String user, String pass) {
|
||||||
|
Core.verbose("Logging in...");
|
||||||
|
if (manager.login(user, pass, false)) {
|
||||||
|
Core.verbose("Logged in.");
|
||||||
|
instance.dispose();
|
||||||
|
Core.verbose("Running server selector.");
|
||||||
|
ServerSelector.getInstance();
|
||||||
|
} else {
|
||||||
|
Core.verbose("Failed to log in.");
|
||||||
|
UILog.log("Error", "Incorrect username or password. Have you tried logging into http://bdn.parabot.org/account/", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,9 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
@Override
|
@Override
|
||||||
public void setVisible(boolean b) {
|
public void setVisible(boolean b) {
|
||||||
BotUI.getInstance().setEnabled(!b);
|
BotUI.getInstance().setEnabled(!b);
|
||||||
if (ProxySocket.getProxyAddress() != null)
|
if (ProxySocket.getProxyAddress() != null) {
|
||||||
proxyHost.setText(ProxySocket.getProxyAddress().getHostName());
|
proxyHost.setText(ProxySocket.getProxyAddress().getHostName());
|
||||||
|
}
|
||||||
proxyPort.setText("" + ProxySocket.getProxyPort());
|
proxyPort.setText("" + ProxySocket.getProxyPort());
|
||||||
proxyType.setSelectedItem(ProxySocket.getProxyType());
|
proxyType.setSelectedItem(ProxySocket.getProxyType());
|
||||||
authCheckBox.setSelected(ProxySocket.auth);
|
authCheckBox.setSelected(ProxySocket.auth);
|
||||||
@@ -95,7 +96,7 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
byte[] macAddr = new byte[6];
|
byte[] macAddr = new byte[6];
|
||||||
rand.nextBytes(macAddr);
|
rand.nextBytes(macAddr);
|
||||||
macAddr[0] = (byte)(macAddr[0] & (byte)254);
|
macAddr[0] = (byte) (macAddr[0] & (byte) 254);
|
||||||
for (int i = 0; i < macAddr.length; i++) {
|
for (int i = 0; i < macAddr.length; i++) {
|
||||||
int value = macAddr[i] & 0xFF;
|
int value = macAddr[i] & 0xFF;
|
||||||
macList[i].setSelectedIndex(value);
|
macList[i].setSelectedIndex(value);
|
||||||
@@ -104,7 +105,6 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
authCheckBox = new JCheckBox("Auth");
|
authCheckBox = new JCheckBox("Auth");
|
||||||
authCheckBox.setSelected(ProxySocket.auth);
|
authCheckBox.setSelected(ProxySocket.auth);
|
||||||
authCheckBox.addActionListener(this);
|
authCheckBox.addActionListener(this);
|
||||||
@@ -262,9 +262,10 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
.setLogin(username, password);
|
.setLogin(username, password);
|
||||||
|
|
||||||
byte[] mac = new byte[macList.length];
|
byte[] mac = new byte[macList.length];
|
||||||
for (int i = 0; i < mac.length; i++)
|
for (int i = 0; i < mac.length; i++) {
|
||||||
mac[i] = (byte) Short.parseShort(
|
mac[i] = (byte) Short.parseShort(
|
||||||
(String) macList[i].getSelectedValue(), 16);
|
(String) macList[i].getSelectedValue(), 16);
|
||||||
|
}
|
||||||
NetworkInterface.setMac(mac);
|
NetworkInterface.setMac(mac);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -340,8 +341,9 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
|
|
||||||
public void insertString(int offs, String str, AttributeSet a)
|
public void insertString(int offs, String str, AttributeSet a)
|
||||||
throws BadLocationException {
|
throws BadLocationException {
|
||||||
if (str == null)
|
if (str == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
String oldString = getText(0, getLength());
|
String oldString = getText(0, getLength());
|
||||||
String newString = oldString.substring(0, offs) + str
|
String newString = oldString.substring(0, offs) + str
|
||||||
+ oldString.substring(offs);
|
+ oldString.substring(offs);
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ public class ReflectUI extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
final JButton adjustClasses = new JButton("Expand");
|
final JButton adjustClasses = new JButton("Expand");
|
||||||
adjustClasses.addActionListener(new ActionListener() {
|
adjustClasses.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -130,7 +129,6 @@ public class ReflectUI extends JFrame {
|
|||||||
searchContent.setMaximumSize(new Dimension(500, (int) searchContent.getPreferredSize().getHeight()));
|
searchContent.setMaximumSize(new Dimension(500, (int) searchContent.getPreferredSize().getHeight()));
|
||||||
searchContent.add(searchButton);
|
searchContent.add(searchButton);
|
||||||
|
|
||||||
|
|
||||||
tree = new JTree();
|
tree = new JTree();
|
||||||
tree.setRootVisible(true);
|
tree.setRootVisible(true);
|
||||||
tree.setShowsRootHandles(true);
|
tree.setShowsRootHandles(true);
|
||||||
|
|||||||
@@ -23,21 +23,23 @@ import java.net.URLEncoder;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Script Selector GUI, shows all scripts
|
* Script Selector GUI, shows all scripts
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public final class ScriptSelector extends JFrame {
|
public final class ScriptSelector extends JFrame {
|
||||||
public static ScriptParser parser;
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
public static ScriptParser parser;
|
||||||
|
private final int WIDTH;
|
||||||
|
private final int HEIGHT;
|
||||||
private HashMap<String, DefaultMutableTreeNode> categories;
|
private HashMap<String, DefaultMutableTreeNode> categories;
|
||||||
private HashMap<String, ScriptDescription> format;
|
private HashMap<String, ScriptDescription> format;
|
||||||
private DefaultMutableTreeNode root;
|
private DefaultMutableTreeNode root;
|
||||||
private DefaultTreeModel model;
|
private DefaultTreeModel model;
|
||||||
private final int WIDTH;
|
private Font fontCategory = new Font("Arial", Font.BOLD, 12);
|
||||||
private final int HEIGHT;
|
private Font fontScript = new Font("Arial", Font.PLAIN, 12);
|
||||||
|
private JTree tree;
|
||||||
|
private JEditorPane scriptInfo;
|
||||||
|
|
||||||
public ScriptSelector() {
|
public ScriptSelector() {
|
||||||
this.categories = new HashMap<String, DefaultMutableTreeNode>();
|
this.categories = new HashMap<String, DefaultMutableTreeNode>();
|
||||||
@@ -77,7 +79,6 @@ public final class ScriptSelector extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getScriptName(String path) {
|
private String getScriptName(String path) {
|
||||||
return path.split(", ")[2].replaceAll("\\]", "");
|
return path.split(", ")[2].replaceAll("\\]", "");
|
||||||
}
|
}
|
||||||
@@ -216,9 +217,4 @@ public final class ScriptSelector extends JFrame {
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Font fontCategory = new Font("Arial", Font.BOLD, 12);
|
|
||||||
private Font fontScript = new Font("Arial", Font.PLAIN, 12);
|
|
||||||
private JTree tree;
|
|
||||||
private JEditorPane scriptInfo;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,25 +11,16 @@ import java.util.LinkedList;
|
|||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Shows a list of every supported server which can be started
|
* Shows a list of every supported server which can be started
|
||||||
*
|
*
|
||||||
* @author Dane, Everel
|
* @author Dane, Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ServerSelector extends JPanel {
|
public class ServerSelector extends JPanel {
|
||||||
public static String initServer;
|
|
||||||
private static final long serialVersionUID = 5238720307271493899L;
|
private static final long serialVersionUID = 5238720307271493899L;
|
||||||
|
public static String initServer;
|
||||||
private static ServerSelector instance;
|
private static ServerSelector instance;
|
||||||
|
|
||||||
public static ServerSelector getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new ServerSelector();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerSelector() {
|
public ServerSelector() {
|
||||||
Queue<ServerComponent> widgets = getServers();
|
Queue<ServerComponent> widgets = getServers();
|
||||||
if (initServer != null) {
|
if (initServer != null) {
|
||||||
@@ -39,7 +30,6 @@ public class ServerSelector extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
setPreferredSize(new Dimension(600, 350));
|
setPreferredSize(new Dimension(600, 350));
|
||||||
|
|
||||||
@@ -50,7 +40,7 @@ public class ServerSelector extends JPanel {
|
|||||||
while (widgets != null && !widgets.isEmpty()) {
|
while (widgets != null && !widgets.isEmpty()) {
|
||||||
final ServerComponent w = widgets.poll();
|
final ServerComponent w = widgets.poll();
|
||||||
w.setSize(300, 100);
|
w.setSize(300, 100);
|
||||||
if(i % 2 == 0 && i != 0) {
|
if (i % 2 == 0 && i != 0) {
|
||||||
y += 100;
|
y += 100;
|
||||||
}
|
}
|
||||||
w.setLocation(i % 2 == 0 ? 0 : 300, y);
|
w.setLocation(i % 2 == 0 ? 0 : 300, y);
|
||||||
@@ -69,6 +59,13 @@ public class ServerSelector extends JPanel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ServerSelector getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new ServerSelector();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called when -server argument is given
|
* This method is called when -server argument is given
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -6,11 +6,9 @@ import javax.swing.*;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Main panel where applets are added.
|
* Main panel where applets are added.
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class GamePanel extends JPanel {
|
public class GamePanel extends JPanel {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -30,15 +28,6 @@ public class GamePanel extends JPanel {
|
|||||||
GroupLayout.Alignment.LEADING).addGap(0, 418, Short.MAX_VALUE));
|
GroupLayout.Alignment.LEADING).addGap(0, 418, Short.MAX_VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates context of this panel and adds a different Applet to the panel
|
|
||||||
*
|
|
||||||
* @param c
|
|
||||||
*/
|
|
||||||
public void setContext(final Context c) {
|
|
||||||
add(c.getApplet(), BorderLayout.CENTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets instance of this panel
|
* Gets instance of this panel
|
||||||
*
|
*
|
||||||
@@ -48,6 +37,15 @@ public class GamePanel extends JPanel {
|
|||||||
return instance == null ? instance = new GamePanel() : instance;
|
return instance == null ? instance = new GamePanel() : instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates context of this panel and adds a different Applet to the panel
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
*/
|
||||||
|
public void setContext(final Context c) {
|
||||||
|
add(c.getApplet(), BorderLayout.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all components
|
* Removes all components
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,23 +1,17 @@
|
|||||||
package org.parabot.core.ui.components;
|
package org.parabot.core.ui.components;
|
||||||
|
|
||||||
import java.awt.AlphaComposite;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.environment.api.interfaces.Paintable;
|
import org.parabot.environment.api.interfaces.Paintable;
|
||||||
import org.parabot.environment.api.utils.Time;
|
import org.parabot.environment.api.utils.Time;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* The panel that is painted on
|
* The panel that is painted on
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class PaintComponent extends JComponent implements Runnable {
|
public class PaintComponent extends JComponent implements Runnable {
|
||||||
private static final long serialVersionUID = 4653612412080038193L;
|
private static final long serialVersionUID = 4653612412080038193L;
|
||||||
@@ -39,6 +33,14 @@ public class PaintComponent extends JComponent implements Runnable {
|
|||||||
setIgnoreRepaint(true);
|
setIgnoreRepaint(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PaintComponent getInstance(Dimension dimensions) {
|
||||||
|
return instance == null ? instance = new PaintComponent(dimensions) : instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PaintComponent getInstance() {
|
||||||
|
return getInstance(null);
|
||||||
|
}
|
||||||
|
|
||||||
public void setDimensions(Dimension dimensions) {
|
public void setDimensions(Dimension dimensions) {
|
||||||
this.dimensions = dimensions;
|
this.dimensions = dimensions;
|
||||||
this.dimensions = dimensions;
|
this.dimensions = dimensions;
|
||||||
@@ -51,14 +53,6 @@ public class PaintComponent extends JComponent implements Runnable {
|
|||||||
setIgnoreRepaint(true);
|
setIgnoreRepaint(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PaintComponent getInstance(Dimension dimensions) {
|
|
||||||
return instance == null ? instance = new PaintComponent(dimensions) : instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PaintComponent getInstance() {
|
|
||||||
return getInstance(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startPainting(Context context) {
|
public void startPainting(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
new Thread(this).start();
|
new Thread(this).start();
|
||||||
@@ -70,8 +64,8 @@ public class PaintComponent extends JComponent implements Runnable {
|
|||||||
g2.fillRect(0, 0, dimensions.width, dimensions.height);
|
g2.fillRect(0, 0, dimensions.width, dimensions.height);
|
||||||
g2.setComposite(AlphaComposite.SrcOver);
|
g2.setComposite(AlphaComposite.SrcOver);
|
||||||
|
|
||||||
if(context != null) {
|
if (context != null) {
|
||||||
for(Paintable p : context.getPaintables()) {
|
for (Paintable p : context.getPaintables()) {
|
||||||
p.paint(g);
|
p.paint(g);
|
||||||
}
|
}
|
||||||
context.getPaintDebugger().debug(g2);
|
context.getPaintDebugger().debug(g2);
|
||||||
@@ -81,7 +75,7 @@ public class PaintComponent extends JComponent implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while(true) {
|
while (true) {
|
||||||
Time.sleep(100);
|
Time.sleep(100);
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
package org.parabot.core.ui.components;
|
package org.parabot.core.ui.components;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.*;
|
||||||
import java.awt.FontMetrics;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* ProgressBar
|
* ProgressBar
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ProgressBar {
|
public class ProgressBar {
|
||||||
private double value;
|
private double value;
|
||||||
@@ -36,11 +30,15 @@ public class ProgressBar {
|
|||||||
this.text = text;
|
this.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
public void setValue(double value) {
|
public void setValue(double value) {
|
||||||
if(value < 0 || value > 100) {
|
if (value < 0 || value > 100) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(value > 99) {
|
if (value > 99) {
|
||||||
value = 100;
|
value = 100;
|
||||||
}
|
}
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@@ -61,10 +59,6 @@ public class ProgressBar {
|
|||||||
this.progColor = new Color(255 - r, 253 - g, 145 - b);
|
this.progColor = new Color(255 - r, 253 - g, 145 - b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw(Graphics g, int x, int y) {
|
public void draw(Graphics g, int x, int y) {
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
g2.setRenderingHint(
|
g2.setRenderingHint(
|
||||||
|
|||||||
@@ -1,26 +1,19 @@
|
|||||||
package org.parabot.core.ui.components;
|
package org.parabot.core.ui.components;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Cursor;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.FontMetrics;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.awt.event.MouseMotionListener;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import org.parabot.core.desc.ServerDescription;
|
import org.parabot.core.desc.ServerDescription;
|
||||||
import org.parabot.core.ui.fonts.Fonts;
|
import org.parabot.core.ui.fonts.Fonts;
|
||||||
import org.parabot.environment.Environment;
|
import org.parabot.environment.Environment;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.event.MouseMotionListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A neat looking server component
|
* A neat looking server component
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class ServerComponent extends JPanel implements MouseListener,
|
public class ServerComponent extends JPanel implements MouseListener,
|
||||||
MouseMotionListener {
|
MouseMotionListener {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import org.parabot.core.forum.AccountManager;
|
|||||||
import org.parabot.core.forum.AccountManagerAccess;
|
import org.parabot.core.forum.AccountManagerAccess;
|
||||||
import org.parabot.core.io.ProgressListener;
|
import org.parabot.core.io.ProgressListener;
|
||||||
import org.parabot.core.ui.ServerSelector;
|
import org.parabot.core.ui.ServerSelector;
|
||||||
import org.parabot.core.ui.images.Images;
|
|
||||||
import org.parabot.core.ui.fonts.Fonts;
|
import org.parabot.core.ui.fonts.Fonts;
|
||||||
|
import org.parabot.core.ui.images.Images;
|
||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -24,22 +24,13 @@ import java.awt.image.RescaleOp;
|
|||||||
* @author Everel, EmmaStone
|
* @author Everel, EmmaStone
|
||||||
*/
|
*/
|
||||||
public class VerboseLoader extends JPanel implements ProgressListener {
|
public class VerboseLoader extends JPanel implements ProgressListener {
|
||||||
|
public static final int STATE_LOADING = 1;
|
||||||
private static final long serialVersionUID = 7412412644921803896L;
|
private static final long serialVersionUID = 7412412644921803896L;
|
||||||
|
private static final int STATE_AUTHENTICATION = 0;
|
||||||
|
private static final int STATE_SERVER_SELECT = 2;
|
||||||
private static VerboseLoader current;
|
private static VerboseLoader current;
|
||||||
private static String state = "Initializing loader...";
|
private static String state = "Initializing loader...";
|
||||||
|
|
||||||
private static final int STATE_AUTHENTICATION = 0;
|
|
||||||
public static final int STATE_LOADING = 1;
|
|
||||||
private static final int STATE_SERVER_SELECT = 2;
|
|
||||||
private int currentState;
|
|
||||||
|
|
||||||
private static AccountManager manager;
|
private static AccountManager manager;
|
||||||
|
|
||||||
private FontMetrics fontMetrics;
|
|
||||||
private BufferedImage background, banner, loginBox;
|
|
||||||
private ProgressBar progressBar;
|
|
||||||
private JPanel loginPanel;
|
|
||||||
|
|
||||||
public static final AccountManagerAccess MANAGER_FETCHER = new AccountManagerAccess() {
|
public static final AccountManagerAccess MANAGER_FETCHER = new AccountManagerAccess() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,6 +39,11 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
private int currentState;
|
||||||
|
private FontMetrics fontMetrics;
|
||||||
|
private BufferedImage background, banner, loginBox;
|
||||||
|
private ProgressBar progressBar;
|
||||||
|
private JPanel loginPanel;
|
||||||
|
|
||||||
private VerboseLoader(String username, String password) {
|
private VerboseLoader(String username, String password) {
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
@@ -77,6 +73,34 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets instance of this panel
|
||||||
|
*
|
||||||
|
* @return instance of this panel
|
||||||
|
*/
|
||||||
|
public static VerboseLoader get(String username, String password) {
|
||||||
|
return current == null ? new VerboseLoader(username, password) : current;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets instance of this panel
|
||||||
|
*
|
||||||
|
* @return instance of this panel
|
||||||
|
*/
|
||||||
|
public static VerboseLoader get() {
|
||||||
|
return current == null ? new VerboseLoader(null, null) : current;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the status message and repaints the panel
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
*/
|
||||||
|
public static void setState(final String message) {
|
||||||
|
state = message;
|
||||||
|
current.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
public void addServerPanel() {
|
public void addServerPanel() {
|
||||||
JPanel servers = ServerSelector.getInstance();
|
JPanel servers = ServerSelector.getInstance();
|
||||||
GridBagLayout bagLayout = (GridBagLayout) getLayout();
|
GridBagLayout bagLayout = (GridBagLayout) getLayout();
|
||||||
@@ -139,7 +163,6 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
passwordLabel.setAlignmentX(Box.CENTER_ALIGNMENT);
|
passwordLabel.setAlignmentX(Box.CENTER_ALIGNMENT);
|
||||||
passwordLabel.setForeground(Color.white);
|
passwordLabel.setForeground(Color.white);
|
||||||
|
|
||||||
|
|
||||||
login.setAlignmentX(Box.CENTER_ALIGNMENT);
|
login.setAlignmentX(Box.CENTER_ALIGNMENT);
|
||||||
login.setOpaque(false);
|
login.setOpaque(false);
|
||||||
|
|
||||||
@@ -189,14 +212,13 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
public void paintComponent(Graphics graphics) {
|
public void paintComponent(Graphics graphics) {
|
||||||
super.paintComponent(graphics);
|
super.paintComponent(graphics);
|
||||||
|
|
||||||
|
|
||||||
Graphics2D g = (Graphics2D) graphics;
|
Graphics2D g = (Graphics2D) graphics;
|
||||||
g.setRenderingHint(
|
g.setRenderingHint(
|
||||||
RenderingHints.KEY_TEXT_ANTIALIASING,
|
RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||||
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||||
|
|
||||||
g.drawImage(background, 0, 0, null);
|
g.drawImage(background, 0, 0, null);
|
||||||
float[] scales = {1f, 1f, 1f, 0.9f};
|
float[] scales = { 1f, 1f, 1f, 0.9f };
|
||||||
float[] offsets = new float[4];
|
float[] offsets = new float[4];
|
||||||
RescaleOp rop = new RescaleOp(scales, offsets, null);
|
RescaleOp rop = new RescaleOp(scales, offsets, null);
|
||||||
g.drawImage(banner, rop, 0, 0);
|
g.drawImage(banner, rop, 0, 0);
|
||||||
@@ -236,7 +258,6 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
g.drawString(state, x, 200);
|
g.drawString(state, x, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
g.setFont(Fonts.getResource("leelawadee.ttf"));
|
g.setFont(Fonts.getResource("leelawadee.ttf"));
|
||||||
final String version = Configuration.BOT_VERSION.get();
|
final String version = Configuration.BOT_VERSION.get();
|
||||||
g.drawString(version,
|
g.drawString(version,
|
||||||
@@ -244,35 +265,6 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
getHeight() - 12);
|
getHeight() - 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets instance of this panel
|
|
||||||
*
|
|
||||||
* @return instance of this panel
|
|
||||||
*/
|
|
||||||
public static VerboseLoader get(String username, String password) {
|
|
||||||
return current == null ? new VerboseLoader(username, password) : current;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets instance of this panel
|
|
||||||
*
|
|
||||||
* @return instance of this panel
|
|
||||||
*/
|
|
||||||
public static VerboseLoader get() {
|
|
||||||
return current == null ? new VerboseLoader(null, null) : current;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the status message and repaints the panel
|
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
*/
|
|
||||||
public static void setState(final String message) {
|
|
||||||
state = message;
|
|
||||||
current.repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgressUpdate(double value) {
|
public void onProgressUpdate(double value) {
|
||||||
progressBar.setValue(value);
|
progressBar.setValue(value);
|
||||||
|
|||||||
@@ -1,27 +1,26 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
<BorderPane xmlns:fx="http://javafx.com/fxml/1" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="500.0" minWidth="500.0"
|
||||||
|
prefHeight="503.0" prefWidth="735.0" xmlns="http://javafx.com/javafx/8">
|
||||||
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="500.0" minWidth="500.0" prefHeight="503.0" prefWidth="735.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
|
|
||||||
<top>
|
<top>
|
||||||
<MenuBar BorderPane.alignment="CENTER">
|
<MenuBar BorderPane.alignment="CENTER">
|
||||||
<menus>
|
<menus>
|
||||||
<Menu mnemonicParsing="false" text="File">
|
<Menu mnemonicParsing="false" text="File">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" text="Close" />
|
<MenuItem mnemonicParsing="false" text="Close"/>
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="Edit">
|
<Menu mnemonicParsing="false" text="Edit">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" text="Delete" />
|
<MenuItem mnemonicParsing="false" text="Delete"/>
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="Help">
|
<Menu mnemonicParsing="false" text="Help">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" text="About" />
|
<MenuItem mnemonicParsing="false" text="About"/>
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
</menus>
|
</menus>
|
||||||
@@ -36,39 +35,41 @@
|
|||||||
<top>
|
<top>
|
||||||
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
<items>
|
<items>
|
||||||
<TextField promptText="Search query" />
|
<TextField promptText="Search query"/>
|
||||||
<Separator prefHeight="30.0" prefWidth="25.0" visible="false" />
|
<Separator prefHeight="30.0" prefWidth="25.0" visible="false"/>
|
||||||
<ComboBox prefWidth="150.0" promptText="Category" />
|
<ComboBox prefWidth="150.0" promptText="Category"/>
|
||||||
<Separator prefHeight="30.0" prefWidth="25.0" visible="false" />
|
<Separator prefHeight="30.0" prefWidth="25.0" visible="false"/>
|
||||||
<CheckBox mnemonicParsing="false" text="All servers" />
|
<CheckBox mnemonicParsing="false" text="All servers"/>
|
||||||
<Separator prefHeight="30.0" prefWidth="25.0" visible="false" />
|
<Separator prefHeight="30.0" prefWidth="25.0" visible="false"/>
|
||||||
<CheckBox mnemonicParsing="false" text="Include local scripts" />
|
<CheckBox mnemonicParsing="false" text="Include local scripts"/>
|
||||||
<Separator prefHeight="30.0" prefWidth="25.0" visible="false" />
|
<Separator prefHeight="30.0" prefWidth="25.0" visible="false"/>
|
||||||
<Button alignment="CENTER_RIGHT" mnemonicParsing="false" text="Search" />
|
<Button alignment="CENTER_RIGHT" mnemonicParsing="false" text="Search"/>
|
||||||
</items>
|
</items>
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
</top>
|
</top>
|
||||||
<center>
|
<center>
|
||||||
<TableView prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
<TableView prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn prefWidth="75.0" text="Name" />
|
<TableColumn prefWidth="75.0" text="Name"/>
|
||||||
<TableColumn prefWidth="75.0" text="Category" />
|
<TableColumn prefWidth="75.0" text="Category"/>
|
||||||
<TableColumn prefWidth="75.0" text="Price" />
|
<TableColumn prefWidth="75.0" text="Price"/>
|
||||||
</columns>
|
</columns>
|
||||||
<contextMenu>
|
<contextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" text="View information" />
|
<MenuItem mnemonicParsing="false" text="View information"/>
|
||||||
</items>
|
</items>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</contextMenu>
|
</contextMenu>
|
||||||
</TableView>
|
</TableView>
|
||||||
</center>
|
</center>
|
||||||
<bottom>
|
<bottom>
|
||||||
<HBox alignment="CENTER_RIGHT" prefHeight="35.0" prefWidth="735.0" BorderPane.alignment="CENTER">
|
<HBox alignment="CENTER_RIGHT" prefHeight="35.0" prefWidth="735.0"
|
||||||
|
BorderPane.alignment="CENTER">
|
||||||
<children>
|
<children>
|
||||||
<Button mnemonicParsing="false" prefHeight="25.0" prefWidth="83.0" text="Start" />
|
<Button mnemonicParsing="false" prefHeight="25.0" prefWidth="83.0"
|
||||||
<Separator prefHeight="4.0" prefWidth="35.0" visible="false" />
|
text="Start"/>
|
||||||
|
<Separator prefHeight="4.0" prefWidth="35.0" visible="false"/>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
</bottom>
|
</bottom>
|
||||||
@@ -77,7 +78,7 @@
|
|||||||
</Tab>
|
</Tab>
|
||||||
<Tab text="JKChicken">
|
<Tab text="JKChicken">
|
||||||
<content>
|
<content>
|
||||||
<BorderPane prefHeight="200.0" prefWidth="200.0" />
|
<BorderPane prefHeight="200.0" prefWidth="200.0"/>
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class Fonts {
|
|||||||
* Calls the getResource with the default size of 12
|
* Calls the getResource with the default size of 12
|
||||||
*
|
*
|
||||||
* @param resource
|
* @param resource
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Font getResource(final String resource) {
|
public static Font getResource(final String resource) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.parabot.core.ui.listeners;
|
|||||||
|
|
||||||
import org.parabot.core.ui.listeners.key.ActionEventBinding;
|
import org.parabot.core.ui.listeners.key.ActionEventBinding;
|
||||||
import org.parabot.core.ui.listeners.key.Binding;
|
import org.parabot.core.ui.listeners.key.Binding;
|
||||||
import org.parabot.environment.OperatingSystem;
|
|
||||||
|
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
@@ -31,15 +30,15 @@ public class PBKeyListener implements KeyListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addBinding(Binding binding) {
|
public void addBinding(Binding binding) {
|
||||||
for (Binding bind : this.bindings){
|
for (Binding bind : this.bindings) {
|
||||||
if (bind.getKey() == binding.getKey()){
|
if (bind.getKey() == binding.getKey()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.bindings.add(binding);
|
this.bindings.add(binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetBindings(){
|
public void resetBindings() {
|
||||||
this.bindings = new ArrayList<>();
|
this.bindings = new ArrayList<>();
|
||||||
this.fillBindings();
|
this.fillBindings();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import org.parabot.environment.api.utils.WebUtil;
|
|||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the bot environment
|
* Initializes the bot environment
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package org.parabot.environment;
|
package org.parabot.environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* This class is used for detecting the user's operating system
|
* This class is used for detecting the user's operating system
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public enum OperatingSystem {
|
public enum OperatingSystem {
|
||||||
|
|
||||||
@@ -13,12 +11,15 @@ public enum OperatingSystem {
|
|||||||
|
|
||||||
public static final OperatingSystem getOS() {
|
public static final OperatingSystem getOS() {
|
||||||
String str = System.getProperty("os.name").toLowerCase();
|
String str = System.getProperty("os.name").toLowerCase();
|
||||||
if (str.indexOf("win") > -1)
|
if (str.indexOf("win") > -1) {
|
||||||
return OperatingSystem.WINDOWS;
|
return OperatingSystem.WINDOWS;
|
||||||
if (str.indexOf("mac") > -1)
|
}
|
||||||
|
if (str.indexOf("mac") > -1) {
|
||||||
return OperatingSystem.MAC;
|
return OperatingSystem.MAC;
|
||||||
if (str.indexOf("nix") > -1 || str.indexOf("nux") > -1)
|
}
|
||||||
|
if (str.indexOf("nix") > -1 || str.indexOf("nux") > -1) {
|
||||||
return OperatingSystem.LINUX;
|
return OperatingSystem.LINUX;
|
||||||
|
}
|
||||||
return OperatingSystem.OTHER;
|
return OperatingSystem.OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package org.parabot.environment.api.interfaces;
|
package org.parabot.environment.api.interfaces;
|
||||||
|
|
||||||
import java.awt.Graphics;
|
import java.awt.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface Paintable {
|
public interface Paintable {
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
*/
|
*/
|
||||||
public class FileUtil {
|
public class FileUtil {
|
||||||
|
|
||||||
public static String getChecksum(File file){
|
public static String getChecksum(File file) {
|
||||||
if (file.isFile()) {
|
if (file.isFile()) {
|
||||||
try {
|
try {
|
||||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
|
|||||||
@@ -3,14 +3,16 @@ package org.parabot.environment.api.utils;
|
|||||||
/**
|
/**
|
||||||
* A simple class to filter things out of an collection
|
* A simple class to filter things out of an collection
|
||||||
*
|
*
|
||||||
* @author Everel
|
|
||||||
*
|
|
||||||
* @param <F>
|
* @param <F>
|
||||||
|
*
|
||||||
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public interface Filter<F> {
|
public interface Filter<F> {
|
||||||
/**
|
/**
|
||||||
* Determines if this object should be accepted
|
* Determines if this object should be accepted
|
||||||
|
*
|
||||||
* @param f
|
* @param f
|
||||||
|
*
|
||||||
* @return <b>true</b> to include this object, otherwise <b>false</b> to exclude.
|
* @return <b>true</b> to include this object, otherwise <b>false</b> to exclude.
|
||||||
*/
|
*/
|
||||||
public boolean accept(F f);
|
public boolean accept(F f);
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ package org.parabot.environment.api.utils;
|
|||||||
public class JavaUtil {
|
public class JavaUtil {
|
||||||
public static double JAVA_VERSION = getVersion();
|
public static double JAVA_VERSION = getVersion();
|
||||||
|
|
||||||
static double getVersion () {
|
static double getVersion() {
|
||||||
String version = System.getProperty("java.version");
|
String version = System.getProperty("java.version");
|
||||||
int pos = version.indexOf('.');
|
int pos = version.indexOf('.');
|
||||||
pos = version.indexOf('.', pos+1);
|
pos = version.indexOf('.', pos + 1);
|
||||||
return Double.parseDouble (version.substring (0, pos));
|
return Double.parseDouble(version.substring(0, pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,16 @@ package org.parabot.environment.api.utils;
|
|||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Helper class for calculating setters for clients that uses multipliers
|
* Helper class for calculating setters for clients that uses multipliers
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Multipliers {
|
public class Multipliers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param multiplier the multiplier
|
||||||
|
* @param set the value you want to set
|
||||||
*
|
*
|
||||||
* @param multiplier
|
|
||||||
* the multiplier
|
|
||||||
* @param set
|
|
||||||
* the value you want to set
|
|
||||||
* @return the correct setter value
|
* @return the correct setter value
|
||||||
*/
|
*/
|
||||||
public static int getIntSetter(int multiplier, int set) {
|
public static int getIntSetter(int multiplier, int set) {
|
||||||
@@ -28,11 +24,9 @@ public class Multipliers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param multiplier the multiplier
|
||||||
|
* @param set the value you want to set
|
||||||
*
|
*
|
||||||
* @param multiplier
|
|
||||||
* the multiplier
|
|
||||||
* @param set
|
|
||||||
* the value you want to set
|
|
||||||
* @return the correct setter value
|
* @return the correct setter value
|
||||||
*/
|
*/
|
||||||
public static long getLongSetter(long multiplier, long set) {
|
public static long getLongSetter(long multiplier, long set) {
|
||||||
|
|||||||
@@ -19,16 +19,14 @@ import java.util.Properties;
|
|||||||
public class PBPreferences {
|
public class PBPreferences {
|
||||||
|
|
||||||
private static AccountManager manager;
|
private static AccountManager manager;
|
||||||
|
|
||||||
private Properties properties;
|
|
||||||
private int scriptID;
|
|
||||||
|
|
||||||
public static final AccountManagerAccess MANAGER_FETCHER = new AccountManagerAccess() {
|
public static final AccountManagerAccess MANAGER_FETCHER = new AccountManagerAccess() {
|
||||||
@Override
|
@Override
|
||||||
public final void setManager(AccountManager manager) {
|
public final void setManager(AccountManager manager) {
|
||||||
PBPreferences.manager = manager;
|
PBPreferences.manager = manager;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private Properties properties;
|
||||||
|
private int scriptID;
|
||||||
|
|
||||||
public PBPreferences(int scriptID) {
|
public PBPreferences(int scriptID) {
|
||||||
this.scriptID = scriptID;
|
this.scriptID = scriptID;
|
||||||
@@ -45,7 +43,7 @@ public class PBPreferences {
|
|||||||
|
|
||||||
JSONArray resultArray;
|
JSONArray resultArray;
|
||||||
if ((resultArray = ((JSONArray) result.get("result"))) != null) {
|
if ((resultArray = ((JSONArray) result.get("result"))) != null) {
|
||||||
for(Object rObject : resultArray) {
|
for (Object rObject : resultArray) {
|
||||||
JSONObject resultObject = (JSONObject) rObject;
|
JSONObject resultObject = (JSONObject) rObject;
|
||||||
for (Object map : resultObject.entrySet()) {
|
for (Object map : resultObject.entrySet()) {
|
||||||
Map.Entry<?, ?> pairs = (Map.Entry<?, ?>) map;
|
Map.Entry<?, ?> pairs = (Map.Entry<?, ?>) map;
|
||||||
@@ -60,6 +58,7 @@ public class PBPreferences {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change a setting
|
* Change a setting
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@@ -69,27 +68,32 @@ public class PBPreferences {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a setting value
|
* Get a setting value
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Object getSetting(Object key){
|
public Object getSetting(Object key) {
|
||||||
return this.properties.get(key);
|
return this.properties.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a setting value as string
|
* Get a setting value as string
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getSetting(String key){
|
public String getSetting(String key) {
|
||||||
return this.properties.getProperty(key);
|
return this.properties.getProperty(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a setting
|
* Remove a setting
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public void removeSetting(Object key){
|
public void removeSetting(Object key) {
|
||||||
try {
|
try {
|
||||||
JSONObject result = (JSONObject) WebUtil.getJsonParser().parse(
|
JSONObject result = (JSONObject) WebUtil.getJsonParser().parse(
|
||||||
WebUtil.getContents("http://bdn.parabot.org/api/v2/user/preferences/set/",
|
WebUtil.getContents("http://bdn.parabot.org/api/v2/user/preferences/set/",
|
||||||
@@ -98,7 +102,7 @@ public class PBPreferences {
|
|||||||
"&script=" + String.valueOf(scriptID)
|
"&script=" + String.valueOf(scriptID)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ((boolean)result.get("result")){
|
if ((boolean) result.get("result")) {
|
||||||
this.properties.remove(key);
|
this.properties.remove(key);
|
||||||
}
|
}
|
||||||
} catch (ParseException | MalformedURLException | UnsupportedEncodingException e) {
|
} catch (ParseException | MalformedURLException | UnsupportedEncodingException e) {
|
||||||
@@ -108,10 +112,11 @@ public class PBPreferences {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a setting
|
* Add a setting
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
public void addSetting(Object key, Object value){
|
public void addSetting(Object key, Object value) {
|
||||||
try {
|
try {
|
||||||
JSONObject result = (JSONObject) WebUtil.getJsonParser().parse(
|
JSONObject result = (JSONObject) WebUtil.getJsonParser().parse(
|
||||||
WebUtil.getContents("http://bdn.parabot.org/api/v2/user/preferences/set/",
|
WebUtil.getContents("http://bdn.parabot.org/api/v2/user/preferences/set/",
|
||||||
@@ -121,7 +126,7 @@ public class PBPreferences {
|
|||||||
"&script=" + String.valueOf(scriptID)
|
"&script=" + String.valueOf(scriptID)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ((boolean)result.get("result")){
|
if ((boolean) result.get("result")) {
|
||||||
this.properties.put(key, value);
|
this.properties.put(key, value);
|
||||||
}
|
}
|
||||||
} catch (ParseException | MalformedURLException | UnsupportedEncodingException e) {
|
} catch (ParseException | MalformedURLException | UnsupportedEncodingException e) {
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package org.parabot.environment.api.utils;
|
package org.parabot.environment.api.utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* A random class is used for generating random numbers
|
* A random class is used for generating random numbers
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Random {
|
public class Random {
|
||||||
private final static java.util.Random RANDOM = new java.util.Random();
|
private final static java.util.Random RANDOM = new java.util.Random();
|
||||||
@@ -15,6 +13,7 @@ public class Random {
|
|||||||
*
|
*
|
||||||
* @param min
|
* @param min
|
||||||
* @param max
|
* @param max
|
||||||
|
*
|
||||||
* @return randomized number
|
* @return randomized number
|
||||||
*/
|
*/
|
||||||
public static int between(final int min, final int max) {
|
public static int between(final int min, final int max) {
|
||||||
|
|||||||
@@ -3,16 +3,15 @@ package org.parabot.environment.api.utils;
|
|||||||
import org.parabot.environment.scripts.framework.SleepCondition;
|
import org.parabot.environment.scripts.framework.SleepCondition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Holds various Time utilities
|
* Holds various Time utilities
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class Time {
|
public final class Time {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sleeps for a given amount of time
|
* Sleeps for a given amount of time
|
||||||
|
*
|
||||||
* @param ms
|
* @param ms
|
||||||
*/
|
*/
|
||||||
public static void sleep(final int ms) {
|
public static void sleep(final int ms) {
|
||||||
@@ -23,9 +22,7 @@ public final class Time {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param minumum
|
* @param minumum
|
||||||
* @param maximum
|
* @param maximum
|
||||||
*/
|
*/
|
||||||
@@ -40,10 +37,9 @@ public final class Time {
|
|||||||
/**
|
/**
|
||||||
* Sleeps until the SleepCondition is valid.
|
* Sleeps until the SleepCondition is valid.
|
||||||
*
|
*
|
||||||
* @param conn
|
* @param conn the condition.
|
||||||
* the condition.
|
* @param timeout the time in miliseconds before it stops sleeping.
|
||||||
* @param timeout
|
*
|
||||||
* the time in miliseconds before it stops sleeping.
|
|
||||||
* @return whether it ran successfully without timing out.
|
* @return whether it ran successfully without timing out.
|
||||||
*/
|
*/
|
||||||
public static boolean sleep(SleepCondition conn, int timeout) {
|
public static boolean sleep(SleepCondition conn, int timeout) {
|
||||||
@@ -59,6 +55,7 @@ public final class Time {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets current time in milliseconds
|
* Gets current time in milliseconds
|
||||||
|
*
|
||||||
* @return time in ms
|
* @return time in ms
|
||||||
*/
|
*/
|
||||||
public static long get() {
|
public static long get() {
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import org.parabot.core.ui.utils.UILog;
|
|||||||
|
|
||||||
public class Version implements Comparable<Version> {
|
public class Version implements Comparable<Version> {
|
||||||
|
|
||||||
private String version;
|
|
||||||
|
|
||||||
private static boolean notified;
|
private static boolean notified;
|
||||||
|
private String version;
|
||||||
|
|
||||||
public Version(String version) {
|
public Version(String version) {
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
@@ -18,11 +17,24 @@ public class Version implements Comparable<Version> {
|
|||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void notifyRC() {
|
||||||
|
if (!notified) {
|
||||||
|
UILog.log(
|
||||||
|
"Version warning",
|
||||||
|
"This is an RC version of Parabot\n" +
|
||||||
|
"This could be an unstable version of Parabot, and might crash at anytime\n\n" +
|
||||||
|
"If you find an error within the client, please report any at:\n" +
|
||||||
|
"https://github.com/Parabot/Parabot/issues"
|
||||||
|
);
|
||||||
|
notified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public final String get() {
|
public final String get() {
|
||||||
return this.version;
|
return this.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNightly(){
|
public boolean isNightly() {
|
||||||
return this.version.contains("RC");
|
return this.version.contains("RC");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,17 +72,4 @@ public class Version implements Comparable<Version> {
|
|||||||
public boolean equals(Object that) {
|
public boolean equals(Object that) {
|
||||||
return this == that || that != null && this.getClass() == that.getClass() && this.compareTo((Version) that) == 0;
|
return this == that || that != null && this.getClass() == that.getClass() && this.compareTo((Version) that) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void notifyRC() {
|
|
||||||
if (!notified) {
|
|
||||||
UILog.log(
|
|
||||||
"Version warning",
|
|
||||||
"This is an RC version of Parabot\n" +
|
|
||||||
"This could be an unstable version of Parabot, and might crash at anytime\n\n" +
|
|
||||||
"If you find an error within the client, please report any at:\n" +
|
|
||||||
"https://github.com/Parabot/Parabot/issues"
|
|
||||||
);
|
|
||||||
notified = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,32 @@
|
|||||||
package org.parabot.environment.input;
|
package org.parabot.environment.input;
|
||||||
|
|
||||||
import java.awt.Component;
|
import org.parabot.core.Context;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.parabot.core.Context;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Virtual keyboard, dispatches key events to a component.
|
* Virtual keyboard, dispatches key events to a component.
|
||||||
*
|
*
|
||||||
* @author Everel, Matt, Dane
|
* @author Everel, Matt, Dane
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Keyboard implements KeyListener {
|
public class Keyboard implements KeyListener {
|
||||||
private static HashMap<Character, Character> specialChars;
|
private static HashMap<Character, Character> specialChars;
|
||||||
|
|
||||||
|
static {
|
||||||
|
char[] spChars = { '~', '!', '@', '#', '%', '^', '&', '*', '(', ')',
|
||||||
|
'_', '+', '{', '}', ':', '<', '>', '?', '"', '|' };
|
||||||
|
char[] replace = { '`', '1', '2', '3', '5', '6', '7', '8', '9', '0',
|
||||||
|
'-', '=', '[', ']', ';', ',', '.', '/', '\'', '\\' };
|
||||||
|
specialChars = new HashMap<Character, Character>(spChars.length);
|
||||||
|
for (int x = 0; x < spChars.length; ++x) {
|
||||||
|
specialChars.put(spChars[x], replace[x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Component component;
|
private Component component;
|
||||||
private long pressTime;
|
private long pressTime;
|
||||||
|
|
||||||
@@ -28,16 +38,6 @@ public class Keyboard implements KeyListener {
|
|||||||
return Context.getInstance().getKeyboard();
|
return Context.getInstance().getKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
|
||||||
char[] spChars = { '~', '!', '@', '#', '%', '^', '&', '*', '(', ')',
|
|
||||||
'_', '+', '{', '}', ':', '<', '>', '?', '"', '|' };
|
|
||||||
char[] replace = { '`', '1', '2', '3', '5', '6', '7', '8', '9', '0',
|
|
||||||
'-', '=', '[', ']', ';', ',', '.', '/', '\'', '\\' };
|
|
||||||
specialChars = new HashMap<Character, Character>(spChars.length);
|
|
||||||
for (int x = 0; x < spChars.length; ++x)
|
|
||||||
specialChars.put(spChars[x], replace[x]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long getRandom() {
|
private static long getRandom() {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
return rand.nextInt(100) + 40;
|
return rand.nextInt(100) + 40;
|
||||||
@@ -46,7 +46,7 @@ public class Keyboard implements KeyListener {
|
|||||||
public void sendKeys(String s) {
|
public void sendKeys(String s) {
|
||||||
|
|
||||||
pressTime = System.currentTimeMillis();
|
pressTime = System.currentTimeMillis();
|
||||||
for (char c : s.toCharArray())
|
for (char c : s.toCharArray()) {
|
||||||
for (KeyEvent ke : createKeyClick(component, c)) {
|
for (KeyEvent ke : createKeyClick(component, c)) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(5);
|
Thread.sleep(5);
|
||||||
@@ -55,22 +55,25 @@ public class Keyboard implements KeyListener {
|
|||||||
}
|
}
|
||||||
sendKeyEvent(ke);
|
sendKeyEvent(ke);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
clickKey(10);
|
clickKey(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickKey(char c) {
|
public void clickKey(char c) {
|
||||||
|
|
||||||
pressTime = System.currentTimeMillis();
|
pressTime = System.currentTimeMillis();
|
||||||
for (KeyEvent ke : createKeyClick(component, c))
|
for (KeyEvent ke : createKeyClick(component, c)) {
|
||||||
sendKeyEvent(ke);
|
sendKeyEvent(ke);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void clickKey(int keyCode) {
|
public void clickKey(int keyCode) {
|
||||||
|
|
||||||
pressTime = System.currentTimeMillis();
|
pressTime = System.currentTimeMillis();
|
||||||
for (KeyEvent ke : createKeyClick(component, keyCode))
|
for (KeyEvent ke : createKeyClick(component, keyCode)) {
|
||||||
sendKeyEvent(ke);
|
sendKeyEvent(ke);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void pressKey(int keyCode) {
|
public void pressKey(int keyCode) {
|
||||||
|
|
||||||
@@ -103,7 +106,7 @@ public class Keyboard implements KeyListener {
|
|||||||
KeyEvent released = new KeyEvent(target, KeyEvent.KEY_RELEASED,
|
KeyEvent released = new KeyEvent(target, KeyEvent.KEY_RELEASED,
|
||||||
pressTime, 0, keyCode, c);
|
pressTime, 0, keyCode, c);
|
||||||
|
|
||||||
return new KeyEvent[] { pressed, typed, released };
|
return new KeyEvent[]{ pressed, typed, released };
|
||||||
} else {
|
} else {
|
||||||
KeyEvent shiftDown = new KeyEvent(target, KeyEvent.KEY_PRESSED,
|
KeyEvent shiftDown = new KeyEvent(target, KeyEvent.KEY_PRESSED,
|
||||||
pressTime, KeyEvent.SHIFT_MASK, KeyEvent.VK_SHIFT,
|
pressTime, KeyEvent.SHIFT_MASK, KeyEvent.VK_SHIFT,
|
||||||
@@ -121,7 +124,7 @@ public class Keyboard implements KeyListener {
|
|||||||
KeyEvent shiftUp = new KeyEvent(target, KeyEvent.KEY_RELEASED,
|
KeyEvent shiftUp = new KeyEvent(target, KeyEvent.KEY_RELEASED,
|
||||||
pressTime, 0, KeyEvent.VK_SHIFT, KeyEvent.CHAR_UNDEFINED);
|
pressTime, 0, KeyEvent.VK_SHIFT, KeyEvent.CHAR_UNDEFINED);
|
||||||
|
|
||||||
return new KeyEvent[] { shiftDown, pressed, typed, released,
|
return new KeyEvent[]{ shiftDown, pressed, typed, released,
|
||||||
shiftUp };
|
shiftUp };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,7 +147,7 @@ public class Keyboard implements KeyListener {
|
|||||||
KeyEvent released = new KeyEvent(target, KeyEvent.KEY_RELEASED,
|
KeyEvent released = new KeyEvent(target, KeyEvent.KEY_RELEASED,
|
||||||
pressTime + getRandom(), 0, keyCode, KeyEvent.CHAR_UNDEFINED);
|
pressTime + getRandom(), 0, keyCode, KeyEvent.CHAR_UNDEFINED);
|
||||||
|
|
||||||
return new KeyEvent[] { pressed, released };
|
return new KeyEvent[]{ pressed, released };
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyEvent createKeyPress(Component target, int keyCode) {
|
private KeyEvent createKeyPress(Component target, int keyCode) {
|
||||||
@@ -188,7 +191,7 @@ public class Keyboard implements KeyListener {
|
|||||||
|
|
||||||
public void sendKeyEvent(KeyEvent e) {
|
public void sendKeyEvent(KeyEvent e) {
|
||||||
for (KeyListener kl : component.getKeyListeners()) {
|
for (KeyListener kl : component.getKeyListeners()) {
|
||||||
if(kl instanceof Keyboard) {
|
if (kl instanceof Keyboard) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!e.isConsumed()) {
|
if (!e.isConsumed()) {
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ import java.awt.event.MouseListener;
|
|||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* A virtual mouse, dispatches mouse events to a component
|
* A virtual mouse, dispatches mouse events to a component
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Mouse implements MouseListener, MouseMotionListener {
|
public class Mouse implements MouseListener, MouseMotionListener {
|
||||||
private Component component;
|
private Component component;
|
||||||
@@ -30,6 +28,7 @@ public class Mouse implements MouseListener, MouseMotionListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the mouse to the given point and clicks
|
* Moves the mouse to the given point and clicks
|
||||||
|
*
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
* @param left
|
* @param left
|
||||||
@@ -49,8 +48,8 @@ public class Mouse implements MouseListener, MouseMotionListener {
|
|||||||
MouseEvent me = new MouseEvent(component,
|
MouseEvent me = new MouseEvent(component,
|
||||||
MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, x,
|
MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, x,
|
||||||
y, 1, false, left ? MouseEvent.BUTTON1 : MouseEvent.BUTTON3);
|
y, 1, false, left ? MouseEvent.BUTTON1 : MouseEvent.BUTTON3);
|
||||||
for(MouseListener l : component.getMouseListeners()) {
|
for (MouseListener l : component.getMouseListeners()) {
|
||||||
if(!(l instanceof Mouse)) {
|
if (!(l instanceof Mouse)) {
|
||||||
l.mousePressed(me);
|
l.mousePressed(me);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,8 +69,8 @@ public class Mouse implements MouseListener, MouseMotionListener {
|
|||||||
MouseEvent me = new MouseEvent(component,
|
MouseEvent me = new MouseEvent(component,
|
||||||
MouseEvent.MOUSE_CLICKED, System.currentTimeMillis(), 0, x,
|
MouseEvent.MOUSE_CLICKED, System.currentTimeMillis(), 0, x,
|
||||||
y, 0, false, left ? MouseEvent.BUTTON1 : MouseEvent.BUTTON3);
|
y, 0, false, left ? MouseEvent.BUTTON1 : MouseEvent.BUTTON3);
|
||||||
for(MouseListener l : component.getMouseListeners()) {
|
for (MouseListener l : component.getMouseListeners()) {
|
||||||
if(!(l instanceof Mouse)) {
|
if (!(l instanceof Mouse)) {
|
||||||
l.mouseClicked(me);
|
l.mouseClicked(me);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,8 +85,8 @@ public class Mouse implements MouseListener, MouseMotionListener {
|
|||||||
MouseEvent me = new MouseEvent(component,
|
MouseEvent me = new MouseEvent(component,
|
||||||
MouseEvent.MOUSE_RELEASED, System.currentTimeMillis(), 0, x,
|
MouseEvent.MOUSE_RELEASED, System.currentTimeMillis(), 0, x,
|
||||||
y, 0, false, left ? MouseEvent.BUTTON1 : MouseEvent.BUTTON3);
|
y, 0, false, left ? MouseEvent.BUTTON1 : MouseEvent.BUTTON3);
|
||||||
for(MouseListener l : component.getMouseListeners()) {
|
for (MouseListener l : component.getMouseListeners()) {
|
||||||
if(!(l instanceof Mouse)) {
|
if (!(l instanceof Mouse)) {
|
||||||
l.mouseReleased(me);
|
l.mouseReleased(me);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,6 +97,7 @@ public class Mouse implements MouseListener, MouseMotionListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the mouse cursor to the given location
|
* Moves the mouse cursor to the given location
|
||||||
|
*
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
*/
|
*/
|
||||||
@@ -106,8 +106,8 @@ public class Mouse implements MouseListener, MouseMotionListener {
|
|||||||
MouseEvent me = new MouseEvent(component,
|
MouseEvent me = new MouseEvent(component,
|
||||||
MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, x,
|
MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, x,
|
||||||
y, 0, false);
|
y, 0, false);
|
||||||
for(MouseMotionListener l : component.getMouseMotionListeners()) {
|
for (MouseMotionListener l : component.getMouseMotionListeners()) {
|
||||||
if(!(l instanceof Mouse)) {
|
if (!(l instanceof Mouse)) {
|
||||||
l.mouseMoved(me);
|
l.mouseMoved(me);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,6 +118,7 @@ public class Mouse implements MouseListener, MouseMotionListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Mouse cursor current location
|
* Mouse cursor current location
|
||||||
|
*
|
||||||
* @return point
|
* @return point
|
||||||
*/
|
*/
|
||||||
public Point getPoint() {
|
public Point getPoint() {
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public class RandomHandler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param random
|
* @param random
|
||||||
|
*
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -77,15 +78,6 @@ public class RandomHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the whole random arraylist to the arraylist given as argument
|
|
||||||
*
|
|
||||||
* @param randoms The new random arraylist
|
|
||||||
*/
|
|
||||||
public void setRandoms(ArrayList<Random> randoms) {
|
|
||||||
this.randoms = randoms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all added randoms
|
* Clears all added randoms
|
||||||
*/
|
*/
|
||||||
@@ -104,15 +96,16 @@ public class RandomHandler {
|
|||||||
* Executes a specific random
|
* Executes a specific random
|
||||||
*
|
*
|
||||||
* @param r
|
* @param r
|
||||||
|
*
|
||||||
* @return True if the random is executed, false if not
|
* @return True if the random is executed, false if not
|
||||||
*/
|
*/
|
||||||
public boolean executeRandom(Random r){
|
public boolean executeRandom(Random r) {
|
||||||
if (r.activate()) {
|
if (r.activate()) {
|
||||||
Logger.addMessage("Running random '" + r.getName() + "'", true);
|
Logger.addMessage("Running random '" + r.getName() + "'", true);
|
||||||
try {
|
try {
|
||||||
r.execute();
|
r.execute();
|
||||||
return true;
|
return true;
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
Logger.addMessage("Random failed: '" + r.getName() + "'", false);
|
Logger.addMessage("Random failed: '" + r.getName() + "'", false);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -126,7 +119,7 @@ public class RandomHandler {
|
|||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
public void runAll(RandomType type){
|
public void runAll(RandomType type) {
|
||||||
for (Random r : this.activeRandoms) {
|
for (Random r : this.activeRandoms) {
|
||||||
if (r.getRandomType().getId() == type.getId()) {
|
if (r.getRandomType().getId() == type.getId()) {
|
||||||
executeRandom(r);
|
executeRandom(r);
|
||||||
@@ -152,6 +145,7 @@ public class RandomHandler {
|
|||||||
* Checks if random occurs and runs it
|
* Checks if random occurs and runs it
|
||||||
*
|
*
|
||||||
* @return returns <b>true</b> if a random has been executed, otherwise <b>false</b>
|
* @return returns <b>true</b> if a random has been executed, otherwise <b>false</b>
|
||||||
|
*
|
||||||
* @see RandomHandler#checkAndRun(RandomType)
|
* @see RandomHandler#checkAndRun(RandomType)
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@@ -165,6 +159,15 @@ public class RandomHandler {
|
|||||||
return this.randoms;
|
return this.randoms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the whole random arraylist to the arraylist given as argument
|
||||||
|
*
|
||||||
|
* @param randoms The new random arraylist
|
||||||
|
*/
|
||||||
|
public void setRandoms(ArrayList<Random> randoms) {
|
||||||
|
this.randoms = randoms;
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayList<Random> getActiveRandoms() {
|
public ArrayList<Random> getActiveRandoms() {
|
||||||
return this.activeRandoms;
|
return this.activeRandoms;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ public enum RandomType {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RandomType getDefault() {
|
||||||
|
return SCRIPT;
|
||||||
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -25,8 +29,4 @@ public enum RandomType {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RandomType getDefault() {
|
|
||||||
return SCRIPT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,47 +5,15 @@ import org.parabot.core.ui.images.Images;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Holds script categories
|
* Holds script categories
|
||||||
*
|
*
|
||||||
* @author Dane, Paradox
|
* @author Dane, Paradox
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public enum Category
|
public enum Category {
|
||||||
{
|
|
||||||
|
|
||||||
AGILITY, COMBAT, COOKING, CRAFTING, CONSTRUCTION, DUNGEONEERING, FARMING, FIREMAKING, FISHING, FLETCHING, HERBLORE, HUNTER, MAGIC, MINIGAMES, MINING, MONEYMAKING, OTHER, PRAYER, RUNECRAFTING, SLAYER, SMITHING, THIEVING, UTILITY, WOODCUTTING;
|
AGILITY, COMBAT, COOKING, CRAFTING, CONSTRUCTION, DUNGEONEERING, FARMING, FIREMAKING, FISHING, FLETCHING, HERBLORE, HUNTER, MAGIC, MINIGAMES, MINING, MONEYMAKING, OTHER, PRAYER, RUNECRAFTING, SLAYER, SMITHING, THIEVING, UTILITY, WOODCUTTING;
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets image belonging to this category
|
|
||||||
* @return icon
|
|
||||||
*/
|
|
||||||
public BufferedImage getIcon() {
|
|
||||||
return Category.getIcon(this.name().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets category icon image from filename
|
|
||||||
* @param s Name of the image - used for the hashmap index
|
|
||||||
* @return icon
|
|
||||||
*/
|
|
||||||
public static BufferedImage getIcon(String s) {
|
|
||||||
if (images.get(s) == null) {
|
|
||||||
images.put(s, Images.getResource("/storage/images/category/" + s + ".png"));
|
|
||||||
}
|
|
||||||
return images.get(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder b = new StringBuilder();
|
|
||||||
b.append(name().charAt(0));
|
|
||||||
b.append(name().toLowerCase().substring(1));
|
|
||||||
return new String(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache
|
* Cache
|
||||||
*/
|
*/
|
||||||
@@ -55,4 +23,35 @@ public enum Category
|
|||||||
images.put("script", Images.getResource("/storage/images/category/script.png"));
|
images.put("script", Images.getResource("/storage/images/category/script.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets category icon image from filename
|
||||||
|
*
|
||||||
|
* @param s Name of the image - used for the hashmap index
|
||||||
|
*
|
||||||
|
* @return icon
|
||||||
|
*/
|
||||||
|
public static BufferedImage getIcon(String s) {
|
||||||
|
if (images.get(s) == null) {
|
||||||
|
images.put(s, Images.getResource("/storage/images/category/" + s + ".png"));
|
||||||
|
}
|
||||||
|
return images.get(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets image belonging to this category
|
||||||
|
*
|
||||||
|
* @return icon
|
||||||
|
*/
|
||||||
|
public BufferedImage getIcon() {
|
||||||
|
return Category.getIcon(this.name().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
b.append(name().charAt(0));
|
||||||
|
b.append(name().toLowerCase().substring(1));
|
||||||
|
return new String(b);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package org.parabot.environment.scripts;
|
package org.parabot.environment.scripts;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import org.parabot.environment.scripts.framework.AbstractFramework;
|
import org.parabot.environment.scripts.framework.AbstractFramework;
|
||||||
import org.parabot.environment.scripts.framework.LoopTask;
|
import org.parabot.environment.scripts.framework.LoopTask;
|
||||||
import org.parabot.environment.scripts.framework.Strategy;
|
import org.parabot.environment.scripts.framework.Strategy;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Holds various script frameworks
|
* Holds various script frameworks
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Frameworks {
|
public class Frameworks {
|
||||||
|
|
||||||
@@ -31,10 +29,11 @@ class Looper extends AbstractFramework {
|
|||||||
public Looper(LoopTask loopTask) {
|
public Looper(LoopTask loopTask) {
|
||||||
this.loopTask = loopTask;
|
this.loopTask = loopTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute() {
|
public boolean execute() {
|
||||||
int sleepTime = loopTask.loop();
|
int sleepTime = loopTask.loop();
|
||||||
if(sleepTime < 0) {
|
if (sleepTime < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -55,8 +54,8 @@ class StrategyWorker extends AbstractFramework {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute() {
|
public boolean execute() {
|
||||||
for(Strategy s : strategies) {
|
for (Strategy s : strategies) {
|
||||||
if(s.activate()) {
|
if (s.activate()) {
|
||||||
s.execute();
|
s.execute();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import org.parabot.core.ui.BotUI;
|
|||||||
import org.parabot.core.ui.Logger;
|
import org.parabot.core.ui.Logger;
|
||||||
import org.parabot.environment.api.utils.PBPreferences;
|
import org.parabot.environment.api.utils.PBPreferences;
|
||||||
import org.parabot.environment.api.utils.Time;
|
import org.parabot.environment.api.utils.Time;
|
||||||
|
import org.parabot.environment.randoms.Random;
|
||||||
import org.parabot.environment.randoms.RandomType;
|
import org.parabot.environment.randoms.RandomType;
|
||||||
import org.parabot.environment.scripts.framework.*;
|
import org.parabot.environment.scripts.framework.*;
|
||||||
import org.parabot.environment.scripts.framework.Frameworks;
|
import org.parabot.environment.scripts.framework.Frameworks;
|
||||||
import org.parabot.environment.scripts.randoms.Random;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -61,6 +61,11 @@ public class Script implements Runnable {
|
|||||||
this.frameWork = f;
|
this.frameWork = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public final void addRandom(org.parabot.environment.scripts.randoms.Random random) {
|
||||||
|
new IllegalArgumentException("This type of random is deprecated").printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
public final void addRandom(Random random) {
|
public final void addRandom(Random random) {
|
||||||
Context.getInstance().getRandomHandler().addRandom(random);
|
Context.getInstance().getRandomHandler().addRandom(random);
|
||||||
}
|
}
|
||||||
@@ -141,6 +146,7 @@ public class Script implements Runnable {
|
|||||||
*
|
*
|
||||||
* @param conn the condition.
|
* @param conn the condition.
|
||||||
* @param timeout the time in miliseconds before it stops sleeping.
|
* @param timeout the time in miliseconds before it stops sleeping.
|
||||||
|
*
|
||||||
* @return whether it ran successfully without timing out.
|
* @return whether it ran successfully without timing out.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -148,18 +154,6 @@ public class Script implements Runnable {
|
|||||||
return Time.sleep(conn, timeout);
|
return Time.sleep(conn, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the script's state
|
|
||||||
*
|
|
||||||
* @param state
|
|
||||||
*/
|
|
||||||
public final void setState(final int state) {
|
|
||||||
if (state < 0 || state > 2) {
|
|
||||||
throw new IllegalArgumentException("Illegal state");
|
|
||||||
}
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sleeps for an amount of milliseconds
|
* Sleeps for an amount of milliseconds
|
||||||
*
|
*
|
||||||
@@ -173,6 +167,18 @@ public class Script implements Runnable {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the script's state
|
||||||
|
*
|
||||||
|
* @param state
|
||||||
|
*/
|
||||||
|
public final void setState(final int state) {
|
||||||
|
if (state < 0 || state > 2) {
|
||||||
|
throw new IllegalArgumentException("Illegal state");
|
||||||
|
}
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
public PBPreferences getPreferences() {
|
public PBPreferences getPreferences() {
|
||||||
if (this.preferences == null) {
|
if (this.preferences == null) {
|
||||||
this.preferences = new PBPreferences(scriptID);
|
this.preferences = new PBPreferences(scriptID);
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A script manifest, holds all script data
|
* A script manifest, holds all script data
|
||||||
* @author Everel
|
|
||||||
*
|
*
|
||||||
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface ScriptManifest {
|
public @interface ScriptManifest {
|
||||||
|
|||||||
@@ -15,11 +15,9 @@ import java.net.URL;
|
|||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Loads a script from the BDN
|
* Loads a script from the BDN
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class BDNScriptsExecuter extends ScriptExecuter {
|
public class BDNScriptsExecuter extends ScriptExecuter {
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,9 @@ import org.parabot.environment.scripts.Script;
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Loads a locally stored script
|
* Loads a locally stored script
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class LocalScriptExecuter extends ScriptExecuter {
|
public class LocalScriptExecuter extends ScriptExecuter {
|
||||||
private Constructor<?> scriptConstructor;
|
private Constructor<?> scriptConstructor;
|
||||||
@@ -21,7 +19,7 @@ public class LocalScriptExecuter extends ScriptExecuter {
|
|||||||
@Override
|
@Override
|
||||||
public void run(ThreadGroup tg) {
|
public void run(ThreadGroup tg) {
|
||||||
try {
|
try {
|
||||||
super.finalize(tg, (Script) scriptConstructor.newInstance(new Object[] { }));
|
super.finalize(tg, (Script) scriptConstructor.newInstance(new Object[]{}));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user