mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 16:49:10 +00:00
Merge pull request #226 from Parabot/release/2.6.7
[MERGE] Release V2.6.7 into Development
This commit is contained in:
+1
-1
@@ -34,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.7
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
|
|||||||
@@ -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.7</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 {
|
||||||
|
|
||||||
@@ -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,21 +31,32 @@ 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,
|
||||||
@@ -122,18 +130,12 @@ public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
|||||||
.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;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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,18 +27,12 @@ public class AddInterfaceAdapter implements Injectable {
|
|||||||
this.interfaceClass = interfaceClass;
|
this.interfaceClass = interfaceClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setAccessorPackage(String packageName) {
|
|
||||||
accessorPackage = packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getAccessorPackage() {
|
public static String getAccessorPackage() {
|
||||||
return accessorPackage;
|
return accessorPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static void setAccessorPackage(String packageName) {
|
||||||
public void inject() {
|
accessorPackage = packageName;
|
||||||
Core.verbose("Injecting: " + this.toString());
|
|
||||||
addInterface(node, accessorPackage + interfaceClass);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void addInterface(ClassNode node, String i) {
|
protected static void addInterface(ClassNode node, String i) {
|
||||||
@@ -54,6 +46,12 @@ public class AddInterfaceAdapter implements Injectable {
|
|||||||
node.interfaces.add(i);
|
node.interfaces.add(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inject() {
|
||||||
|
Core.verbose("Injecting: " + this.toString());
|
||||||
|
addInterface(node, accessorPackage + interfaceClass);
|
||||||
|
}
|
||||||
|
|
||||||
@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;
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -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;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package org.parabot.core.asm.interfaces;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Injectable
|
* Injectable
|
||||||
* @author Everel
|
|
||||||
*
|
*
|
||||||
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public interface Injectable {
|
public interface Injectable {
|
||||||
|
|
||||||
|
|||||||
@@ -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,6 +1,5 @@
|
|||||||
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 {
|
||||||
@@ -59,7 +58,6 @@ public class ThreadRedirect {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -7,11 +7,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;
|
||||||
|
|||||||
@@ -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,6 +126,7 @@ 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) {
|
||||||
@@ -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,6 +184,7 @@ 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 {
|
||||||
@@ -204,8 +197,6 @@ public class ClassPath {
|
|||||||
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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|
||||||
|
|||||||
@@ -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,6 +50,7 @@ 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() {
|
||||||
@@ -66,6 +64,7 @@ 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() {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,11 +1,9 @@
|
|||||||
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;
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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++);
|
||||||
@@ -44,8 +41,9 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,9 +68,14 @@ public class NetworkInterface {
|
|||||||
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,14 +4,19 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public class Runtime {
|
public class Runtime {
|
||||||
|
|
||||||
private java.lang.Runtime rt;
|
|
||||||
|
|
||||||
private static Runtime cached;
|
private static Runtime cached;
|
||||||
|
private java.lang.Runtime rt;
|
||||||
|
|
||||||
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);
|
||||||
@@ -57,10 +62,4 @@ public class Runtime {
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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,6 +21,10 @@ 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);
|
||||||
}
|
}
|
||||||
@@ -42,10 +43,6 @@ public class PaintDebugger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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");
|
||||||
|
|||||||
@@ -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>();
|
||||||
@@ -49,4 +47,6 @@ public abstract class ScriptParser {
|
|||||||
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
|
||||||
|
|||||||
@@ -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<>();
|
||||||
@@ -48,4 +46,6 @@ public abstract class ServerParser {
|
|||||||
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
|
||||||
*
|
*
|
||||||
@@ -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>
|
||||||
*/
|
*/
|
||||||
@@ -234,8 +232,8 @@ public class RefClass extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* 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;
|
||||||
@@ -30,8 +28,8 @@ public class RefConstructor extends RefModifiers {
|
|||||||
/**
|
/**
|
||||||
* 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;
|
||||||
@@ -118,11 +116,10 @@ public class RefMethod extends RefModifiers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* 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) {
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,27 +45,13 @@ 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
|
||||||
*/
|
*/
|
||||||
@@ -96,6 +82,21 @@ public class Logger extends JPanel {
|
|||||||
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);
|
||||||
@@ -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));
|
||||||
|
|
||||||
@@ -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();
|
||||||
|
|||||||
@@ -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,6 +30,10 @@ 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;
|
||||||
@@ -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,7 +212,6 @@ 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,
|
||||||
@@ -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,11 +1,10 @@
|
|||||||
<?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>
|
||||||
@@ -65,9 +64,11 @@
|
|||||||
</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"
|
||||||
|
text="Start"/>
|
||||||
<Separator prefHeight="4.0" prefWidth="35.0" visible="false"/>
|
<Separator prefHeight="4.0" prefWidth="35.0" visible="false"/>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -60,6 +58,7 @@ public class PBPreferences {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change a setting
|
* Change a setting
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@@ -69,7 +68,9 @@ 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) {
|
||||||
@@ -78,7 +79,9 @@ public class PBPreferences {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 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) {
|
||||||
@@ -87,6 +90,7 @@ public class PBPreferences {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a setting
|
* Remove a setting
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public void removeSetting(Object key) {
|
public void removeSetting(Object key) {
|
||||||
@@ -108,6 +112,7 @@ public class PBPreferences {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a setting
|
* Add a setting
|
||||||
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package org.parabot.environment.api.utils;
|
package org.parabot.environment.api.utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* A simple timer class
|
* A simple timer class
|
||||||
*
|
*
|
||||||
* @author Everel, Parameter
|
* @author Everel, Parameter
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Timer {
|
public class Timer {
|
||||||
private long start;
|
private long start;
|
||||||
@@ -92,8 +90,8 @@ public class Timer {
|
|||||||
/**
|
/**
|
||||||
* Calculates hourly gains based on given variable
|
* Calculates hourly gains based on given variable
|
||||||
*
|
*
|
||||||
* @param gained
|
* @param gained variable
|
||||||
* variable
|
*
|
||||||
* @return hourly gains
|
* @return hourly gains
|
||||||
*/
|
*/
|
||||||
public int getPerHour(final int gained) {
|
public int getPerHour(final int gained) {
|
||||||
|
|||||||
@@ -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,6 +17,19 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -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) {
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
*/
|
*/
|
||||||
@@ -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,6 +96,7 @@ 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) {
|
||||||
@@ -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,6 +29,7 @@ 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();
|
||||||
|
|||||||
@@ -141,6 +141,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 +149,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 +162,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;
|
||||||
|
|||||||
@@ -3,11 +3,9 @@ package org.parabot.environment.scripts.executers;
|
|||||||
import org.parabot.environment.scripts.Script;
|
import org.parabot.environment.scripts.Script;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Executes a script
|
* Executes a script
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class ScriptExecuter {
|
public abstract class ScriptExecuter {
|
||||||
|
|
||||||
@@ -15,6 +13,7 @@ public abstract class ScriptExecuter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Start script.
|
* Start script.
|
||||||
|
*
|
||||||
* @param tg
|
* @param tg
|
||||||
* @param script
|
* @param script
|
||||||
*/
|
*/
|
||||||
@@ -23,5 +22,4 @@ public abstract class ScriptExecuter {
|
|||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
package org.parabot.environment.scripts.framework;
|
package org.parabot.environment.scripts.framework;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Abstract framework for a script
|
* Abstract framework for a script
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractFramework {
|
public abstract class AbstractFramework {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes this frame
|
* Executes this frame
|
||||||
|
*
|
||||||
* @return <b>true</b> if it should keep executing this framework, otherwise <b>false</b>.
|
* @return <b>true</b> if it should keep executing this framework, otherwise <b>false</b>.
|
||||||
*/
|
*/
|
||||||
public abstract boolean execute();
|
public abstract boolean execute();
|
||||||
|
|||||||
@@ -3,11 +3,9 @@ package org.parabot.environment.scripts.framework;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Holds various script frameworks
|
* Holds various script frameworks
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class Frameworks {
|
public class Frameworks {
|
||||||
|
|
||||||
@@ -27,6 +25,7 @@ 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();
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
package org.parabot.environment.scripts.framework;
|
package org.parabot.environment.scripts.framework;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* A LoopTask interface is used to keep calling the loop method which should return the sleep time
|
* A LoopTask interface is used to keep calling the loop method which should return the sleep time
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface LoopTask {
|
public interface LoopTask {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return sleepTime in ms
|
* @return sleepTime in ms
|
||||||
*/
|
*/
|
||||||
public int loop();
|
public int loop();
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ package org.parabot.environment.scripts.framework;
|
|||||||
* Keeps sleeping till a condition is valid
|
* Keeps sleeping till a condition is valid
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface SleepCondition {
|
public interface SleepCondition {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if condition is valid
|
* Determine if condition is valid
|
||||||
|
*
|
||||||
* @return <b>true</b> if valid, otherwise <b>false</b>.
|
* @return <b>true</b> if valid, otherwise <b>false</b>.
|
||||||
*/
|
*/
|
||||||
public boolean isValid();
|
public boolean isValid();
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ package org.parabot.environment.scripts.framework;
|
|||||||
* Strategy framework for scripts
|
* Strategy framework for scripts
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public interface Strategy {
|
public interface Strategy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to activate this strategy
|
* Whether to activate this strategy
|
||||||
|
*
|
||||||
* @return <b>true</b> if this strategy should be executed, otherwise <b>false</b>.
|
* @return <b>true</b> if this strategy should be executed, otherwise <b>false</b>.
|
||||||
*/
|
*/
|
||||||
public boolean activate();
|
public boolean activate();
|
||||||
|
|||||||
@@ -1,20 +1,17 @@
|
|||||||
package org.parabot.environment.scripts.loader;
|
package org.parabot.environment.scripts.loader;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import org.parabot.core.asm.ASMClassLoader;
|
import org.parabot.core.asm.ASMClassLoader;
|
||||||
import org.parabot.core.classpath.ClassPath;
|
import org.parabot.core.classpath.ClassPath;
|
||||||
import org.parabot.environment.scripts.Script;
|
import org.parabot.environment.scripts.Script;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* An environment to load a script
|
* An environment to load a script
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class JavaScriptLoader extends ASMClassLoader {
|
public class JavaScriptLoader extends ASMClassLoader {
|
||||||
private ClassPath classPath;
|
private ClassPath classPath;
|
||||||
@@ -24,18 +21,19 @@ public class JavaScriptLoader extends ASMClassLoader {
|
|||||||
this.classPath = classPath;
|
this.classPath = classPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all classes that extends ServerProvider
|
* Gets all classes that extends ServerProvider
|
||||||
|
*
|
||||||
* @return string array of class names that extends ServerProvider
|
* @return string array of class names that extends ServerProvider
|
||||||
*/
|
*/
|
||||||
public final String[] getScriptClassNames() {
|
public final String[] getScriptClassNames() {
|
||||||
final List<String> classNames = new ArrayList<String>();
|
final List<String> classNames = new ArrayList<String>();
|
||||||
for (ClassNode c : classPath.classes.values())
|
for (ClassNode c : classPath.classes.values()) {
|
||||||
if (c.superName.replace('/', '.').equals(
|
if (c.superName.replace('/', '.').equals(
|
||||||
Script.class.getName())) {
|
Script.class.getName())) {
|
||||||
classNames.add(c.name.replace('/', '.'));
|
classNames.add(c.name.replace('/', '.'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return classNames.toArray(new String[classNames.size()]);
|
return classNames.toArray(new String[classNames.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,15 @@ package org.parabot.environment.scripts.randoms;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Everel
|
* @author Everel
|
||||||
* @deprecated
|
|
||||||
* @see org.parabot.environment.randoms.Random
|
* @see org.parabot.environment.randoms.Random
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public interface Random {
|
public interface Random {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether this random should activate
|
* Determines whether this random should activate
|
||||||
|
*
|
||||||
* @return <b>true</b> if this random should activate
|
* @return <b>true</b> if this random should activate
|
||||||
*/
|
*/
|
||||||
public boolean activate();
|
public boolean activate();
|
||||||
@@ -21,12 +22,14 @@ public interface Random {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the random
|
* Returns the name of the random
|
||||||
|
*
|
||||||
* @return Name of the random
|
* @return Name of the random
|
||||||
*/
|
*/
|
||||||
public String getName();
|
public String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the server which the random is made for
|
* Returns the name of the server which the random is made for
|
||||||
|
*
|
||||||
* @return Name of the server
|
* @return Name of the server
|
||||||
*/
|
*/
|
||||||
public String getServer();
|
public String getServer();
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package org.parabot.environment.scripts.randoms;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Everel
|
* @author Everel
|
||||||
* @deprecated
|
|
||||||
* @see org.parabot.environment.randoms.RandomHandler
|
* @see org.parabot.environment.randoms.RandomHandler
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class RandomHandler extends org.parabot.environment.randoms.RandomHandler {
|
public class RandomHandler extends org.parabot.environment.randoms.RandomHandler {
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ import org.parabot.environment.servers.executers.ServerExecuter;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Loads locally stored server providers
|
* Loads locally stored server providers
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user