mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-10-01 02:17:22 +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: St/fecUDInFBCRriYqgp2F8PU9/SooorgxD9Mrs+b0EsC7AbtSsQXvdIv2Lp6xzdQ0VSXPcLIhULPOYrmBKnGQ/NjXTIZXxnroyQxxnI6xyEWIZwiHRY/bKRJDRbQTxD9NL32szKiDSwnw7pu6llF4D64UqQvziq4Gm6VohU75M=
|
||||
- secure: bD15GVZWowiknbfLavh8CxSh0GsnF5kT4kZ6ggCuUDGyj0mzqf7dNRnchQIKkCG0WRYyTrFN4pEiygeywWsipEeAVv9Xhx3cuUZmzeQaR5KCWabSwJ8gK6jZd1YhcWmM9vrdPHobZr65MP0y/8mu/Fovgky9dY7KDf4G3SebNrM=
|
||||
- PARABOT_VERSION=2.6.6.6
|
||||
- PARABOT_VERSION=2.6.7
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>org.parabot</groupId>
|
||||
<artifactId>client</artifactId>
|
||||
<version>2.6.6.6</version>
|
||||
<version>2.6.7</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
@@ -80,6 +80,14 @@ public class Context {
|
||||
return getInstance(null);
|
||||
}
|
||||
|
||||
public static String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public static void setUsername(String username) {
|
||||
Context.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
this.hookParser = hookParser;
|
||||
public Mouse getMouse() {
|
||||
return mouse;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,15 +114,14 @@ public class Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mouse
|
||||
* Gets the keyboard
|
||||
*
|
||||
* @return mouse
|
||||
* @return keyboard
|
||||
*/
|
||||
public Mouse getMouse() {
|
||||
return mouse;
|
||||
public Keyboard getKeyboard() {
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the keyboard
|
||||
*
|
||||
@@ -124,15 +131,6 @@ public class Context {
|
||||
this.keyboard = keyboard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the keyboard
|
||||
*
|
||||
* @return keyboard
|
||||
*/
|
||||
public Keyboard getKeyboard() {
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
/**
|
||||
* ClassPath
|
||||
*
|
||||
@@ -160,32 +158,9 @@ public class Context {
|
||||
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
|
||||
*
|
||||
* @param applet
|
||||
*/
|
||||
public void setApplet(final Applet applet) {
|
||||
@@ -237,6 +212,30 @@ public class Context {
|
||||
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
|
||||
*
|
||||
@@ -247,7 +246,6 @@ public class Context {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Sets provider info of this context
|
||||
*
|
||||
* @param providerInfo
|
||||
@@ -259,6 +257,7 @@ public class Context {
|
||||
/**
|
||||
* Gets ServerProvider info
|
||||
* Can be null if this is not a public server provider
|
||||
*
|
||||
* @return info about this provider
|
||||
*/
|
||||
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) {
|
||||
this.runningScript = script;
|
||||
public void setHookParser(final HookParser hookParser) {
|
||||
this.hookParser = hookParser;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,22 +345,24 @@ public class Context {
|
||||
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
|
||||
*
|
||||
* @return random handler
|
||||
*/
|
||||
public RandomHandler getRandomHandler() {
|
||||
return this.randomHandler;
|
||||
}
|
||||
|
||||
public static String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public static void setUsername(String username) {
|
||||
Context.username = username;
|
||||
}
|
||||
|
||||
public JSONParser getJsonParser() {
|
||||
return jsonParser;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,14 @@ public class ProjectProperties {
|
||||
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() {
|
||||
InputStream input;
|
||||
try {
|
||||
@@ -35,12 +43,4 @@ public class ProjectProperties {
|
||||
private Properties getCached() {
|
||||
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;
|
||||
|
||||
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.parabot.core.classpath.ClassPath;
|
||||
@@ -16,17 +15,15 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* Makes classnodes into runnable classes
|
||||
*
|
||||
* @author Everel
|
||||
* @author Matt
|
||||
*
|
||||
*/
|
||||
public class ASMClassLoader extends ClassLoader {
|
||||
|
||||
private Map<String, Class<?>> classCache;
|
||||
public ClassPath classPath;
|
||||
private Map<String, Class<?>> classCache;
|
||||
|
||||
public ASMClassLoader(final ClassPath classPath) {
|
||||
this.classCache = new HashMap<String, Class<?>>();
|
||||
|
||||
@@ -9,11 +9,9 @@ import org.parabot.core.Context;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* A collection of various asm util methods
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class ASMUtils implements Opcodes {
|
||||
|
||||
@@ -70,6 +68,7 @@ public class ASMUtils implements Opcodes {
|
||||
* Return right opcode for desc
|
||||
*
|
||||
* @param desc
|
||||
*
|
||||
* @return return opcode
|
||||
*/
|
||||
public static int getReturnOpcode(String desc) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||
|
||||
public class ClassRemapper extends Remapper {
|
||||
private static HashMap<String, String> remapNames = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
remapNames.put("java/net/Socket", "org/parabot/core/network/proxy/ProxySocket");
|
||||
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 {
|
||||
|
||||
private static final Map<String, Class<?>> redirects = new HashMap<String, Class<?>>();
|
||||
|
||||
private String className;
|
||||
|
||||
private static PrintStream str_out, class_out;
|
||||
|
||||
static {
|
||||
@@ -34,21 +31,32 @@ public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
||||
redirects.put("java/lang/System", SystemRedirect.class);
|
||||
}
|
||||
|
||||
private String className;
|
||||
|
||||
public RedirectClassAdapter(ClassVisitor cv) {
|
||||
super(ASM5, cv);
|
||||
if (str_out == null && Core.shouldDump())
|
||||
if (str_out == null && Core.shouldDump()) {
|
||||
try {
|
||||
str_out = new PrintStream(new FileOutputStream(new File(Directories.getWorkspace(), "strings.txt")));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(class_out == null && Core.shouldDump())
|
||||
}
|
||||
if (class_out == null && Core.shouldDump()) {
|
||||
try {
|
||||
class_out = new PrintStream(new FileOutputStream(new File(Directories.getWorkspace(), "classes.txt")));
|
||||
} catch (FileNotFoundException e) {
|
||||
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
|
||||
public void visit(int version, int access, String name, String signature,
|
||||
@@ -122,18 +130,12 @@ public class RedirectClassAdapter extends ClassVisitor implements Opcodes {
|
||||
.replaceAll("\\.", "/");
|
||||
}
|
||||
}
|
||||
if(class_out != null)
|
||||
if (class_out != null) {
|
||||
class_out.println(owner);
|
||||
}
|
||||
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;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
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.objectweb.asm.tree.*;
|
||||
import org.parabot.core.asm.ASMUtils;
|
||||
import org.parabot.core.asm.interfaces.Injectable;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* Injects a callback, invokes a given static method
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class AddCallbackAdapter implements Injectable, Opcodes {
|
||||
private MethodNode method;
|
||||
|
||||
@@ -2,12 +2,7 @@ package org.parabot.core.asm.adapters;
|
||||
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
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;
|
||||
import org.objectweb.asm.tree.*;
|
||||
|
||||
public class AddDebugAdapter {
|
||||
private ClassNode owner;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.parabot.core.asm.adapters;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
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.interfaces.Injectable;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
* Adds a method into a Classnode which returns a field
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class AddGetterAdapter implements Opcodes, Injectable {
|
||||
private ClassNode into;
|
||||
@@ -28,21 +27,13 @@ public class AddGetterAdapter implements Opcodes, Injectable {
|
||||
private long multiplier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param into
|
||||
* - classnode to inject getter method in
|
||||
* @param fieldLocation
|
||||
* - classnode where field is located
|
||||
* @param fieldNode
|
||||
* - field name to get
|
||||
* @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
|
||||
* @param into - classnode to inject getter method in
|
||||
* @param fieldLocation - classnode where field is located
|
||||
* @param fieldNode - field name to get
|
||||
* @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,
|
||||
final ClassNode fieldLocation, final FieldNode fieldNode,
|
||||
@@ -59,7 +50,6 @@ public class AddGetterAdapter implements Opcodes, Injectable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fieldLocation
|
||||
* @param fieldNode
|
||||
* @param methodName
|
||||
|
||||
@@ -7,11 +7,9 @@ import org.parabot.core.asm.ASMUtils;
|
||||
import org.parabot.core.asm.interfaces.Injectable;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class appends an interface to a class
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class AddInterfaceAdapter implements Injectable {
|
||||
private static String accessorPackage;
|
||||
@@ -29,18 +27,12 @@ public class AddInterfaceAdapter implements Injectable {
|
||||
this.interfaceClass = interfaceClass;
|
||||
}
|
||||
|
||||
public static void setAccessorPackage(String packageName) {
|
||||
accessorPackage = packageName;
|
||||
}
|
||||
|
||||
public static String getAccessorPackage() {
|
||||
return accessorPackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inject() {
|
||||
Core.verbose("Injecting: " + this.toString());
|
||||
addInterface(node, accessorPackage + interfaceClass);
|
||||
public static void setAccessorPackage(String packageName) {
|
||||
accessorPackage = packageName;
|
||||
}
|
||||
|
||||
protected static void addInterface(ClassNode node, String i) {
|
||||
@@ -54,6 +46,12 @@ public class AddInterfaceAdapter implements Injectable {
|
||||
node.interfaces.add(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inject() {
|
||||
Core.verbose("Injecting: " + this.toString());
|
||||
addInterface(node, accessorPackage + interfaceClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String 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;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
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.interfaces.Injectable;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* Injects a method which invokes an other method
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class AddInvokerAdapter implements Opcodes, Injectable {
|
||||
private ClassNode into;
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.parabot.core.asm.interfaces.Injectable;
|
||||
* Injects methods which sets a field
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class AddSetterAdapter implements Opcodes, Injectable {
|
||||
private ClassNode fieldLocation;
|
||||
@@ -38,8 +37,9 @@ public class AddSetterAdapter implements Opcodes, Injectable {
|
||||
|
||||
private static void addSetter(ClassNode fieldLocation, ClassNode into,
|
||||
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;";
|
||||
}
|
||||
MethodNode method = new MethodNode(ACC_PUBLIC
|
||||
| (methodStatic ? ACC_STATIC : 0), name, "(" + desc + ")V",
|
||||
null, null);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.parabot.core.asm.adapters;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
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.interfaces.Injectable;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is used for changing the super class of a class
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class AddSuperAdapter implements Injectable {
|
||||
private ClassNode node;
|
||||
@@ -32,12 +30,6 @@ public class AddSuperAdapter implements Injectable {
|
||||
this.superClass = superClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inject() {
|
||||
Core.verbose("Injecting: " + this.toString());
|
||||
setSuper(node, superClass);
|
||||
}
|
||||
|
||||
private static final void setSuper(final ClassNode node,
|
||||
final String superClass) {
|
||||
ListIterator<?> mli = node.methods.listIterator();
|
||||
@@ -60,6 +52,12 @@ public class AddSuperAdapter implements Injectable {
|
||||
node.superName = superClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inject() {
|
||||
Core.verbose("Injecting: " + this.toString());
|
||||
setSuper(node, superClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("[Injectable: super, class name: ")
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
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.JSONHookParser;
|
||||
import org.parabot.core.parsers.hooks.XMLHookParser;
|
||||
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 static final int TYPE_XML = 0;
|
||||
public static final int TYPE_JSON = 1;
|
||||
|
||||
@@ -2,8 +2,8 @@ package org.parabot.core.asm.interfaces;
|
||||
|
||||
/**
|
||||
* Injectable
|
||||
* @author Everel
|
||||
*
|
||||
* @author Everel
|
||||
*/
|
||||
public interface Injectable {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.parabot.core.asm.redirect;
|
||||
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.Directories;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.parabot.core.asm.redirect;
|
||||
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.asm.RedirectClassAdapter;
|
||||
|
||||
public class ThreadRedirect {
|
||||
@@ -59,7 +58,6 @@ public class ThreadRedirect {
|
||||
Thread.sleep(time);
|
||||
}
|
||||
|
||||
|
||||
public static void setUncaughtExceptionHandler(Thread t, Thread.UncaughtExceptionHandler handler) {
|
||||
t.setUncaughtExceptionHandler(handler);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,9 @@ import org.parabot.core.asm.adapters.AddCallbackAdapter;
|
||||
import org.parabot.core.asm.interfaces.Injectable;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is used for injecting a callback into a methodnode
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Callback implements Injectable {
|
||||
private MethodNode method;
|
||||
|
||||
@@ -8,11 +8,9 @@ import org.parabot.core.asm.adapters.AddGetterAdapter;
|
||||
import org.parabot.core.asm.interfaces.Injectable;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class injects a getter which gets a specific field
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Getter implements Injectable {
|
||||
private ClassNode into;
|
||||
@@ -24,7 +22,6 @@ public class Getter implements Injectable {
|
||||
private long multiplier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param into - classnode to inject getter method in
|
||||
* @param fieldLocation - classnode where field is located
|
||||
* @param fieldNode - field name to get
|
||||
@@ -48,7 +45,6 @@ public class Getter implements Injectable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fieldLocation
|
||||
* @param fieldNode
|
||||
* @param methodName
|
||||
@@ -64,6 +60,7 @@ public class Getter implements Injectable {
|
||||
|
||||
/**
|
||||
* Short route for getAdaptar().inject();
|
||||
*
|
||||
* @see AddGetterAdapter#inject
|
||||
*/
|
||||
@Override
|
||||
@@ -73,6 +70,7 @@ public class Getter implements Injectable {
|
||||
|
||||
/**
|
||||
* Gets the AddGetterAdapter
|
||||
*
|
||||
* @return AddGetterAdapter
|
||||
*/
|
||||
public AddGetterAdapter getAdapter() {
|
||||
|
||||
@@ -4,11 +4,9 @@ import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
||||
import org.parabot.core.asm.interfaces.Injectable;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class appends an interface to a class
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Interface implements Injectable {
|
||||
private String className;
|
||||
@@ -30,6 +28,7 @@ public class Interface implements Injectable {
|
||||
|
||||
/**
|
||||
* Gets the add interface adapter
|
||||
*
|
||||
* @return AddInterface adapter
|
||||
*/
|
||||
public AddInterfaceAdapter getAdapter() {
|
||||
|
||||
@@ -7,11 +7,9 @@ import org.parabot.core.asm.adapters.AddInvokerAdapter;
|
||||
import org.parabot.core.asm.interfaces.Injectable;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is used for injecting an invoker into a methodnode
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Invoker implements Injectable {
|
||||
private ClassNode into;
|
||||
|
||||
@@ -7,11 +7,9 @@ import org.parabot.core.asm.adapters.AddSetterAdapter;
|
||||
import org.parabot.core.asm.interfaces.Injectable;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is used for injecting a setter for a specific field
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Setter implements Injectable {
|
||||
private ClassNode fieldLocation;
|
||||
@@ -37,6 +35,7 @@ public class Setter implements Injectable {
|
||||
|
||||
/**
|
||||
* Short route for getAdaptar().inject();
|
||||
*
|
||||
* @see AddSetterAdapter#inject
|
||||
*/
|
||||
@Override
|
||||
@@ -46,6 +45,7 @@ public class Setter implements Injectable {
|
||||
|
||||
/**
|
||||
* Gets the AddGetterAdapter
|
||||
*
|
||||
* @return AddGetterAdapter
|
||||
*/
|
||||
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.interfaces.Injectable;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is used for changing the super class of a class
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Super implements Injectable {
|
||||
private String className;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.parabot.core.build;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class used for adding urls to the buildpath
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class BuildPath extends org.parabot.api.io.build.BuildPath {
|
||||
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package org.parabot.core.classpath;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
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;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
@@ -20,17 +25,6 @@ import java.util.jar.JarOutputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
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
|
||||
*
|
||||
@@ -47,7 +41,6 @@ public class ClassPath {
|
||||
private boolean parseJar;
|
||||
private ArrayList<URL> jarFiles;
|
||||
|
||||
|
||||
public ClassPath() {
|
||||
this(false);
|
||||
}
|
||||
@@ -92,8 +85,9 @@ public class ClassPath {
|
||||
final ZipInputStream zin = new ZipInputStream(sizeInputStream);
|
||||
ZipEntry e;
|
||||
while ((e = zin.getNextEntry()) != null) {
|
||||
if (e.isDirectory())
|
||||
if (e.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
if (e.getName().endsWith(".class")) {
|
||||
loadClass(zin);
|
||||
} else {
|
||||
@@ -108,13 +102,10 @@ public class ClassPath {
|
||||
VerboseLoader.get().onProgressUpdate(100);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds a jar to this classpath
|
||||
*
|
||||
* @param url
|
||||
* - in string format
|
||||
* @param url - in string format
|
||||
*/
|
||||
public void addJar(final String url) {
|
||||
try {
|
||||
@@ -135,6 +126,7 @@ public class ClassPath {
|
||||
|
||||
/**
|
||||
* Finds and loads all classes/jar files in folder
|
||||
*
|
||||
* @param directory
|
||||
*/
|
||||
public void addClasses(final File directory) {
|
||||
@@ -147,13 +139,13 @@ public class ClassPath {
|
||||
/**
|
||||
* Finds and loads all classes/jar files in folder
|
||||
*
|
||||
* @param f
|
||||
* to find class / jar files
|
||||
* @param f to find class / jar files
|
||||
* @param root
|
||||
*/
|
||||
public void addClasses(final File f, File root) {
|
||||
if (f == null)
|
||||
if (f == null) {
|
||||
return;
|
||||
}
|
||||
if (!f.exists()) {
|
||||
f.mkdirs();
|
||||
}
|
||||
@@ -167,9 +159,9 @@ public class ClassPath {
|
||||
addClasses(f1, root);
|
||||
} else {
|
||||
try (FileInputStream fin = new FileInputStream(f1)) {
|
||||
if (f1.getName().endsWith(".class"))
|
||||
if (f1.getName().endsWith(".class")) {
|
||||
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());
|
||||
if (this.parseJar) {
|
||||
// if enabled, there may be problem with duplicate
|
||||
@@ -192,6 +184,7 @@ public class ClassPath {
|
||||
* Loads class from input stream
|
||||
*
|
||||
* @param in
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void loadClass(InputStream in) throws IOException {
|
||||
@@ -204,8 +197,6 @@ public class ClassPath {
|
||||
classes.put(cn.name, cn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Determines if this classpath represents a jar file
|
||||
*
|
||||
@@ -236,6 +227,7 @@ public class ClassPath {
|
||||
* @param classPath
|
||||
* @param name
|
||||
* @param inputstream
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void loadResource(final String name, final InputStream in)
|
||||
@@ -246,8 +238,9 @@ public class ClassPath {
|
||||
try (OutputStream out = new FileOutputStream(f)) {
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
while ((len = in.read(buffer)) != -1)
|
||||
while ((len = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
this.resources.put(name, f);
|
||||
@@ -284,6 +277,7 @@ public class ClassPath {
|
||||
|
||||
/**
|
||||
* Dumps this classPath classes to a jar file
|
||||
*
|
||||
* @param stream
|
||||
*/
|
||||
public void dump(final FileOutputStream stream) {
|
||||
|
||||
@@ -4,7 +4,6 @@ package org.parabot.core.desc;
|
||||
* Holds information about a script
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class ScriptDescription implements Comparable<ScriptDescription> {
|
||||
public String scriptName;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.parabot.core.desc;
|
||||
|
||||
/**
|
||||
*
|
||||
* Holds information about a server
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class ServerDescription implements Comparable<ServerDescription> {
|
||||
private String serverName;
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package org.parabot.core.desc;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.parabot.core.Configuration;
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.ui.utils.UILog;
|
||||
import org.parabot.environment.api.utils.WebUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
@@ -22,7 +19,6 @@ import java.util.zip.CRC32;
|
||||
* Gets the information for the selected server provider
|
||||
*
|
||||
* @author Paradox, Everel
|
||||
*
|
||||
*/
|
||||
public class ServerProviderInfo {
|
||||
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
package org.parabot.core.forum;
|
||||
|
||||
import org.parabot.core.Core;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
/**
|
||||
*
|
||||
* 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
|
||||
* steal user information.
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Account {
|
||||
private String username;
|
||||
@@ -20,7 +16,6 @@ public class Account {
|
||||
private String api;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param username - Forum account username
|
||||
* @param password - Forum account password
|
||||
*/
|
||||
@@ -37,6 +32,7 @@ public class Account {
|
||||
|
||||
/**
|
||||
* Gets user's parabot account name
|
||||
*
|
||||
* @return username.
|
||||
*/
|
||||
public String getUsername() {
|
||||
@@ -45,6 +41,7 @@ public class Account {
|
||||
|
||||
/**
|
||||
* Gets user's parabot password
|
||||
*
|
||||
* @return password.
|
||||
*/
|
||||
public String getPassword() {
|
||||
@@ -53,6 +50,7 @@ public class Account {
|
||||
|
||||
/**
|
||||
* Gets user's parabot account name
|
||||
*
|
||||
* @return username, already URL UTF-8 encoded.
|
||||
*/
|
||||
public String getURLUsername() {
|
||||
@@ -66,6 +64,7 @@ public class Account {
|
||||
|
||||
/**
|
||||
* Gets user's password
|
||||
*
|
||||
* @return password, already URL UTF-8 encoded.
|
||||
*/
|
||||
public String getURLPassword() {
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.ArrayList;
|
||||
* Handles logging in to parabot forum, only certain classes may use this class.
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public final class AccountManager {
|
||||
private static boolean validated;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.parabot.core.forum;
|
||||
|
||||
/**
|
||||
*
|
||||
* Gives access to account details
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public interface AccountManagerAccess {
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.parabot.core.io;
|
||||
|
||||
/**
|
||||
*
|
||||
* Keeps track of a progress
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public interface ProgressListener extends org.parabot.api.io.ProgressListener {
|
||||
|
||||
|
||||
@@ -4,9 +4,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class SizeInputStream extends InputStream {
|
||||
public int bytesRead;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package org.parabot.core.lib;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public abstract class Library extends org.parabot.api.io.libraries.Library {
|
||||
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
package org.parabot.core.lib.javafx;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.Directories;
|
||||
import org.parabot.core.build.BuildPath;
|
||||
import org.parabot.core.lib.Library;
|
||||
import org.parabot.environment.api.utils.JavaUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
*
|
||||
* Jython util class
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class JavaFX extends Library {
|
||||
private static boolean valid;
|
||||
|
||||
public static boolean isValid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
if (!hasJar()) {
|
||||
@@ -69,8 +71,4 @@ public class JavaFX extends Library {
|
||||
public String getLibraryName() {
|
||||
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()
|
||||
throws SocketException {
|
||||
final ArrayList<NetworkInterface> netifs = new ArrayList<>();
|
||||
|
||||
return new Enumeration<NetworkInterface>() {
|
||||
private int i = 0;
|
||||
|
||||
public NetworkInterface nextElement() {
|
||||
if (i < netifs.size()) {
|
||||
NetworkInterface netif = netifs.get(i++);
|
||||
@@ -44,8 +41,9 @@ public class NetworkInterface {
|
||||
}
|
||||
|
||||
public static byte[] getRealHardwareAddress() throws SocketException {
|
||||
if (realMac != null)
|
||||
if (realMac != null) {
|
||||
return realMac;
|
||||
}
|
||||
try {
|
||||
return realMac = java.net.NetworkInterface.getByInetAddress(
|
||||
InetAddress.getLocalHost()).getHardwareAddress();
|
||||
@@ -55,8 +53,9 @@ public class NetworkInterface {
|
||||
}
|
||||
|
||||
public static NetworkInterface getByInetAddress(InetAddress addr) {
|
||||
if (cached == null)
|
||||
if (cached == null) {
|
||||
cached = new NetworkInterface();
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
||||
@@ -69,9 +68,14 @@ public class NetworkInterface {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (int i = 0; i < 6; i++) {
|
||||
b.append(String.format("%02X", mac[i]));
|
||||
if(i < 5)
|
||||
if (i < 5) {
|
||||
b.append(':');
|
||||
}
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
public byte[] getHardwareAddress() {
|
||||
return mac;
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,19 @@ import java.io.IOException;
|
||||
|
||||
public class Runtime {
|
||||
|
||||
private java.lang.Runtime rt;
|
||||
|
||||
private static Runtime cached;
|
||||
private java.lang.Runtime rt;
|
||||
|
||||
private Runtime(java.lang.Runtime 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) {
|
||||
rt.addShutdownHook(t);
|
||||
@@ -57,10 +62,4 @@ public class Runtime {
|
||||
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 static boolean auth = false;
|
||||
private static List<ProxySocket> connections = new ArrayList<ProxySocket>();
|
||||
|
||||
private static ProxyType proxyType = ProxyType.NONE;
|
||||
|
||||
private static int proxyPort = 0;
|
||||
|
||||
private static String username = null, password = null;
|
||||
private static InetAddress proxyInetAddress = null;
|
||||
private InetAddress addr;
|
||||
private int port;
|
||||
|
||||
private static String username = null, password = null;
|
||||
|
||||
public static boolean auth = false;
|
||||
|
||||
private static InetAddress proxyInetAddress = null;
|
||||
|
||||
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 {
|
||||
super(addr, port);
|
||||
}
|
||||
@@ -55,6 +33,23 @@ public class ProxySocket extends Socket {
|
||||
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) {
|
||||
try {
|
||||
proxyInetAddress = InetAddress.getByName(host);
|
||||
@@ -77,6 +72,23 @@ public class ProxySocket extends Socket {
|
||||
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
|
||||
public void connect(SocketAddress addr) throws IOException {
|
||||
connections.add(this);
|
||||
@@ -94,9 +106,10 @@ public class ProxySocket extends Socket {
|
||||
UILog.log("Proxy Error", e.getMessage(),
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
super.connect(addr);
|
||||
}
|
||||
}
|
||||
|
||||
private void initProxy() throws IOException {
|
||||
System.out.println("Proxying:" + addr + ":" + port + " Over:"
|
||||
@@ -126,10 +139,12 @@ public class ProxySocket extends Socket {
|
||||
out.write("\r\n".getBytes());
|
||||
String str;
|
||||
while ((str = br.readLine()) != null) {
|
||||
if (str.length() == 0)
|
||||
if (str.length() == 0) {
|
||||
break;
|
||||
if (!str.startsWith("HTTP"))
|
||||
}
|
||||
if (!str.startsWith("HTTP")) {
|
||||
continue;
|
||||
}
|
||||
int code = Integer.parseInt(str.substring(9, 12));
|
||||
switch (code) {
|
||||
case 404:
|
||||
@@ -140,12 +155,13 @@ public class ProxySocket extends Socket {
|
||||
"Proxy doesn't support connecting to port: " + port
|
||||
+ "! Try a different proxy.");
|
||||
}
|
||||
if (code / 100 != 2)
|
||||
if (code / 100 != 2) {
|
||||
throw new IOException(
|
||||
"Unable to connect to proxy server! HTTP Error code:"
|
||||
+ code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void socks4_connect() throws IOException {
|
||||
DataOutputStream out = new DataOutputStream(getOutputStream());
|
||||
@@ -155,18 +171,22 @@ public class ProxySocket extends Socket {
|
||||
out.write(0x01); // connection type (TCP stream)
|
||||
out.writeShort(port);
|
||||
byte[] b = addr.getAddress();
|
||||
if (b.length != 4)
|
||||
if (b.length != 4) {
|
||||
throw new IOException("Unsupported IP type for socksv4!");
|
||||
}
|
||||
out.write(b);
|
||||
out.write(0); // the userID stuff, 0 means end of string (null
|
||||
// terminated)
|
||||
out.flush();
|
||||
|
||||
if (in.read() != 0x00) // null byte
|
||||
{
|
||||
throw new IOException("Proxy server dun goofed");
|
||||
if (in.read() != 0x5a)
|
||||
}
|
||||
if (in.read() != 0x5a) {
|
||||
throw new IOException(
|
||||
"Proxy server was unable to connect to server!");
|
||||
}
|
||||
|
||||
in.readShort(); // ignored
|
||||
in.readFully(b); // ignored
|
||||
@@ -184,7 +204,9 @@ public class ProxySocket extends Socket {
|
||||
}
|
||||
out.flush();
|
||||
if (in.read() != 0x05) // remote proxy version
|
||||
{
|
||||
throw new IOException("Proxy server is not supported!");
|
||||
}
|
||||
switch (in.read()) { // auth method
|
||||
case 0:
|
||||
break; // no auth
|
||||
@@ -198,7 +220,9 @@ public class ProxySocket extends Socket {
|
||||
out.flush();
|
||||
in.read(); // skip the version
|
||||
if (in.read() == 0) // Successful login, continue
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new IOException("Proxy server declined request!");
|
||||
}
|
||||
@@ -217,12 +241,16 @@ public class ProxySocket extends Socket {
|
||||
|
||||
// now to read the server's reply
|
||||
if (in.read() != 0x05) // socks version (again)
|
||||
{
|
||||
throw new IOException("Proxy server dun goofed");
|
||||
}
|
||||
int reply = in.read();
|
||||
if (reply == 0x08)
|
||||
if (reply == 0x08) {
|
||||
throw new IOException("Bad address sent to proxy server");
|
||||
if (reply != 0x00)
|
||||
}
|
||||
if (reply != 0x00) {
|
||||
throw new IOException("Unable to connect to server!");
|
||||
}
|
||||
in.read(); // reserve byte
|
||||
int addrType = in.read();
|
||||
b = new byte[4];
|
||||
@@ -242,29 +270,33 @@ public class ProxySocket extends Socket {
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
if (super.getInetAddress().equals(proxyInetAddress))
|
||||
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||
return port;
|
||||
}
|
||||
return super.getPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetAddress getInetAddress() {
|
||||
if (super.getInetAddress().equals(proxyInetAddress))
|
||||
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||
return addr;
|
||||
}
|
||||
return super.getInetAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketAddress getRemoteSocketAddress() {
|
||||
if (super.getInetAddress().equals(proxyInetAddress))
|
||||
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||
return cachedAddr;
|
||||
}
|
||||
return super.getRemoteSocketAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SocketChannel getChannel() {
|
||||
if (super.getInetAddress().equals(proxyInetAddress))
|
||||
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||
return null;
|
||||
}
|
||||
return super.getChannel();
|
||||
}
|
||||
|
||||
@@ -274,21 +306,4 @@ public class ProxySocket extends Socket {
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* Abstract class for debugging in game values & more
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractDebugger implements Paintable {
|
||||
|
||||
@@ -17,7 +15,6 @@ public abstract class AbstractDebugger implements Paintable {
|
||||
public abstract void toggle();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return True if this debugger is enabled, otherwise false
|
||||
*/
|
||||
public abstract boolean isEnabled();
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
package org.parabot.core.paint;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import org.parabot.core.Context;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
import org.parabot.core.Context;
|
||||
|
||||
/**
|
||||
*
|
||||
* Manages and paints on a collection of AbstractDebuggers
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class PaintDebugger {
|
||||
private final HashMap<String, AbstractDebugger> debuggers;
|
||||
@@ -24,6 +21,10 @@ public class PaintDebugger {
|
||||
this.stringDebug = new LinkedList<String>();
|
||||
}
|
||||
|
||||
public static final PaintDebugger getInstance() {
|
||||
return Context.getInstance().getPaintDebugger();
|
||||
}
|
||||
|
||||
public final void addDebugger(final String name, final AbstractDebugger 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) {
|
||||
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.interfaces.Injectable;
|
||||
import org.parabot.core.asm.wrappers.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -15,7 +16,6 @@ import java.util.HashMap;
|
||||
*/
|
||||
public abstract class HookParser {
|
||||
|
||||
|
||||
public HookParser(HookFile hookFile) {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +1,18 @@
|
||||
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.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
||||
import org.parabot.core.asm.hooks.HookFile;
|
||||
import org.parabot.core.asm.wrappers.Callback;
|
||||
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.parabot.core.asm.wrappers.*;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Dane
|
||||
*
|
||||
*/
|
||||
public class JSONHookParser extends HookParser {
|
||||
private JSONObject root;
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
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.asm.adapters.AddInterfaceAdapter;
|
||||
import org.parabot.core.asm.hooks.HookFile;
|
||||
import org.parabot.core.asm.wrappers.Callback;
|
||||
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.parabot.core.asm.wrappers.*;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
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 {
|
||||
private Document doc;
|
||||
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
|
||||
public Interface[] getInterfaces() {
|
||||
parsedInterfaces = true;
|
||||
@@ -267,40 +294,6 @@ public class XMLHookParser extends HookParser {
|
||||
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
|
||||
public Invoker[] getInvokers() {
|
||||
final NodeList invokerRootList = doc.getElementsByTagName("invokers");
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
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.HashMap;
|
||||
import java.util.Map;
|
||||
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
|
||||
*
|
||||
@@ -18,8 +18,6 @@ public abstract class ScriptParser {
|
||||
|
||||
public static final Map<ScriptDescription, ScriptExecuter> SCRIPT_CACHE = new HashMap<ScriptDescription, ScriptExecuter>();
|
||||
|
||||
public abstract void execute();
|
||||
|
||||
public static ScriptDescription[] getDescriptions() {
|
||||
SCRIPT_CACHE.clear();
|
||||
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()]);
|
||||
}
|
||||
|
||||
public abstract void execute();
|
||||
|
||||
}
|
||||
@@ -1,36 +1,23 @@
|
||||
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.parser.ParseException;
|
||||
import org.parabot.core.Configuration;
|
||||
import org.parabot.core.Context;
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.Directories;
|
||||
import org.parabot.core.build.BuildPath;
|
||||
import org.parabot.core.classpath.ClassPath;
|
||||
import org.parabot.core.desc.ServerDescription;
|
||||
import org.parabot.core.desc.ServerProviderInfo;
|
||||
import org.parabot.core.ui.components.VerboseLoader;
|
||||
import org.parabot.core.ui.utils.UILog;
|
||||
import org.parabot.environment.api.utils.WebUtil;
|
||||
import org.parabot.environment.servers.ServerManifest;
|
||||
import org.parabot.environment.servers.ServerProvider;
|
||||
import org.parabot.environment.servers.executers.LocalPublicServerExecuter;
|
||||
import org.parabot.environment.servers.executers.LocalServerExecuter;
|
||||
import org.parabot.environment.servers.executers.PublicServerExecuter;
|
||||
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
|
||||
|
||||
@@ -17,8 +17,6 @@ import java.util.TreeMap;
|
||||
public abstract class ServerParser {
|
||||
public static final Map<ServerDescription, ServerExecuter> SERVER_CACHE = new HashMap<ServerDescription, ServerExecuter>();
|
||||
|
||||
public abstract void execute();
|
||||
|
||||
public static final ServerDescription[] getDescriptions() {
|
||||
SERVER_CACHE.clear();
|
||||
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()]);
|
||||
}
|
||||
|
||||
public abstract void execute();
|
||||
|
||||
}
|
||||
@@ -9,13 +9,11 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*
|
||||
* 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
|
||||
* only invoke static methods
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class RefClass extends RefModifiers {
|
||||
private Object instance;
|
||||
@@ -35,12 +33,21 @@ public class RefClass extends RefModifiers {
|
||||
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
|
||||
* retrieved and non static methods can be invoked
|
||||
*
|
||||
* @param instance
|
||||
* instance of this class.
|
||||
* @param instance instance of this class.
|
||||
*/
|
||||
public void setInstance(Object instance) {
|
||||
if (instance == null) {
|
||||
@@ -56,16 +63,6 @@ public class RefClass extends RefModifiers {
|
||||
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
|
||||
*
|
||||
@@ -127,7 +124,9 @@ public class RefClass extends RefModifiers {
|
||||
|
||||
/**
|
||||
* Determines if a object is an instance of this class
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public boolean instanceOf(Object object) {
|
||||
@@ -137,8 +136,8 @@ public class RefClass extends RefModifiers {
|
||||
/**
|
||||
* Gets field by field name
|
||||
*
|
||||
* @param name
|
||||
* name of the field
|
||||
* @param name name of the field
|
||||
*
|
||||
* @return the field if found
|
||||
*/
|
||||
public RefField getField(String name) {
|
||||
@@ -148,10 +147,9 @@ public class RefClass extends RefModifiers {
|
||||
/**
|
||||
* Gets field by field name and desc
|
||||
*
|
||||
* @param name
|
||||
* name of the field
|
||||
* @param desc
|
||||
* desc type of the field
|
||||
* @param name name of the field
|
||||
* @param desc desc type of the field
|
||||
*
|
||||
* @return the field if found
|
||||
*/
|
||||
public RefField getField(String name, String desc) {
|
||||
@@ -182,9 +180,9 @@ public class RefClass extends RefModifiers {
|
||||
/**
|
||||
* Determines if this class has a super class
|
||||
*
|
||||
* @param ignoreObjectClass
|
||||
* if you want this method to return false when the superclass is
|
||||
* @param ignoreObjectClass if you want this method to return false when the superclass is
|
||||
* the java/lang/Object class
|
||||
*
|
||||
* @return <code>true</code> if this class has a superclass, otherwise
|
||||
* <code>false</code>
|
||||
*/
|
||||
@@ -234,8 +232,8 @@ public class RefClass extends RefModifiers {
|
||||
/**
|
||||
* Gets a RefConstructor from this class
|
||||
*
|
||||
* @param parameters
|
||||
* the constructor it's parameters
|
||||
* @param parameters the constructor it's parameters
|
||||
*
|
||||
* @return the retrieved constructor
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param name
|
||||
* method its name
|
||||
* @param name method its name
|
||||
*
|
||||
* @return the first match, or if not found <code>null</code>
|
||||
*/
|
||||
public RefMethod getMethod(String name) {
|
||||
@@ -300,10 +298,9 @@ public class RefClass extends RefModifiers {
|
||||
/**
|
||||
* Finds a RefMethod in this RefClass
|
||||
*
|
||||
* @param name
|
||||
* the method its name
|
||||
* @param parameters
|
||||
* the method its parameters
|
||||
* @param name the method its name
|
||||
* @param parameters the method its parameters
|
||||
*
|
||||
* @return the matched method or if not found null <code>null</code>
|
||||
*/
|
||||
public RefMethod getMethod(String name, Class<?>[] parameters) {
|
||||
|
||||
@@ -3,12 +3,10 @@ package org.parabot.core.reflect;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* A <code>RefConstructor</code> class represent a constructor method of a
|
||||
* <code>RefClass</code>.
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class RefConstructor extends RefModifiers {
|
||||
private Constructor<?> constructor;
|
||||
@@ -30,8 +28,8 @@ public class RefConstructor extends RefModifiers {
|
||||
/**
|
||||
* Creates a new instance of this class by invoking this constructor
|
||||
*
|
||||
* @param args
|
||||
* the arguments for the constructor
|
||||
* @param args the arguments for the constructor
|
||||
*
|
||||
* @return the instance of the class
|
||||
*/
|
||||
public RefClass newInstance(Object... args) {
|
||||
|
||||
@@ -4,11 +4,9 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* A <code>RefField</code> represents a field in a <code>RefClass</code>
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class RefField extends RefModifiers {
|
||||
private Field field;
|
||||
@@ -129,8 +127,7 @@ public class RefField extends RefModifiers {
|
||||
/**
|
||||
* Sets the field value
|
||||
*
|
||||
* @param object
|
||||
* object to set
|
||||
* @param object object to set
|
||||
*/
|
||||
public void set(Object object) {
|
||||
if (instance == null && !isStatic()) {
|
||||
@@ -150,8 +147,7 @@ public class RefField extends RefModifiers {
|
||||
/**
|
||||
* Sets the field integer value
|
||||
*
|
||||
* @param i
|
||||
* value to set
|
||||
* @param i value to set
|
||||
*/
|
||||
public void setInt(int i) {
|
||||
set(i);
|
||||
@@ -160,8 +156,7 @@ public class RefField extends RefModifiers {
|
||||
/**
|
||||
* Sets the field long value
|
||||
*
|
||||
* @param l
|
||||
* value to set
|
||||
* @param l value to set
|
||||
*/
|
||||
public void setLong(long l) {
|
||||
set(l);
|
||||
@@ -170,8 +165,7 @@ public class RefField extends RefModifiers {
|
||||
/**
|
||||
* Sets the field double value
|
||||
*
|
||||
* @param d
|
||||
* value to set
|
||||
* @param d value to set
|
||||
*/
|
||||
public void setDouble(double d) {
|
||||
set(d);
|
||||
@@ -180,8 +174,7 @@ public class RefField extends RefModifiers {
|
||||
/**
|
||||
* Sets the field float value
|
||||
*
|
||||
* @param f
|
||||
* value to set
|
||||
* @param f value to set
|
||||
*/
|
||||
public void setFloat(float f) {
|
||||
set(f);
|
||||
@@ -190,8 +183,7 @@ public class RefField extends RefModifiers {
|
||||
/**
|
||||
* Sets the field boolean value
|
||||
*
|
||||
* @param b
|
||||
* value to set
|
||||
* @param b value to set
|
||||
*/
|
||||
public void setBoolean(boolean b) {
|
||||
set(b);
|
||||
@@ -200,8 +192,7 @@ public class RefField extends RefModifiers {
|
||||
/**
|
||||
* Sets the field short value
|
||||
*
|
||||
* @param s
|
||||
* value to set
|
||||
* @param s value to set
|
||||
*/
|
||||
public void setShort(short s) {
|
||||
set(s);
|
||||
@@ -210,28 +201,16 @@ public class RefField extends RefModifiers {
|
||||
/**
|
||||
* Sets the byte integer value
|
||||
*
|
||||
* @param b
|
||||
* value to set
|
||||
* @param b value to set
|
||||
*/
|
||||
public void setByte(byte 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
|
||||
*
|
||||
* @param c
|
||||
* value to set
|
||||
* @param c value to set
|
||||
*/
|
||||
public void setChar(char c) {
|
||||
set(c);
|
||||
@@ -312,6 +291,15 @@ public class RefField extends RefModifiers {
|
||||
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
|
||||
* 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
|
||||
*
|
||||
* @return <code>RefClass</code> holding this field
|
||||
*/
|
||||
public RefClass getOwner() {
|
||||
@@ -377,5 +366,4 @@ public class RefField extends RefModifiers {
|
||||
return field.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@ package org.parabot.core.reflect;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
*
|
||||
* A <code>RefMethod</code> class represent a method of a <code>RefClass</code>.
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class RefMethod extends RefModifiers {
|
||||
private Method method;
|
||||
@@ -118,11 +116,10 @@ public class RefMethod extends RefModifiers {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Invokes the method and returns it returned object
|
||||
*
|
||||
* @param args
|
||||
* arguments for the invokable method
|
||||
* @param args arguments for the invokable method
|
||||
*
|
||||
* @return object returned by the method
|
||||
*/
|
||||
public Object invoke(Object... args) {
|
||||
|
||||
@@ -3,9 +3,7 @@ package org.parabot.core.reflect;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class RefModifiers {
|
||||
private int modifiers;
|
||||
@@ -18,14 +16,14 @@ public class RefModifiers {
|
||||
setModifiers(modifiers);
|
||||
}
|
||||
|
||||
public void setModifiers(int modifiers) {
|
||||
this.modifiers = modifiers;
|
||||
}
|
||||
|
||||
public int getModifiers() {
|
||||
return this.modifiers;
|
||||
}
|
||||
|
||||
public void setModifiers(int modifiers) {
|
||||
this.modifiers = modifiers;
|
||||
}
|
||||
|
||||
public boolean isStatic() {
|
||||
return Modifier.isStatic(modifiers);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class RefUtils {
|
||||
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
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.environment.OperatingSystem;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class BotDialog extends JDialog {
|
||||
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) {
|
||||
setUndecorated(true);
|
||||
getRootPane().setOpaque(false);
|
||||
@@ -57,12 +61,4 @@ public class BotDialog extends JDialog {
|
||||
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 boolean runScript, pauseScript;
|
||||
|
||||
|
||||
public BotUI(String username, String password) {
|
||||
if (instance != null) {
|
||||
throw new IllegalStateException("BotUI already created");
|
||||
@@ -75,7 +74,6 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
private void createMenu() {
|
||||
menuBar = new JMenuBar();
|
||||
|
||||
@@ -146,7 +144,6 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
||||
menuBar.add(scripts);
|
||||
menuBar.add(features);
|
||||
|
||||
|
||||
setJMenuBar(menuBar);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,27 +45,13 @@ public class Logger extends JPanel {
|
||||
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() {
|
||||
return instance == null ? instance = new Logger() : instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message in the logger ui
|
||||
*
|
||||
* @param message
|
||||
* @param uliratha Determines if this should be sent to the uliratha server
|
||||
*/
|
||||
@@ -96,6 +82,21 @@ public class Logger extends JPanel {
|
||||
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() {
|
||||
return clearable;
|
||||
}
|
||||
|
||||
@@ -17,11 +17,9 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
*
|
||||
* Users must login with their parabot account through this LoginUI class
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class LoginUI extends JFrame {
|
||||
private static final long serialVersionUID = 2032832552863466297L;
|
||||
@@ -33,38 +31,6 @@ public class LoginUI extends JFrame {
|
||||
private JButton cmdLogin;
|
||||
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) {
|
||||
instance = this;
|
||||
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
|
||||
public void setVisible(boolean b) {
|
||||
BotUI.getInstance().setEnabled(!b);
|
||||
if (ProxySocket.getProxyAddress() != null)
|
||||
if (ProxySocket.getProxyAddress() != null) {
|
||||
proxyHost.setText(ProxySocket.getProxyAddress().getHostName());
|
||||
}
|
||||
proxyPort.setText("" + ProxySocket.getProxyPort());
|
||||
proxyType.setSelectedItem(ProxySocket.getProxyType());
|
||||
authCheckBox.setSelected(ProxySocket.auth);
|
||||
@@ -104,7 +105,6 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
authCheckBox = new JCheckBox("Auth");
|
||||
authCheckBox.setSelected(ProxySocket.auth);
|
||||
authCheckBox.addActionListener(this);
|
||||
@@ -262,9 +262,10 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
||||
.setLogin(username, password);
|
||||
|
||||
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(
|
||||
(String) macList[i].getSelectedValue(), 16);
|
||||
}
|
||||
NetworkInterface.setMac(mac);
|
||||
|
||||
try {
|
||||
@@ -340,8 +341,9 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
||||
|
||||
public void insertString(int offs, String str, AttributeSet a)
|
||||
throws BadLocationException {
|
||||
if (str == null)
|
||||
if (str == null) {
|
||||
return;
|
||||
}
|
||||
String oldString = getText(0, getLength());
|
||||
String newString = oldString.substring(0, offs) + str
|
||||
+ oldString.substring(offs);
|
||||
|
||||
@@ -103,7 +103,6 @@ public class ReflectUI extends JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
final JButton adjustClasses = new JButton("Expand");
|
||||
adjustClasses.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
@@ -130,7 +129,6 @@ public class ReflectUI extends JFrame {
|
||||
searchContent.setMaximumSize(new Dimension(500, (int) searchContent.getPreferredSize().getHeight()));
|
||||
searchContent.add(searchButton);
|
||||
|
||||
|
||||
tree = new JTree();
|
||||
tree.setRootVisible(true);
|
||||
tree.setShowsRootHandles(true);
|
||||
|
||||
@@ -23,21 +23,23 @@ import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* Script Selector GUI, shows all scripts
|
||||
*
|
||||
* @author Everel
|
||||
*/
|
||||
public final class ScriptSelector extends JFrame {
|
||||
public static ScriptParser parser;
|
||||
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, ScriptDescription> format;
|
||||
private DefaultMutableTreeNode root;
|
||||
private DefaultTreeModel model;
|
||||
private final int WIDTH;
|
||||
private final int HEIGHT;
|
||||
private Font fontCategory = new Font("Arial", Font.BOLD, 12);
|
||||
private Font fontScript = new Font("Arial", Font.PLAIN, 12);
|
||||
private JTree tree;
|
||||
private JEditorPane scriptInfo;
|
||||
|
||||
public ScriptSelector() {
|
||||
this.categories = new HashMap<String, DefaultMutableTreeNode>();
|
||||
@@ -77,7 +79,6 @@ public final class ScriptSelector extends JFrame {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getScriptName(String path) {
|
||||
return path.split(", ")[2].replaceAll("\\]", "");
|
||||
}
|
||||
@@ -216,9 +217,4 @@ public final class ScriptSelector extends JFrame {
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* Shows a list of every supported server which can be started
|
||||
*
|
||||
* @author Dane, Everel
|
||||
*
|
||||
*/
|
||||
|
||||
public class ServerSelector extends JPanel {
|
||||
public static String initServer;
|
||||
private static final long serialVersionUID = 5238720307271493899L;
|
||||
public static String initServer;
|
||||
private static ServerSelector instance;
|
||||
|
||||
public static ServerSelector getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new ServerSelector();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ServerSelector() {
|
||||
Queue<ServerComponent> widgets = getServers();
|
||||
if (initServer != null) {
|
||||
@@ -39,7 +30,6 @@ public class ServerSelector extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
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
|
||||
*
|
||||
|
||||
@@ -6,11 +6,9 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* Main panel where applets are added.
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class GamePanel extends JPanel {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -30,15 +28,6 @@ public class GamePanel extends JPanel {
|
||||
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
|
||||
*
|
||||
@@ -48,6 +37,15 @@ public class GamePanel extends JPanel {
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
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.environment.api.interfaces.Paintable;
|
||||
import org.parabot.environment.api.utils.Time;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
*
|
||||
* The panel that is painted on
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class PaintComponent extends JComponent implements Runnable {
|
||||
private static final long serialVersionUID = 4653612412080038193L;
|
||||
@@ -39,6 +33,14 @@ public class PaintComponent extends JComponent implements Runnable {
|
||||
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) {
|
||||
this.dimensions = dimensions;
|
||||
this.dimensions = dimensions;
|
||||
@@ -51,14 +53,6 @@ public class PaintComponent extends JComponent implements Runnable {
|
||||
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) {
|
||||
this.context = context;
|
||||
new Thread(this).start();
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
package org.parabot.core.ui.components;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
/**
|
||||
*
|
||||
* ProgressBar
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class ProgressBar {
|
||||
private double value;
|
||||
@@ -36,6 +30,10 @@ public class ProgressBar {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(double value) {
|
||||
if (value < 0 || value > 100) {
|
||||
return;
|
||||
@@ -61,10 +59,6 @@ public class ProgressBar {
|
||||
this.progColor = new Color(255 - r, 253 - g, 145 - b);
|
||||
}
|
||||
|
||||
public double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void draw(Graphics g, int x, int y) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(
|
||||
|
||||
@@ -1,26 +1,19 @@
|
||||
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.ui.fonts.Fonts;
|
||||
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
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class ServerComponent extends JPanel implements MouseListener,
|
||||
MouseMotionListener {
|
||||
|
||||
@@ -6,8 +6,8 @@ import org.parabot.core.forum.AccountManager;
|
||||
import org.parabot.core.forum.AccountManagerAccess;
|
||||
import org.parabot.core.io.ProgressListener;
|
||||
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.images.Images;
|
||||
import org.parabot.core.ui.utils.UILog;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -24,22 +24,13 @@ import java.awt.image.RescaleOp;
|
||||
* @author Everel, EmmaStone
|
||||
*/
|
||||
public class VerboseLoader extends JPanel implements ProgressListener {
|
||||
public static final int STATE_LOADING = 1;
|
||||
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 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 FontMetrics fontMetrics;
|
||||
private BufferedImage background, banner, loginBox;
|
||||
private ProgressBar progressBar;
|
||||
private JPanel loginPanel;
|
||||
|
||||
public static final AccountManagerAccess MANAGER_FETCHER = new AccountManagerAccess() {
|
||||
|
||||
@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) {
|
||||
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() {
|
||||
JPanel servers = ServerSelector.getInstance();
|
||||
GridBagLayout bagLayout = (GridBagLayout) getLayout();
|
||||
@@ -139,7 +163,6 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
||||
passwordLabel.setAlignmentX(Box.CENTER_ALIGNMENT);
|
||||
passwordLabel.setForeground(Color.white);
|
||||
|
||||
|
||||
login.setAlignmentX(Box.CENTER_ALIGNMENT);
|
||||
login.setOpaque(false);
|
||||
|
||||
@@ -189,7 +212,6 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
||||
public void paintComponent(Graphics graphics) {
|
||||
super.paintComponent(graphics);
|
||||
|
||||
|
||||
Graphics2D g = (Graphics2D) graphics;
|
||||
g.setRenderingHint(
|
||||
RenderingHints.KEY_TEXT_ANTIALIASING,
|
||||
@@ -236,7 +258,6 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
||||
g.drawString(state, x, 200);
|
||||
}
|
||||
|
||||
|
||||
g.setFont(Fonts.getResource("leelawadee.ttf"));
|
||||
final String version = Configuration.BOT_VERSION.get();
|
||||
g.drawString(version,
|
||||
@@ -244,35 +265,6 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
||||
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
|
||||
public void onProgressUpdate(double value) {
|
||||
progressBar.setValue(value);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
|
||||
<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">
|
||||
<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">
|
||||
<top>
|
||||
<MenuBar BorderPane.alignment="CENTER">
|
||||
<menus>
|
||||
@@ -65,9 +64,11 @@
|
||||
</TableView>
|
||||
</center>
|
||||
<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>
|
||||
<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"/>
|
||||
</children>
|
||||
</HBox>
|
||||
|
||||
@@ -13,6 +13,7 @@ public class Fonts {
|
||||
* Calls the getResource with the default size of 12
|
||||
*
|
||||
* @param resource
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
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.Binding;
|
||||
import org.parabot.environment.OperatingSystem;
|
||||
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.parabot.environment.api.utils.WebUtil;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the bot environment
|
||||
*
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.parabot.environment;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is used for detecting the user's operating system
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public enum OperatingSystem {
|
||||
|
||||
@@ -13,12 +11,15 @@ public enum OperatingSystem {
|
||||
|
||||
public static final OperatingSystem getOS() {
|
||||
String str = System.getProperty("os.name").toLowerCase();
|
||||
if (str.indexOf("win") > -1)
|
||||
if (str.indexOf("win") > -1) {
|
||||
return OperatingSystem.WINDOWS;
|
||||
if (str.indexOf("mac") > -1)
|
||||
}
|
||||
if (str.indexOf("mac") > -1) {
|
||||
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.OTHER;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.parabot.environment.api.interfaces;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public interface Paintable {
|
||||
|
||||
|
||||
@@ -3,14 +3,16 @@ package org.parabot.environment.api.utils;
|
||||
/**
|
||||
* A simple class to filter things out of an collection
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
* @param <F>
|
||||
*
|
||||
* @author Everel
|
||||
*/
|
||||
public interface Filter<F> {
|
||||
/**
|
||||
* Determines if this object should be accepted
|
||||
*
|
||||
* @param f
|
||||
*
|
||||
* @return <b>true</b> to include this object, otherwise <b>false</b> to exclude.
|
||||
*/
|
||||
public boolean accept(F f);
|
||||
|
||||
@@ -3,20 +3,16 @@ package org.parabot.environment.api.utils;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
*
|
||||
* Helper class for calculating setters for clients that uses multipliers
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public static long getLongSetter(long multiplier, long set) {
|
||||
|
||||
@@ -19,16 +19,14 @@ import java.util.Properties;
|
||||
public class PBPreferences {
|
||||
|
||||
private static AccountManager manager;
|
||||
|
||||
private Properties properties;
|
||||
private int scriptID;
|
||||
|
||||
public static final AccountManagerAccess MANAGER_FETCHER = new AccountManagerAccess() {
|
||||
@Override
|
||||
public final void setManager(AccountManager manager) {
|
||||
PBPreferences.manager = manager;
|
||||
}
|
||||
};
|
||||
private Properties properties;
|
||||
private int scriptID;
|
||||
|
||||
public PBPreferences(int scriptID) {
|
||||
this.scriptID = scriptID;
|
||||
@@ -60,6 +58,7 @@ public class PBPreferences {
|
||||
|
||||
/**
|
||||
* Change a setting
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@@ -69,7 +68,9 @@ public class PBPreferences {
|
||||
|
||||
/**
|
||||
* Get a setting value
|
||||
*
|
||||
* @param key
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Object getSetting(Object key) {
|
||||
@@ -78,7 +79,9 @@ public class PBPreferences {
|
||||
|
||||
/**
|
||||
* Get a setting value as string
|
||||
*
|
||||
* @param key
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getSetting(String key) {
|
||||
@@ -87,6 +90,7 @@ public class PBPreferences {
|
||||
|
||||
/**
|
||||
* Remove a setting
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public void removeSetting(Object key) {
|
||||
@@ -108,6 +112,7 @@ public class PBPreferences {
|
||||
|
||||
/**
|
||||
* Add a setting
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.parabot.environment.api.utils;
|
||||
|
||||
/**
|
||||
*
|
||||
* A random class is used for generating random numbers
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Random {
|
||||
private final static java.util.Random RANDOM = new java.util.Random();
|
||||
@@ -15,6 +13,7 @@ public class Random {
|
||||
*
|
||||
* @param min
|
||||
* @param max
|
||||
*
|
||||
* @return randomized number
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* Holds various Time utilities
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public final class Time {
|
||||
|
||||
/**
|
||||
* Sleeps for a given amount of time
|
||||
*
|
||||
* @param ms
|
||||
*/
|
||||
public static void sleep(final int ms) {
|
||||
@@ -23,9 +22,7 @@ public final class Time {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param minumum
|
||||
* @param maximum
|
||||
*/
|
||||
@@ -40,10 +37,9 @@ public final class Time {
|
||||
/**
|
||||
* Sleeps until the SleepCondition is valid.
|
||||
*
|
||||
* @param conn
|
||||
* the condition.
|
||||
* @param timeout
|
||||
* the time in miliseconds before it stops sleeping.
|
||||
* @param conn the condition.
|
||||
* @param timeout the time in miliseconds before it stops sleeping.
|
||||
*
|
||||
* @return whether it ran successfully without timing out.
|
||||
*/
|
||||
public static boolean sleep(SleepCondition conn, int timeout) {
|
||||
@@ -59,6 +55,7 @@ public final class Time {
|
||||
|
||||
/**
|
||||
* Gets current time in milliseconds
|
||||
*
|
||||
* @return time in ms
|
||||
*/
|
||||
public static long get() {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.parabot.environment.api.utils;
|
||||
|
||||
/**
|
||||
*
|
||||
* A simple timer class
|
||||
*
|
||||
* @author Everel, Parameter
|
||||
*
|
||||
*/
|
||||
public class Timer {
|
||||
private long start;
|
||||
@@ -92,8 +90,8 @@ public class Timer {
|
||||
/**
|
||||
* Calculates hourly gains based on given variable
|
||||
*
|
||||
* @param gained
|
||||
* variable
|
||||
* @param gained variable
|
||||
*
|
||||
* @return hourly gains
|
||||
*/
|
||||
public int getPerHour(final int gained) {
|
||||
|
||||
@@ -4,9 +4,8 @@ import org.parabot.core.ui.utils.UILog;
|
||||
|
||||
public class Version implements Comparable<Version> {
|
||||
|
||||
private String version;
|
||||
|
||||
private static boolean notified;
|
||||
private String version;
|
||||
|
||||
public Version(String version) {
|
||||
if (version == null) {
|
||||
@@ -18,6 +17,19 @@ public class Version implements Comparable<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() {
|
||||
return this.version;
|
||||
}
|
||||
@@ -60,17 +72,4 @@ public class Version implements Comparable<Version> {
|
||||
public boolean equals(Object that) {
|
||||
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;
|
||||
|
||||
import java.awt.Component;
|
||||
import org.parabot.core.Context;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
import org.parabot.core.Context;
|
||||
|
||||
/**
|
||||
*
|
||||
* Virtual keyboard, dispatches key events to a component.
|
||||
*
|
||||
* @author Everel, Matt, Dane
|
||||
*
|
||||
*/
|
||||
public class Keyboard implements KeyListener {
|
||||
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 long pressTime;
|
||||
|
||||
@@ -28,16 +38,6 @@ public class Keyboard implements KeyListener {
|
||||
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() {
|
||||
Random rand = new Random();
|
||||
return rand.nextInt(100) + 40;
|
||||
@@ -46,7 +46,7 @@ public class Keyboard implements KeyListener {
|
||||
public void sendKeys(String s) {
|
||||
|
||||
pressTime = System.currentTimeMillis();
|
||||
for (char c : s.toCharArray())
|
||||
for (char c : s.toCharArray()) {
|
||||
for (KeyEvent ke : createKeyClick(component, c)) {
|
||||
try {
|
||||
Thread.sleep(5);
|
||||
@@ -55,22 +55,25 @@ public class Keyboard implements KeyListener {
|
||||
}
|
||||
sendKeyEvent(ke);
|
||||
}
|
||||
}
|
||||
clickKey(10);
|
||||
}
|
||||
|
||||
public void clickKey(char c) {
|
||||
|
||||
pressTime = System.currentTimeMillis();
|
||||
for (KeyEvent ke : createKeyClick(component, c))
|
||||
for (KeyEvent ke : createKeyClick(component, c)) {
|
||||
sendKeyEvent(ke);
|
||||
}
|
||||
}
|
||||
|
||||
public void clickKey(int keyCode) {
|
||||
|
||||
pressTime = System.currentTimeMillis();
|
||||
for (KeyEvent ke : createKeyClick(component, keyCode))
|
||||
for (KeyEvent ke : createKeyClick(component, keyCode)) {
|
||||
sendKeyEvent(ke);
|
||||
}
|
||||
}
|
||||
|
||||
public void pressKey(int keyCode) {
|
||||
|
||||
|
||||
@@ -9,11 +9,9 @@ import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* A virtual mouse, dispatches mouse events to a component
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Mouse implements MouseListener, MouseMotionListener {
|
||||
private Component component;
|
||||
@@ -30,6 +28,7 @@ public class Mouse implements MouseListener, MouseMotionListener {
|
||||
|
||||
/**
|
||||
* Moves the mouse to the given point and clicks
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
* @param left
|
||||
@@ -98,6 +97,7 @@ public class Mouse implements MouseListener, MouseMotionListener {
|
||||
|
||||
/**
|
||||
* Moves the mouse cursor to the given location
|
||||
*
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
@@ -118,6 +118,7 @@ public class Mouse implements MouseListener, MouseMotionListener {
|
||||
|
||||
/**
|
||||
* Mouse cursor current location
|
||||
*
|
||||
* @return point
|
||||
*/
|
||||
public Point getPoint() {
|
||||
|
||||
@@ -48,6 +48,7 @@ public class RandomHandler {
|
||||
|
||||
/**
|
||||
* @param random
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@@ -104,6 +96,7 @@ public class RandomHandler {
|
||||
* Executes a specific random
|
||||
*
|
||||
* @param r
|
||||
*
|
||||
* @return True if the random is executed, false if not
|
||||
*/
|
||||
public boolean executeRandom(Random r) {
|
||||
@@ -152,6 +145,7 @@ public class RandomHandler {
|
||||
* Checks if random occurs and runs it
|
||||
*
|
||||
* @return returns <b>true</b> if a random has been executed, otherwise <b>false</b>
|
||||
*
|
||||
* @see RandomHandler#checkAndRun(RandomType)
|
||||
* @deprecated
|
||||
*/
|
||||
@@ -165,6 +159,15 @@ public class RandomHandler {
|
||||
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() {
|
||||
return this.activeRandoms;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ public enum RandomType {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static RandomType getDefault() {
|
||||
return SCRIPT;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -25,8 +29,4 @@ public enum RandomType {
|
||||
public String getName() {
|
||||
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.util.HashMap;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Holds script categories
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@@ -55,4 +23,35 @@ public enum Category
|
||||
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;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.parabot.environment.scripts.framework.AbstractFramework;
|
||||
import org.parabot.environment.scripts.framework.LoopTask;
|
||||
import org.parabot.environment.scripts.framework.Strategy;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* Holds various script frameworks
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Frameworks {
|
||||
|
||||
@@ -31,6 +29,7 @@ class Looper extends AbstractFramework {
|
||||
public Looper(LoopTask loopTask) {
|
||||
this.loopTask = loopTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute() {
|
||||
int sleepTime = loopTask.loop();
|
||||
|
||||
@@ -141,6 +141,7 @@ public class Script implements Runnable {
|
||||
*
|
||||
* @param conn the condition.
|
||||
* @param timeout the time in miliseconds before it stops sleeping.
|
||||
*
|
||||
* @return whether it ran successfully without timing out.
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -148,18 +149,6 @@ public class Script implements Runnable {
|
||||
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
|
||||
*
|
||||
@@ -173,6 +162,18 @@ public class Script implements Runnable {
|
||||
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() {
|
||||
if (this.preferences == null) {
|
||||
this.preferences = new PBPreferences(scriptID);
|
||||
|
||||
@@ -5,8 +5,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* A script manifest, holds all script data
|
||||
* @author Everel
|
||||
*
|
||||
* @author Everel
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ScriptManifest {
|
||||
|
||||
@@ -15,11 +15,9 @@ import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
*
|
||||
* Loads a script from the BDN
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class BDNScriptsExecuter extends ScriptExecuter {
|
||||
|
||||
|
||||
@@ -5,11 +5,9 @@ import org.parabot.environment.scripts.Script;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* Loads a locally stored script
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class LocalScriptExecuter extends ScriptExecuter {
|
||||
private Constructor<?> scriptConstructor;
|
||||
|
||||
@@ -3,11 +3,9 @@ package org.parabot.environment.scripts.executers;
|
||||
import org.parabot.environment.scripts.Script;
|
||||
|
||||
/**
|
||||
*
|
||||
* Executes a script
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public abstract class ScriptExecuter {
|
||||
|
||||
@@ -15,6 +13,7 @@ public abstract class ScriptExecuter {
|
||||
|
||||
/**
|
||||
* Start script.
|
||||
*
|
||||
* @param tg
|
||||
* @param script
|
||||
*/
|
||||
@@ -23,5 +22,4 @@ public abstract class ScriptExecuter {
|
||||
thread.start();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package org.parabot.environment.scripts.framework;
|
||||
|
||||
/**
|
||||
*
|
||||
* Abstract framework for a script
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractFramework {
|
||||
|
||||
/**
|
||||
* Executes this frame
|
||||
*
|
||||
* @return <b>true</b> if it should keep executing this framework, otherwise <b>false</b>.
|
||||
*/
|
||||
public abstract boolean execute();
|
||||
|
||||
@@ -3,11 +3,9 @@ package org.parabot.environment.scripts.framework;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* Holds various script frameworks
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Frameworks {
|
||||
|
||||
@@ -27,6 +25,7 @@ class Looper extends AbstractFramework {
|
||||
public Looper(LoopTask loopTask) {
|
||||
this.loopTask = loopTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute() {
|
||||
int sleepTime = loopTask.loop();
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
package org.parabot.environment.scripts.framework;
|
||||
|
||||
/**
|
||||
*
|
||||
* A LoopTask interface is used to keep calling the loop method which should return the sleep time
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public interface LoopTask {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return sleepTime in ms
|
||||
*/
|
||||
public int loop();
|
||||
|
||||
@@ -4,12 +4,12 @@ package org.parabot.environment.scripts.framework;
|
||||
* Keeps sleeping till a condition is valid
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public interface SleepCondition {
|
||||
|
||||
/**
|
||||
* Determine if condition is valid
|
||||
*
|
||||
* @return <b>true</b> if valid, otherwise <b>false</b>.
|
||||
*/
|
||||
public boolean isValid();
|
||||
|
||||
@@ -4,12 +4,12 @@ package org.parabot.environment.scripts.framework;
|
||||
* Strategy framework for scripts
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public interface Strategy {
|
||||
|
||||
/**
|
||||
* Whether to activate this strategy
|
||||
*
|
||||
* @return <b>true</b> if this strategy should be executed, otherwise <b>false</b>.
|
||||
*/
|
||||
public boolean activate();
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
package org.parabot.environment.scripts.loader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.parabot.core.asm.ASMClassLoader;
|
||||
import org.parabot.core.classpath.ClassPath;
|
||||
import org.parabot.environment.scripts.Script;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* An environment to load a script
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class JavaScriptLoader extends ASMClassLoader {
|
||||
private ClassPath classPath;
|
||||
@@ -24,18 +21,19 @@ public class JavaScriptLoader extends ASMClassLoader {
|
||||
this.classPath = classPath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets all classes that extends ServerProvider
|
||||
*
|
||||
* @return string array of class names that extends ServerProvider
|
||||
*/
|
||||
public final String[] getScriptClassNames() {
|
||||
final List<String> classNames = new ArrayList<String>();
|
||||
for (ClassNode c : classPath.classes.values())
|
||||
for (ClassNode c : classPath.classes.values()) {
|
||||
if (c.superName.replace('/', '.').equals(
|
||||
Script.class.getName())) {
|
||||
classNames.add(c.name.replace('/', '.'));
|
||||
}
|
||||
}
|
||||
return classNames.toArray(new String[classNames.size()]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,15 @@ package org.parabot.environment.scripts.randoms;
|
||||
|
||||
/**
|
||||
* @author Everel
|
||||
* @deprecated
|
||||
* @see org.parabot.environment.randoms.Random
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Random {
|
||||
|
||||
/**
|
||||
* Determines whether this random should activate
|
||||
*
|
||||
* @return <b>true</b> if this random should activate
|
||||
*/
|
||||
public boolean activate();
|
||||
@@ -21,12 +22,14 @@ public interface Random {
|
||||
|
||||
/**
|
||||
* Returns the name of the random
|
||||
*
|
||||
* @return Name of the random
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Returns the name of the server which the random is made for
|
||||
*
|
||||
* @return Name of the server
|
||||
*/
|
||||
public String getServer();
|
||||
|
||||
@@ -2,8 +2,8 @@ package org.parabot.environment.scripts.randoms;
|
||||
|
||||
/**
|
||||
* @author Everel
|
||||
* @deprecated
|
||||
* @see org.parabot.environment.randoms.RandomHandler
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public class RandomHandler extends org.parabot.environment.randoms.RandomHandler {
|
||||
|
||||
@@ -9,11 +9,9 @@ import org.parabot.environment.servers.executers.ServerExecuter;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Loads locally stored server providers
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
@Deprecated
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user