mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 00:37:55 +00:00
[CLEANUP] Formatted code
This commit is contained in:
@@ -12,9 +12,11 @@ import org.parabot.core.ui.BotUI;
|
|||||||
import org.parabot.core.ui.ServerSelector;
|
import org.parabot.core.ui.ServerSelector;
|
||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Everel, JKetelaar, Matt, Dane
|
* @author Everel, JKetelaar, Matt, Dane
|
||||||
* @version 2.8.1
|
* @version 2.8.1
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import org.parabot.environment.scripts.Script;
|
|||||||
import org.parabot.environment.servers.ServerProvider;
|
import org.parabot.environment.servers.ServerProvider;
|
||||||
|
|
||||||
import java.applet.Applet;
|
import java.applet.Applet;
|
||||||
import java.awt.*;
|
import java.awt.Dimension;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -34,26 +34,26 @@ import java.util.TimerTask;
|
|||||||
public class Context {
|
public class Context {
|
||||||
public static final HashMap<ThreadGroup, Context> threadGroups = new HashMap<>();
|
public static final HashMap<ThreadGroup, Context> threadGroups = new HashMap<>();
|
||||||
|
|
||||||
private static ArrayList<Paintable> paintables = new ArrayList<>();
|
private static final ArrayList<Paintable> paintables = new ArrayList<>();
|
||||||
private static Context instance;
|
private static Context instance;
|
||||||
private static String username;
|
private static String username;
|
||||||
|
|
||||||
private ASMClassLoader classLoader;
|
private final ASMClassLoader classLoader;
|
||||||
private ClassPath classPath;
|
private final ClassPath classPath;
|
||||||
private ServerProvider serverProvider;
|
private final ServerProvider serverProvider;
|
||||||
private Applet gameApplet;
|
private final RandomHandler randomHandler;
|
||||||
private HookParser hookParser;
|
private final PaintDebugger paintDebugger;
|
||||||
private Script runningScript;
|
private final JSONParser jsonParser;
|
||||||
private RandomHandler randomHandler;
|
private final PrintStream defaultOut;
|
||||||
private Object clientInstance;
|
private final PrintStream defaultErr;
|
||||||
private PaintDebugger paintDebugger;
|
private Applet gameApplet;
|
||||||
private Mouse mouse;
|
private HookParser hookParser;
|
||||||
private Keyboard keyboard;
|
private Script runningScript;
|
||||||
private PBKeyListener pbKeyListener;
|
private Object clientInstance;
|
||||||
|
private Mouse mouse;
|
||||||
|
private Keyboard keyboard;
|
||||||
|
private PBKeyListener pbKeyListener;
|
||||||
private ServerProviderInfo providerInfo;
|
private ServerProviderInfo providerInfo;
|
||||||
private JSONParser jsonParser;
|
|
||||||
private PrintStream defaultOut;
|
|
||||||
private PrintStream defaultErr;
|
|
||||||
|
|
||||||
private Context(final ServerProvider serverProvider) {
|
private Context(final ServerProvider serverProvider) {
|
||||||
threadGroups.put(Thread.currentThread().getThreadGroup(), this);
|
threadGroups.put(Thread.currentThread().getThreadGroup(), this);
|
||||||
@@ -199,7 +199,7 @@ public class Context {
|
|||||||
|
|
||||||
Core.verbose(TranslationHelper.translate("APPLET_FETCHED"));
|
Core.verbose(TranslationHelper.translate("APPLET_FETCHED"));
|
||||||
|
|
||||||
final GamePanel panel = GamePanel.getInstance();
|
final GamePanel panel = GamePanel.getInstance();
|
||||||
final Dimension appletSize = serverProvider.getGameDimensions();
|
final Dimension appletSize = serverProvider.getGameDimensions();
|
||||||
|
|
||||||
panel.setPreferredSize(appletSize);
|
panel.setPreferredSize(appletSize);
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ import org.parabot.core.ui.utils.UILog;
|
|||||||
import org.parabot.environment.api.utils.Version;
|
import org.parabot.environment.api.utils.Version;
|
||||||
import org.parabot.environment.api.utils.WebUtil;
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.Desktop;
|
||||||
import java.awt.*;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -20,6 +19,8 @@ import java.net.URLEncoder;
|
|||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The core of parabot
|
* The core of parabot
|
||||||
*
|
*
|
||||||
@@ -28,17 +29,15 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
public class Core {
|
public class Core {
|
||||||
|
|
||||||
|
private static final Version currentVersion = Configuration.BOT_VERSION;
|
||||||
private static int quickLaunchByUuid = -1; // used like -server, but denoted by an Int rather than the server name
|
private static int quickLaunchByUuid = -1; // used like -server, but denoted by an Int rather than the server name
|
||||||
private static boolean debug; // Debug mode is Offline Mode. No BDN connection for Servers/Scripts/User Login. Not related to debug messages.
|
private static boolean debug; // Debug mode is Offline Mode. No BDN connection for Servers/Scripts/User Login. Not related to debug messages.
|
||||||
private static boolean verbose;
|
private static boolean verbose;
|
||||||
private static boolean dump;
|
private static boolean dump;
|
||||||
private static boolean loadLocal; //Loads both local and public scripts/servers
|
private static boolean loadLocal; //Loads both local and public scripts/servers
|
||||||
|
|
||||||
private static boolean validate = true;
|
private static boolean validate = true;
|
||||||
private static boolean secure = true;
|
private static boolean secure = true;
|
||||||
|
|
||||||
private static Version currentVersion = Configuration.BOT_VERSION;
|
|
||||||
|
|
||||||
public static void disableValidation() {
|
public static void disableValidation() {
|
||||||
Core.validate = false;
|
Core.validate = false;
|
||||||
}
|
}
|
||||||
@@ -251,7 +250,7 @@ public class Core {
|
|||||||
|
|
||||||
byte[] mdbytes = md.digest();
|
byte[] mdbytes = md.digest();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder("");
|
StringBuilder sb = new StringBuilder();
|
||||||
for (byte mdbyte : mdbytes) {
|
for (byte mdbyte : mdbytes) {
|
||||||
sb.append(Integer.toString((mdbyte & 0xff) + 0x100, 16).substring(1));
|
sb.append(Integer.toString((mdbyte & 0xff) + 0x100, 16).substring(1));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.Properties;
|
|||||||
public class ProjectProperties {
|
public class ProjectProperties {
|
||||||
|
|
||||||
private static ProjectProperties instance;
|
private static ProjectProperties instance;
|
||||||
private Properties cached = new Properties();
|
private final Properties cached = new Properties();
|
||||||
|
|
||||||
private ProjectProperties() {
|
private ProjectProperties() {
|
||||||
setProperties();
|
setProperties();
|
||||||
|
|||||||
@@ -22,14 +22,19 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class ASMClassLoader extends ClassLoader {
|
public class ASMClassLoader extends ClassLoader {
|
||||||
|
|
||||||
public ClassPath classPath;
|
private final Map<String, Class<?>> classCache;
|
||||||
private Map<String, Class<?>> classCache;
|
public ClassPath classPath;
|
||||||
|
|
||||||
public ASMClassLoader(final ClassPath classPath) {
|
public ASMClassLoader(final ClassPath classPath) {
|
||||||
this.classCache = new HashMap<String, Class<?>>();
|
this.classCache = new HashMap<String, Class<?>>();
|
||||||
this.classPath = classPath;
|
this.classPath = classPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> loadClass(String name) throws ClassNotFoundException {
|
||||||
|
return findClass(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected URL findResource(String name) {
|
protected URL findResource(String name) {
|
||||||
if (getSystemResource(name) == null) {
|
if (getSystemResource(name) == null) {
|
||||||
@@ -47,11 +52,6 @@ public class ASMClassLoader extends ClassLoader {
|
|||||||
return getSystemResource(name);
|
return getSystemResource(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<?> loadClass(String name) throws ClassNotFoundException {
|
|
||||||
return findClass(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.objectweb.asm.commons.Remapper;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class ClassRemapper extends Remapper {
|
public class ClassRemapper extends Remapper {
|
||||||
private static HashMap<String, String> remapNames = new HashMap<String, String>();
|
private static final HashMap<String, String> remapNames = new HashMap<String, String>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
remapNames.put("java/net/Socket", "org/parabot/core/network/proxy/ProxySocket");
|
remapNames.put("java/net/Socket", "org/parabot/core/network/proxy/ProxySocket");
|
||||||
|
|||||||
@@ -5,7 +5,15 @@ import org.objectweb.asm.MethodVisitor;
|
|||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.parabot.core.Core;
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.Directories;
|
import org.parabot.core.Directories;
|
||||||
import org.parabot.core.asm.redirect.*;
|
import org.parabot.core.asm.redirect.ClassRedirect;
|
||||||
|
import org.parabot.core.asm.redirect.ProcessBuilderRedirect;
|
||||||
|
import org.parabot.core.asm.redirect.RuntimeMXBeanRedirect;
|
||||||
|
import org.parabot.core.asm.redirect.RuntimeRedirect;
|
||||||
|
import org.parabot.core.asm.redirect.StackTraceElementRedirect;
|
||||||
|
import org.parabot.core.asm.redirect.SystemRedirect;
|
||||||
|
import org.parabot.core.asm.redirect.ThreadRedirect;
|
||||||
|
import org.parabot.core.asm.redirect.ToolkitRedirect;
|
||||||
|
import org.parabot.core.asm.redirect.URLClassLoaderRedirect;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|||||||
@@ -3,7 +3,14 @@ package org.parabot.core.asm.adapters;
|
|||||||
import org.objectweb.asm.Label;
|
import org.objectweb.asm.Label;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
import org.objectweb.asm.tree.*;
|
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.parabot.core.asm.ASMUtils;
|
import org.parabot.core.asm.ASMUtils;
|
||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
|
|
||||||
@@ -15,12 +22,12 @@ import java.lang.reflect.Modifier;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class AddCallbackAdapter implements Injectable, Opcodes {
|
public class AddCallbackAdapter implements Injectable, Opcodes {
|
||||||
private MethodNode method;
|
private final MethodNode method;
|
||||||
private String invokeClass;
|
private final String invokeClass;
|
||||||
private String invokeMethod;
|
private final String invokeMethod;
|
||||||
private String desc;
|
private final String desc;
|
||||||
private int[] args;
|
private final int[] args;
|
||||||
private boolean conditional;
|
private final boolean conditional;
|
||||||
|
|
||||||
public AddCallbackAdapter(final MethodNode method,
|
public AddCallbackAdapter(final MethodNode method,
|
||||||
final String invokeClass, final String invokeMethod,
|
final String invokeClass, final String invokeMethod,
|
||||||
@@ -35,9 +42,9 @@ public class AddCallbackAdapter implements Injectable, Opcodes {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inject() {
|
public void inject() {
|
||||||
final Type[] types = Type.getArgumentTypes(this.method.desc);
|
final Type[] types = Type.getArgumentTypes(this.method.desc);
|
||||||
InsnList inject = new InsnList();
|
InsnList inject = new InsnList();
|
||||||
Label l0 = new Label();
|
Label l0 = new Label();
|
||||||
inject.add(new LabelNode(l0));
|
inject.add(new LabelNode(l0));
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
if (args != null) {
|
if (args != null) {
|
||||||
|
|||||||
@@ -2,11 +2,16 @@ package org.parabot.core.asm.adapters;
|
|||||||
|
|
||||||
import org.objectweb.asm.Label;
|
import org.objectweb.asm.Label;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.tree.*;
|
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;
|
||||||
|
|
||||||
public class AddDebugAdapter {
|
public class AddDebugAdapter {
|
||||||
|
private final MethodNode mn;
|
||||||
private ClassNode owner;
|
private ClassNode owner;
|
||||||
private MethodNode mn;
|
|
||||||
|
|
||||||
public AddDebugAdapter(ClassNode owner, MethodNode mn) {
|
public AddDebugAdapter(ClassNode owner, MethodNode mn) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ import java.lang.reflect.Modifier;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class AddGetterAdapter implements Opcodes, Injectable {
|
public class AddGetterAdapter implements Opcodes, Injectable {
|
||||||
private ClassNode into;
|
private final ClassNode into;
|
||||||
private ClassNode fieldLocation;
|
private final ClassNode fieldLocation;
|
||||||
private FieldNode fieldNode;
|
private final FieldNode fieldNode;
|
||||||
private String methodName;
|
private final String methodName;
|
||||||
private String returnDesc;
|
private final String returnDesc;
|
||||||
private boolean staticField;
|
private final boolean staticField;
|
||||||
private boolean staticMethod;
|
private final boolean staticMethod;
|
||||||
private long multiplier;
|
private long multiplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param into - classnode to inject getter method in
|
* @param into - classnode to inject getter method in
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import org.parabot.core.asm.interfaces.Injectable;
|
|||||||
public class AddInterfaceAdapter implements Injectable {
|
public class AddInterfaceAdapter implements Injectable {
|
||||||
private static String accessorPackage;
|
private static String accessorPackage;
|
||||||
|
|
||||||
private ClassNode node;
|
private final ClassNode node;
|
||||||
private String interfaceClass;
|
private final String interfaceClass;
|
||||||
|
|
||||||
public AddInterfaceAdapter(ClassNode node, String interfaceClass) {
|
public AddInterfaceAdapter(ClassNode node, String interfaceClass) {
|
||||||
this.node = node;
|
this.node = node;
|
||||||
@@ -35,17 +35,6 @@ public class AddInterfaceAdapter implements Injectable {
|
|||||||
accessorPackage = packageName;
|
accessorPackage = packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void addInterface(ClassNode node, String i) {
|
|
||||||
ASMUtils.makePublic(node);
|
|
||||||
for (Object mn : node.methods) {
|
|
||||||
MethodNode methodNode = (MethodNode) mn;
|
|
||||||
if (methodNode.name.startsWith("<init")) {
|
|
||||||
ASMUtils.makePublic(methodNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node.interfaces.add(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inject() {
|
public void inject() {
|
||||||
Core.verbose("Injecting: " + this.toString());
|
Core.verbose("Injecting: " + this.toString());
|
||||||
@@ -56,4 +45,15 @@ public class AddInterfaceAdapter implements Injectable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return new StringBuilder("[Injectable: interface, into classname: ").append(node.name).append(", interface: ").append(accessorPackage).append(interfaceClass).append("]").toString();
|
return new StringBuilder("[Injectable: interface, into classname: ").append(node.name).append(", interface: ").append(accessorPackage).append(interfaceClass).append("]").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static void addInterface(ClassNode node, String i) {
|
||||||
|
ASMUtils.makePublic(node);
|
||||||
|
for (Object mn : node.methods) {
|
||||||
|
MethodNode methodNode = (MethodNode) mn;
|
||||||
|
if (methodNode.name.startsWith("<init")) {
|
||||||
|
ASMUtils.makePublic(methodNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node.interfaces.add(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,17 +15,17 @@ import java.lang.reflect.Modifier;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class AddInvokerAdapter implements Opcodes, Injectable {
|
public class AddInvokerAdapter implements Opcodes, Injectable {
|
||||||
private ClassNode into;
|
private final ClassNode into;
|
||||||
private ClassNode methodLocation;
|
private final ClassNode methodLocation;
|
||||||
private MethodNode mn;
|
private final MethodNode mn;
|
||||||
private String argsDesc;
|
private final String argsDesc;
|
||||||
private String returnDesc;
|
private final String returnDesc;
|
||||||
private String methodName;
|
private final String methodName;
|
||||||
private boolean isInterface;
|
private final boolean isInterface;
|
||||||
private String instanceCast;
|
private final String instanceCast;
|
||||||
private String mName;
|
private final String mName;
|
||||||
private String mDesc;
|
private final String mDesc;
|
||||||
private String argsCheckCast;
|
private final String argsCheckCast;
|
||||||
|
|
||||||
private boolean isStatic;
|
private boolean isStatic;
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ public class AddInvokerAdapter implements Opcodes, Injectable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.argsDesc.equals("()")) {
|
if (!this.argsDesc.equals("()")) {
|
||||||
Type[] castArgs = argsCheckCast == null ? null : Type.getArgumentTypes(argsCheckCast + "V");
|
Type[] castArgs = argsCheckCast == null ? null : Type.getArgumentTypes(argsCheckCast + "V");
|
||||||
Type[] methodArgs = Type.getArgumentTypes(argsDesc + "V");
|
Type[] methodArgs = Type.getArgumentTypes(argsDesc + "V");
|
||||||
|
|
||||||
for (int i = 0; i < methodArgs.length; i++) {
|
for (int i = 0; i < methodArgs.length; i++) {
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ import org.parabot.core.asm.interfaces.Injectable;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class AddSetterAdapter implements Opcodes, Injectable {
|
public class AddSetterAdapter implements Opcodes, Injectable {
|
||||||
private ClassNode fieldLocation;
|
private final ClassNode fieldLocation;
|
||||||
private ClassNode into;
|
private final ClassNode into;
|
||||||
private FieldNode field;
|
private final FieldNode field;
|
||||||
private String name;
|
private final String name;
|
||||||
private String desc;
|
private final String desc;
|
||||||
private boolean methodStatic;
|
private final boolean methodStatic;
|
||||||
|
|
||||||
public AddSetterAdapter(ClassNode fieldLocation, ClassNode into,
|
public AddSetterAdapter(ClassNode fieldLocation, ClassNode into,
|
||||||
FieldNode field, String name, String desc, boolean methodStatic) {
|
FieldNode field, String name, String desc, boolean methodStatic) {
|
||||||
@@ -35,6 +35,27 @@ public class AddSetterAdapter implements Opcodes, Injectable {
|
|||||||
this(fieldLocation, into, field, name, desc, false);
|
this(fieldLocation, into, field, name, desc, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Injects the setter
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void inject() {
|
||||||
|
Core.verbose("Injecting: " + this.toString());
|
||||||
|
addSetter(fieldLocation, into, field, name, desc, methodStatic);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new StringBuilder("[Injectable: setter, into classname: ")
|
||||||
|
.append(into.name).append(", field classname: ")
|
||||||
|
.append(fieldLocation.name).append(", field name: ")
|
||||||
|
.append(field.name).append(", field desc: ").append(field.desc)
|
||||||
|
.append(", method name: ").append(name)
|
||||||
|
.append(", method desc: ").append(desc)
|
||||||
|
.append(", static method: ").append(methodStatic).append("]")
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
|
||||||
private static void addSetter(ClassNode fieldLocation, ClassNode into,
|
private static void addSetter(ClassNode fieldLocation, ClassNode into,
|
||||||
FieldNode field, String name, String desc, boolean methodStatic) {
|
FieldNode field, String name, String desc, boolean methodStatic) {
|
||||||
if (desc.contains("L") && !desc.endsWith("Ljava/lang/String;")) {
|
if (desc.contains("L") && !desc.endsWith("Ljava/lang/String;")) {
|
||||||
@@ -61,25 +82,4 @@ public class AddSetterAdapter implements Opcodes, Injectable {
|
|||||||
into.methods.add(method);
|
into.methods.add(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Injects the setter
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void inject() {
|
|
||||||
Core.verbose("Injecting: " + this.toString());
|
|
||||||
addSetter(fieldLocation, into, field, name, desc, methodStatic);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new StringBuilder("[Injectable: setter, into classname: ")
|
|
||||||
.append(into.name).append(", field classname: ")
|
|
||||||
.append(fieldLocation.name).append(", field name: ")
|
|
||||||
.append(field.name).append(", field desc: ").append(field.desc)
|
|
||||||
.append(", method name: ").append(name)
|
|
||||||
.append(", method desc: ").append(desc)
|
|
||||||
.append(", static method: ").append(methodStatic).append("]")
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import java.util.ListIterator;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class AddSuperAdapter implements Injectable {
|
public class AddSuperAdapter implements Injectable {
|
||||||
private ClassNode node;
|
private final ClassNode node;
|
||||||
private String superClass;
|
private final String superClass;
|
||||||
|
|
||||||
public AddSuperAdapter(final ClassNode node, final String superClass) {
|
public AddSuperAdapter(final ClassNode node, final String superClass) {
|
||||||
this.node = node;
|
this.node = node;
|
||||||
@@ -30,6 +30,19 @@ public class AddSuperAdapter implements Injectable {
|
|||||||
this.superClass = superClass;
|
this.superClass = superClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inject() {
|
||||||
|
Core.verbose("Injecting: " + this.toString());
|
||||||
|
setSuper(node, superClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new StringBuilder("[Injectable: super, class name: ")
|
||||||
|
.append(node.name).append(", super: ").append(superClass)
|
||||||
|
.append("]").toString();
|
||||||
|
}
|
||||||
|
|
||||||
private static final void setSuper(final ClassNode node,
|
private static final void setSuper(final ClassNode node,
|
||||||
final String superClass) {
|
final String superClass) {
|
||||||
ListIterator<?> mli = node.methods.listIterator();
|
ListIterator<?> mli = node.methods.listIterator();
|
||||||
@@ -52,17 +65,4 @@ public class AddSuperAdapter implements Injectable {
|
|||||||
node.superName = superClass;
|
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: ")
|
|
||||||
.append(node.name).append(", super: ").append(superClass)
|
|
||||||
.append("]").toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class HookFile {
|
|||||||
public static final int TYPE_XML = 0;
|
public static final int TYPE_XML = 0;
|
||||||
public static final int TYPE_JSON = 1;
|
public static final int TYPE_JSON = 1;
|
||||||
|
|
||||||
private URL url;
|
private final URL url;
|
||||||
private int type;
|
private int type;
|
||||||
|
|
||||||
private boolean isLocal;
|
private boolean isLocal;
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ public interface Injectable {
|
|||||||
/**
|
/**
|
||||||
* Injects bytecode into a class
|
* Injects bytecode into a class
|
||||||
*/
|
*/
|
||||||
public void inject();
|
void inject();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,11 @@ import org.parabot.environment.scripts.Script;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.lang.reflect.TypeVariable;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
@@ -42,7 +46,9 @@ public class ClassRedirect {
|
|||||||
throw RedirectClassAdapter.createSecurityException();
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Method getDeclaredMethod(Class<?> c, String name, Class<?>... params) throws NoSuchMethodException, SecurityException {
|
public static Method getDeclaredMethod(Class<?> c, String name, Class<?>... params) throws
|
||||||
|
NoSuchMethodException,
|
||||||
|
SecurityException {
|
||||||
if (validStack() || validRequest(c)) {
|
if (validStack() || validRequest(c)) {
|
||||||
return c.getDeclaredMethod(name, params);
|
return c.getDeclaredMethod(name, params);
|
||||||
}
|
}
|
||||||
@@ -60,7 +66,7 @@ public class ClassRedirect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static URL getResource(Class<?> c, String path) {
|
public static URL getResource(Class<?> c, String path) {
|
||||||
if(validStack() || validRequest(c)) {
|
if (validStack() || validRequest(c)) {
|
||||||
return c.getResource(path);
|
return c.getResource(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +119,9 @@ public class ClassRedirect {
|
|||||||
throw RedirectClassAdapter.createSecurityException();
|
throw RedirectClassAdapter.createSecurityException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Method getMethod(Class<?> c, String name, Class<?>... params) throws NoSuchMethodException, SecurityException {
|
public static Method getMethod(Class<?> c, String name, Class<?>... params) throws
|
||||||
|
NoSuchMethodException,
|
||||||
|
SecurityException {
|
||||||
if (validStack() || validRequest(c)) {
|
if (validStack() || validRequest(c)) {
|
||||||
return c.getMethod(name, params);
|
return c.getMethod(name, params);
|
||||||
}
|
}
|
||||||
@@ -207,7 +215,9 @@ public class ClassRedirect {
|
|||||||
return c.getAnnotation(annotationClass);
|
return c.getAnnotation(annotationClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Constructor getDeclaredConstructor(Class c, Class[] parameterTypes) throws NoSuchMethodException, SecurityException {
|
public static Constructor getDeclaredConstructor(Class c, Class[] parameterTypes) throws
|
||||||
|
NoSuchMethodException,
|
||||||
|
SecurityException {
|
||||||
return c.getDeclaredConstructor(parameterTypes);
|
return c.getDeclaredConstructor(parameterTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
public class FileRedirect extends File {
|
public class FileRedirect extends File {
|
||||||
|
|
||||||
private static ArrayList<String> cachedFiles = new ArrayList<>();
|
private static final ArrayList<String> cachedFiles = new ArrayList<>();
|
||||||
|
|
||||||
public FileRedirect(String pathname) {
|
public FileRedirect(String pathname) {
|
||||||
super(pathname);
|
super(pathname);
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ public class RuntimeRedirect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static long totalMemory(Runtime runtime) {
|
public static long totalMemory(Runtime runtime) {
|
||||||
return (long) Random.between(1024, 4096);
|
return Random.between(1024, 4096);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long freeMemory(Runtime runtime) {
|
public static long freeMemory(Runtime runtime) {
|
||||||
return (long) Random.between(1024, 4096);
|
return Random.between(1024, 4096);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Process exec(Runtime r, String[] s) {
|
public static Process exec(Runtime r, String[] s) {
|
||||||
|
|||||||
@@ -23,18 +23,6 @@ public class SystemRedirect {
|
|||||||
System.exit(i);
|
System.exit(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getClassPath(){
|
|
||||||
String classPath = System.getProperty("java.class.path");
|
|
||||||
StringBuilder finalClassPath = new StringBuilder();
|
|
||||||
for (String path : classPath.split(":")) {
|
|
||||||
if (!path.toLowerCase().contains("parabot")) {
|
|
||||||
finalClassPath.append(path).append(":");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return finalClassPath.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getProperty(String s) {
|
public static String getProperty(String s) {
|
||||||
String value;
|
String value;
|
||||||
switch (s) {
|
switch (s) {
|
||||||
@@ -107,4 +95,16 @@ public class SystemRedirect {
|
|||||||
return System.nanoTime();
|
return System.nanoTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getClassPath() {
|
||||||
|
String classPath = System.getProperty("java.class.path");
|
||||||
|
StringBuilder finalClassPath = new StringBuilder();
|
||||||
|
for (String path : classPath.split(":")) {
|
||||||
|
if (!path.toLowerCase().contains("parabot")) {
|
||||||
|
finalClassPath.append(path).append(":");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return finalClassPath.toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import org.parabot.core.asm.RedirectClassAdapter;
|
|||||||
|
|
||||||
public class ThreadRedirect {
|
public class ThreadRedirect {
|
||||||
|
|
||||||
private static int count = 0;
|
private static final int count = 0;
|
||||||
|
|
||||||
public static void start(Thread t) {
|
public static void start(Thread t) {
|
||||||
t.start();
|
t.start();
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package org.parabot.core.asm.redirect;
|
package org.parabot.core.asm.redirect;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Cursor;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.Toolkit;
|
||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
import java.awt.datatransfer.DataFlavor;
|
import java.awt.datatransfer.DataFlavor;
|
||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import org.parabot.core.asm.interfaces.Injectable;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class Callback implements Injectable {
|
public class Callback implements Injectable {
|
||||||
private MethodNode method;
|
private final MethodNode method;
|
||||||
private String invokeClass;
|
private final String invokeClass;
|
||||||
private String invokeMethod;
|
private final String invokeMethod;
|
||||||
private String desc;
|
private final String desc;
|
||||||
private int[] args;
|
private final boolean conditional;
|
||||||
private boolean conditional;
|
private int[] args;
|
||||||
|
|
||||||
public Callback(final String className, final String methodName,
|
public Callback(final String className, final String methodName,
|
||||||
final String methodDesc, final String callbackClass,
|
final String methodDesc, final String callbackClass,
|
||||||
@@ -34,7 +34,7 @@ public class Callback implements Injectable {
|
|||||||
this.args[i] = Integer.parseInt(strArgs[i]);
|
this.args[i] = Integer.parseInt(strArgs[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.args = new int[]{Integer.parseInt(args)};
|
this.args = new int[]{ Integer.parseInt(args) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ public class Callback implements Injectable {
|
|||||||
|
|
||||||
sb.append("Injectable type: Callback");
|
sb.append("Injectable type: Callback");
|
||||||
|
|
||||||
if(method != null) {
|
if (method != null) {
|
||||||
sb.append(", intercepts method: ").append(method.name);
|
sb.append(", intercepts method: ").append(method.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ import org.parabot.core.asm.interfaces.Injectable;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class Getter implements Injectable {
|
public class Getter implements Injectable {
|
||||||
private ClassNode into;
|
private final ClassNode into;
|
||||||
private ClassNode fieldLocation;
|
private final ClassNode fieldLocation;
|
||||||
private FieldNode fieldNode;
|
private final FieldNode fieldNode;
|
||||||
private String methodName;
|
private final String methodName;
|
||||||
private String returnDesc;
|
private final String returnDesc;
|
||||||
private boolean staticMethod;
|
private final boolean staticMethod;
|
||||||
private long multiplier;
|
private long multiplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param into - classnode to inject getter method in
|
* @param into - classnode to inject getter method in
|
||||||
@@ -82,11 +82,11 @@ public class Getter implements Injectable {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Injectable type: Getter");
|
sb.append("Injectable type: Getter");
|
||||||
|
|
||||||
if(fieldLocation.interfaces.size() > 0) {
|
if (fieldLocation.interfaces.size() > 0) {
|
||||||
sb.append(", accessor type: ").append(fieldLocation.interfaces.get(0).toString().replace('/', '.'));
|
sb.append(", accessor type: ").append(fieldLocation.interfaces.get(0).toString().replace('/', '.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fieldNode != null) {
|
if (fieldNode != null) {
|
||||||
sb.append(", field: ").append(fieldNode.name);
|
sb.append(", field: ").append(fieldNode.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import org.parabot.core.asm.interfaces.Injectable;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class Interface implements Injectable {
|
public class Interface implements Injectable {
|
||||||
private String className;
|
private final String className;
|
||||||
private String interfaceClass;
|
private final String interfaceClass;
|
||||||
|
|
||||||
public Interface(String className, String interfaceClass) {
|
public Interface(String className, String interfaceClass) {
|
||||||
this.className = className;
|
this.className = className;
|
||||||
|
|||||||
@@ -13,18 +13,18 @@ import org.parabot.core.asm.interfaces.Injectable;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class Invoker implements Injectable {
|
public class Invoker implements Injectable {
|
||||||
private ClassNode into;
|
private final ClassNode into;
|
||||||
private ClassNode methodLocation;
|
private final ClassNode methodLocation;
|
||||||
private MethodNode mn;
|
private final MethodNode mn;
|
||||||
private String argsDesc;
|
private final String argsDesc;
|
||||||
private String returnDesc;
|
private final String returnDesc;
|
||||||
private String methodName;
|
private final String methodName;
|
||||||
private boolean isInterface;
|
private final boolean isInterface;
|
||||||
private String instanceCast;
|
private final String instanceCast;
|
||||||
private String argsCheckCastDesc;
|
private final String argsCheckCastDesc;
|
||||||
|
|
||||||
private String mName;
|
private final String mName;
|
||||||
private String mDesc;
|
private final String mDesc;
|
||||||
|
|
||||||
public Invoker(String methodLoc, String invMethName, String argsDesc,
|
public Invoker(String methodLoc, String invMethName, String argsDesc,
|
||||||
String returnDesc, String methodName) {
|
String returnDesc, String methodName) {
|
||||||
@@ -48,17 +48,6 @@ public class Invoker implements Injectable {
|
|||||||
this.argsCheckCastDesc = argsCheckCastDesc;
|
this.argsCheckCastDesc = argsCheckCastDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MethodNode getMethod(ClassNode into, String name, String argsDesc, String returnDesc) {
|
|
||||||
for (Object method : into.methods) {
|
|
||||||
MethodNode m = (MethodNode) method;
|
|
||||||
if (m.name.equals(name) && m.desc.substring(0, m.desc.indexOf(')') + 1).equals(argsDesc)
|
|
||||||
&& (returnDesc == null || Type.getType(m.desc).getReturnType().getDescriptor().equals(returnDesc))) {
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short route for getAdaptar().inject();
|
* Short route for getAdaptar().inject();
|
||||||
*
|
*
|
||||||
@@ -83,4 +72,15 @@ public class Invoker implements Injectable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Injectable type: Invoker, accessor: %s, method name: %s, invokes method: %s", methodLocation.name, methodName, mName);
|
return String.format("Injectable type: Invoker, accessor: %s, method name: %s, invokes method: %s", methodLocation.name, methodName, mName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static MethodNode getMethod(ClassNode into, String name, String argsDesc, String returnDesc) {
|
||||||
|
for (Object method : into.methods) {
|
||||||
|
MethodNode m = (MethodNode) method;
|
||||||
|
if (m.name.equals(name) && m.desc.substring(0, m.desc.indexOf(')') + 1).equals(argsDesc)
|
||||||
|
&& (returnDesc == null || Type.getType(m.desc).getReturnType().getDescriptor().equals(returnDesc))) {
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ import org.parabot.core.asm.interfaces.Injectable;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class Setter implements Injectable {
|
public class Setter implements Injectable {
|
||||||
private ClassNode fieldLocation;
|
private final ClassNode fieldLocation;
|
||||||
private ClassNode into;
|
private final ClassNode into;
|
||||||
private FieldNode field;
|
private final FieldNode field;
|
||||||
private String name;
|
private final String name;
|
||||||
private String desc;
|
private final String desc;
|
||||||
private boolean methodStatic;
|
private final boolean methodStatic;
|
||||||
|
|
||||||
public Setter(final String fieldLocation, String into, final String fieldName, final String methodName, final String desc, final boolean methodStatic, final String fieldDesc) {
|
public Setter(final String fieldLocation, String into, final String fieldName, final String methodName, final String desc, final boolean methodStatic, final String fieldDesc) {
|
||||||
this.fieldLocation = ASMUtils.getClass(fieldLocation);
|
this.fieldLocation = ASMUtils.getClass(fieldLocation);
|
||||||
@@ -57,11 +57,11 @@ public class Setter implements Injectable {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Injectable type: Setter");
|
sb.append("Injectable type: Setter");
|
||||||
|
|
||||||
if(fieldLocation.interfaces.size() > 0) {
|
if (fieldLocation.interfaces.size() > 0) {
|
||||||
sb.append(", accessor type: ").append(fieldLocation.interfaces.get(0).toString().replace('/', '.'));
|
sb.append(", accessor type: ").append(fieldLocation.interfaces.get(0).toString().replace('/', '.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(field != null) {
|
if (field != null) {
|
||||||
sb.append(", field: ").append(field.name);
|
sb.append(", field: ").append(field.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import org.parabot.core.asm.interfaces.Injectable;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class Super implements Injectable {
|
public class Super implements Injectable {
|
||||||
private String className;
|
private final String className;
|
||||||
private String superClassName;
|
private final String superClassName;
|
||||||
|
|
||||||
public Super(String className, String superClassName) {
|
public Super(String className, String superClassName) {
|
||||||
this.className = className;
|
this.className = className;
|
||||||
|
|||||||
@@ -11,7 +11,13 @@ import org.parabot.core.build.BuildPath;
|
|||||||
import org.parabot.core.io.SizeInputStream;
|
import org.parabot.core.io.SizeInputStream;
|
||||||
import org.parabot.core.ui.components.VerboseLoader;
|
import org.parabot.core.ui.components.VerboseLoader;
|
||||||
|
|
||||||
import java.io.*;
|
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 java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
@@ -32,14 +38,14 @@ import java.util.zip.ZipInputStream;
|
|||||||
* @author Matt
|
* @author Matt
|
||||||
*/
|
*/
|
||||||
public class ClassPath {
|
public class ClassPath {
|
||||||
public final ArrayList<String> classNames;
|
public final ArrayList<String> classNames;
|
||||||
public final HashMap<String, ClassNode> classes;
|
public final HashMap<String, ClassNode> classes;
|
||||||
public final Map<String, File> resources;
|
public final Map<String, File> resources;
|
||||||
public URL lastParsed;
|
private final ClassRemapper classRemapper;
|
||||||
private ClassRemapper classRemapper;
|
private final boolean isJar;
|
||||||
private boolean isJar;
|
private final ArrayList<URL> jarFiles;
|
||||||
private boolean parseJar;
|
public URL lastParsed;
|
||||||
private ArrayList<URL> jarFiles;
|
private boolean parseJar;
|
||||||
|
|
||||||
public ClassPath() {
|
public ClassPath() {
|
||||||
this(false);
|
this(false);
|
||||||
@@ -83,7 +89,7 @@ public class ClassPath {
|
|||||||
final SizeInputStream sizeInputStream = new SizeInputStream(
|
final SizeInputStream sizeInputStream = new SizeInputStream(
|
||||||
connection.getInputStream(), size, VerboseLoader.get());
|
connection.getInputStream(), size, VerboseLoader.get());
|
||||||
final ZipInputStream zin = new ZipInputStream(sizeInputStream);
|
final ZipInputStream zin = new ZipInputStream(sizeInputStream);
|
||||||
ZipEntry e;
|
ZipEntry e;
|
||||||
while ((e = zin.getNextEntry()) != null) {
|
while ((e = zin.getNextEntry()) != null) {
|
||||||
if (e.isDirectory()) {
|
if (e.isDirectory()) {
|
||||||
continue;
|
continue;
|
||||||
@@ -180,23 +186,6 @@ public class ClassPath {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads class from input stream
|
|
||||||
*
|
|
||||||
* @param in
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
protected void loadClass(InputStream in) throws IOException {
|
|
||||||
ClassReader cr = new ClassReader(in);
|
|
||||||
ClassNode cn = new ClassNode();
|
|
||||||
RemappingClassAdapter rca = new RemappingClassAdapter(cn, classRemapper);
|
|
||||||
RedirectClassAdapter redir = new RedirectClassAdapter(rca);
|
|
||||||
cr.accept(redir, ClassReader.EXPAND_FRAMES);
|
|
||||||
classNames.add(cn.name.replace('/', '.'));
|
|
||||||
classes.put(cn.name, cn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if this classpath represents a jar file
|
* Determines if this classpath represents a jar file
|
||||||
*
|
*
|
||||||
@@ -221,31 +210,6 @@ public class ClassPath {
|
|||||||
return jars;
|
return jars;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Dumps a resource from a input stream
|
|
||||||
*
|
|
||||||
* @param classPath
|
|
||||||
* @param name
|
|
||||||
* @param inputstream
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
private void loadResource(final String name, final InputStream in)
|
|
||||||
throws IOException {
|
|
||||||
final File f = File.createTempFile("bot", ".tmp",
|
|
||||||
Directories.getTempDirectory());
|
|
||||||
f.deleteOnExit();
|
|
||||||
try (OutputStream out = new FileOutputStream(f)) {
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int len;
|
|
||||||
while ((len = in.read(buffer)) != -1) {
|
|
||||||
out.write(buffer, 0, len);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
this.resources.put(name, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds this jar to buildpath
|
* Adds this jar to buildpath
|
||||||
*/
|
*/
|
||||||
@@ -302,4 +266,46 @@ public class ClassPath {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads class from input stream
|
||||||
|
*
|
||||||
|
* @param in
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
protected void loadClass(InputStream in) throws IOException {
|
||||||
|
ClassReader cr = new ClassReader(in);
|
||||||
|
ClassNode cn = new ClassNode();
|
||||||
|
RemappingClassAdapter rca = new RemappingClassAdapter(cn, classRemapper);
|
||||||
|
RedirectClassAdapter redir = new RedirectClassAdapter(rca);
|
||||||
|
cr.accept(redir, ClassReader.EXPAND_FRAMES);
|
||||||
|
classNames.add(cn.name.replace('/', '.'));
|
||||||
|
classes.put(cn.name, cn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps a resource from a input stream
|
||||||
|
*
|
||||||
|
* @param classPath
|
||||||
|
* @param name
|
||||||
|
* @param inputstream
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
private void loadResource(final String name, final InputStream in)
|
||||||
|
throws IOException {
|
||||||
|
final File f = File.createTempFile("bot", ".tmp",
|
||||||
|
Directories.getTempDirectory());
|
||||||
|
f.deleteOnExit();
|
||||||
|
try (OutputStream out = new FileOutputStream(f)) {
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int len;
|
||||||
|
while ((len = in.read(buffer)) != -1) {
|
||||||
|
out.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
this.resources.put(name, f);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ package org.parabot.core.desc;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class ScriptDescription implements Comparable<ScriptDescription> {
|
public class ScriptDescription implements Comparable<ScriptDescription> {
|
||||||
public String scriptName;
|
public String scriptName;
|
||||||
public String author;
|
public String author;
|
||||||
public String category;
|
public String category;
|
||||||
public double version;
|
public double version;
|
||||||
public String description;
|
public String description;
|
||||||
public String[] servers;
|
public String[] servers;
|
||||||
public String isVip;
|
public String isVip;
|
||||||
public String isPremium;
|
public String isPremium;
|
||||||
public int bdnId;
|
public int bdnId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ScriptManifest
|
* The ScriptManifest
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ package org.parabot.core.desc;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class ServerDescription implements Comparable<ServerDescription> {
|
public class ServerDescription implements Comparable<ServerDescription> {
|
||||||
private String serverName;
|
private final String serverName;
|
||||||
private String author;
|
private final String author;
|
||||||
private double revision;
|
private final double revision;
|
||||||
public int uuid;
|
public int uuid;
|
||||||
|
|
||||||
public ServerDescription(final String serverName, final String author,
|
public ServerDescription(final String serverName, final String author,
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import java.util.zip.CRC32;
|
|||||||
*/
|
*/
|
||||||
public class ServerProviderInfo {
|
public class ServerProviderInfo {
|
||||||
|
|
||||||
private HashMap<String, Integer> settings;
|
private final HashMap<String, Integer> settings;
|
||||||
private Properties properties;
|
private final Properties properties;
|
||||||
|
|
||||||
public ServerProviderInfo(URL providerInfo, String username, String password) {
|
public ServerProviderInfo(URL providerInfo, String username, String password) {
|
||||||
this.properties = new Properties();
|
this.properties = new Properties();
|
||||||
@@ -52,11 +52,12 @@ public class ServerProviderInfo {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize configuration with data provided by {@link org.parabot.core.parsers.servers.LocalServers} from a {@code /parabot/servers/config.json} file. Also loads the default Settings map from the BDN.
|
* Initialize configuration with data provided by {@link org.parabot.core.parsers.servers.LocalServers} from a {@code /parabot/servers/config.json} file. Also loads the default Settings map from the BDN.
|
||||||
* @param clientJar Name of the client jar file
|
*
|
||||||
* @param hooks Name of the hooks file
|
* @param clientJar Name of the client jar file
|
||||||
* @param name Server name
|
* @param hooks Name of the hooks file
|
||||||
|
* @param name Server name
|
||||||
* @param clientClass Entry class within the client jar
|
* @param clientClass Entry class within the client jar
|
||||||
* @param bankTabs Bank tabs - only relevant for certain servers. Default 0
|
* @param bankTabs Bank tabs - only relevant for certain servers. Default 0
|
||||||
*/
|
*/
|
||||||
public ServerProviderInfo(String clientJar, String hooks, String name, String clientClass, int bankTabs) {
|
public ServerProviderInfo(String clientJar, String hooks, String name, String clientClass, int bankTabs) {
|
||||||
this(clientJar, hooks, name, clientClass, bankTabs, null);
|
this(clientJar, hooks, name, clientClass, bankTabs, null);
|
||||||
@@ -64,20 +65,21 @@ public class ServerProviderInfo {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize configuration with data provided by {@link org.parabot.core.parsers.servers.LocalServers} from a {@code /parabot/servers/config.json} file. Also loads the default Settings map from the BDN.
|
* Initialize configuration with data provided by {@link org.parabot.core.parsers.servers.LocalServers} from a {@code /parabot/servers/config.json} file. Also loads the default Settings map from the BDN.
|
||||||
* @param clientJar Name of the client jar file
|
*
|
||||||
* @param hooks Name of the hooks file
|
* @param clientJar Name of the client jar file
|
||||||
* @param name Server name
|
* @param hooks Name of the hooks file
|
||||||
|
* @param name Server name
|
||||||
* @param clientClass Entry class within the client jar
|
* @param clientClass Entry class within the client jar
|
||||||
* @param bankTabs Bank tabs - only relevant for certain servers. Default 0
|
* @param bankTabs Bank tabs - only relevant for certain servers. Default 0
|
||||||
* @param randoms A URL to an endpoint where the Randoms are located. Can be Null, in which case getRandoms() will fallback to the default BDN Randoms URL.
|
* @param randoms A URL to an endpoint where the Randoms are located. Can be Null, in which case getRandoms() will fallback to the default BDN Randoms URL.
|
||||||
*/
|
*/
|
||||||
public ServerProviderInfo(String clientJar, String hooks, String name, String clientClass, int bankTabs, String randoms) {
|
public ServerProviderInfo(String clientJar, String hooks, String name, String clientClass, int bankTabs, String randoms) {
|
||||||
this.properties = new Properties();
|
this.properties = new Properties();
|
||||||
this.settings = new HashMap<>();
|
this.settings = new HashMap<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BufferedReader br = WebUtil.getReader(new URL(Configuration.GET_SERVER_SETTINGS));
|
BufferedReader br = WebUtil.getReader(new URL(Configuration.GET_SERVER_SETTINGS));
|
||||||
JSONObject settings = (JSONObject) WebUtil.getJsonParser().parse(br);
|
JSONObject settings = (JSONObject) WebUtil.getJsonParser().parse(br);
|
||||||
parseSettings(settings);
|
parseSettings(settings);
|
||||||
} catch (ParseException | IOException e) {
|
} catch (ParseException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -93,22 +95,6 @@ public class ServerProviderInfo {
|
|||||||
this.properties.setProperty("randoms_jar", randoms);
|
this.properties.setProperty("randoms_jar", randoms);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getCRC32(String name, String type) {
|
|
||||||
CRC32 crc = new CRC32();
|
|
||||||
name += "-" + type;
|
|
||||||
crc.update(name.getBytes());
|
|
||||||
return crc.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void parseSettings(JSONObject object) {
|
|
||||||
for (Object settingObject : object.entrySet()) {
|
|
||||||
Map.Entry<?, ?> settingValue = (Map.Entry<?, ?>) settingObject;
|
|
||||||
String key = (String) settingValue.getKey();
|
|
||||||
long value = (Long) settingValue.getValue();
|
|
||||||
settings.put(key, (int) value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public URL getClient() {
|
public URL getClient() {
|
||||||
try {
|
try {
|
||||||
return new URL(properties.getProperty("client_jar"));
|
return new URL(properties.getProperty("client_jar"));
|
||||||
@@ -190,12 +176,28 @@ public class ServerProviderInfo {
|
|||||||
* @return provider version
|
* @return provider version
|
||||||
*/
|
*/
|
||||||
public String getProviderVersion() {
|
public String getProviderVersion() {
|
||||||
String providerType = WebUtil.getJsonValue(String.format(Configuration.GET_SERVER_PROVIDER_TYPE , properties.getProperty("name")), "type");
|
String providerType = WebUtil.getJsonValue(String.format(Configuration.GET_SERVER_PROVIDER_TYPE, properties.getProperty("name")), "type");
|
||||||
if(providerType != null) {
|
if (providerType != null) {
|
||||||
String providerInfo = String.format(Configuration.SERVER_PROVIDER_INFO, providerType);
|
String providerInfo = String.format(Configuration.SERVER_PROVIDER_INFO, providerType);
|
||||||
return WebUtil.getJsonValue(providerInfo, "version");
|
return WebUtil.getJsonValue(providerInfo, "version");
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long getCRC32(String name, String type) {
|
||||||
|
CRC32 crc = new CRC32();
|
||||||
|
name += "-" + type;
|
||||||
|
crc.update(name.getBytes());
|
||||||
|
return crc.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseSettings(JSONObject object) {
|
||||||
|
for (Object settingObject : object.entrySet()) {
|
||||||
|
Map.Entry<?, ?> settingValue = (Map.Entry<?, ?>) settingObject;
|
||||||
|
String key = (String) settingValue.getKey();
|
||||||
|
long value = (Long) settingValue.getValue();
|
||||||
|
settings.put(key, (int) value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import java.net.URLEncoder;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class Account {
|
public class Account {
|
||||||
private String username;
|
private final String username;
|
||||||
private String password;
|
private final String password;
|
||||||
private String api;
|
private String api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,19 +13,20 @@ import org.parabot.environment.api.utils.WebUtil;
|
|||||||
import org.parabot.environment.scripts.executers.BDNScriptsExecuter;
|
import org.parabot.environment.scripts.executers.BDNScriptsExecuter;
|
||||||
import org.parabot.environment.servers.executers.PublicServerExecuter;
|
import org.parabot.environment.servers.executers.PublicServerExecuter;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles logging in to parabot forum, only certain classes may use this class.
|
* Handles logging in to parabot forum, only certain classes may use this class.
|
||||||
*
|
*
|
||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public final class AccountManager {
|
public final class AccountManager {
|
||||||
private static boolean validated;
|
private static boolean validated;
|
||||||
private static AccountManager instance;
|
private static AccountManager instance;
|
||||||
|
|
||||||
private Account account;
|
private Account account;
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ package org.parabot.core.forum;
|
|||||||
*/
|
*/
|
||||||
public interface AccountManagerAccess {
|
public interface AccountManagerAccess {
|
||||||
|
|
||||||
public void setManager(AccountManager manager);
|
void setManager(AccountManager manager);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ import java.io.InputStream;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class SizeInputStream extends InputStream {
|
public class SizeInputStream extends InputStream {
|
||||||
public int bytesRead;
|
private final ProgressListener l;
|
||||||
private ProgressListener l;
|
private final InputStream in;
|
||||||
private InputStream in;
|
private final long startTime;
|
||||||
private long startTime;
|
private final double size;
|
||||||
private double size;
|
public int bytesRead;
|
||||||
|
|
||||||
public SizeInputStream(InputStream in, int size, ProgressListener l) {
|
public SizeInputStream(InputStream in, int size, ProgressListener l) {
|
||||||
this.in = in;
|
this.in = in;
|
||||||
@@ -52,9 +52,9 @@ public class SizeInputStream extends InputStream {
|
|||||||
double percent = (bytesRead / size) * 100.0D;
|
double percent = (bytesRead / size) * 100.0D;
|
||||||
l.onProgressUpdate(percent);
|
l.onProgressUpdate(percent);
|
||||||
|
|
||||||
long curTime = System.currentTimeMillis();
|
long curTime = System.currentTimeMillis();
|
||||||
double timeSeconds = (curTime - startTime) / 1000.0D;
|
double timeSeconds = (curTime - startTime) / 1000.0D;
|
||||||
double speed = bytesRead / (1024.0D * 1024.0D) / timeSeconds;
|
double speed = bytesRead / (1024.0D * 1024.0D) / timeSeconds;
|
||||||
l.updateDownloadSpeed(speed);
|
l.updateDownloadSpeed(speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.NoSuchElementException;
|
|||||||
|
|
||||||
public class NetworkInterface {
|
public class NetworkInterface {
|
||||||
public static byte[] mac = new byte[]{ 11, 11, 11, 11, 11, 11 };
|
public static byte[] mac = new byte[]{ 11, 11, 11, 11, 11, 11 };
|
||||||
private static byte[] realMac;
|
private static byte[] realMac;
|
||||||
private static NetworkInterface cached;
|
private static NetworkInterface cached;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.io.IOException;
|
|||||||
public class Runtime {
|
public class Runtime {
|
||||||
|
|
||||||
private static Runtime cached;
|
private static Runtime cached;
|
||||||
private java.lang.Runtime rt;
|
private final java.lang.Runtime rt;
|
||||||
|
|
||||||
private Runtime(java.lang.Runtime rt) {
|
private Runtime(java.lang.Runtime rt) {
|
||||||
this.rt = rt;
|
this.rt = rt;
|
||||||
|
|||||||
@@ -3,23 +3,34 @@ package org.parabot.core.network.proxy;
|
|||||||
import org.parabot.core.Core;
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.io.BufferedReader;
|
||||||
import java.io.*;
|
import java.io.DataInputStream;
|
||||||
import java.net.*;
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.net.Socket;
|
||||||
|
import java.net.SocketAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
public class ProxySocket extends Socket {
|
public class ProxySocket extends Socket {
|
||||||
|
|
||||||
|
private static final List<ProxySocket> connections = new ArrayList<ProxySocket>();
|
||||||
public static boolean auth = false;
|
public static boolean auth = false;
|
||||||
private static List<ProxySocket> connections = new ArrayList<ProxySocket>();
|
|
||||||
private static ProxyType proxyType = ProxyType.NONE;
|
private static ProxyType proxyType = ProxyType.NONE;
|
||||||
private static int proxyPort = 0;
|
private static int proxyPort = 0;
|
||||||
private static String username = null, password = null;
|
private static String username = null, password = null;
|
||||||
private static InetAddress proxyInetAddress = null;
|
private static InetAddress proxyInetAddress = null;
|
||||||
private InetAddress addr;
|
private InetAddress addr;
|
||||||
private int port;
|
private int port;
|
||||||
private InetSocketAddress cachedAddr;
|
private InetSocketAddress cachedAddr;
|
||||||
|
|
||||||
public ProxySocket(InetAddress addr, int port) throws IOException {
|
public ProxySocket(InetAddress addr, int port) throws IOException {
|
||||||
@@ -112,6 +123,44 @@ public class ProxySocket extends Socket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPort() {
|
||||||
|
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
return super.getPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InetAddress getInetAddress() {
|
||||||
|
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
return super.getInetAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SocketAddress getRemoteSocketAddress() {
|
||||||
|
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||||
|
return cachedAddr;
|
||||||
|
}
|
||||||
|
return super.getRemoteSocketAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SocketChannel getChannel() {
|
||||||
|
if (super.getInetAddress().equals(proxyInetAddress)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return super.getChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
connections.remove(this);
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
private void initProxy() throws IOException {
|
private void initProxy() throws IOException {
|
||||||
System.out.println("Proxying:" + addr + ":" + port + " Over:"
|
System.out.println("Proxying:" + addr + ":" + port + " Over:"
|
||||||
+ proxyInetAddress + ":" + proxyPort + " Type:" + proxyType);
|
+ proxyInetAddress + ":" + proxyPort + " Type:" + proxyType);
|
||||||
@@ -131,9 +180,9 @@ public class ProxySocket extends Socket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void http_connect() throws IOException {
|
private void http_connect() throws IOException {
|
||||||
InputStream in = getInputStream();
|
InputStream in = getInputStream();
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||||
OutputStream out = getOutputStream();
|
OutputStream out = getOutputStream();
|
||||||
out.write(("CONNECT " + addr.getHostAddress() + ":" + port + "\r\n")
|
out.write(("CONNECT " + addr.getHostAddress() + ":" + port + "\r\n")
|
||||||
.getBytes());
|
.getBytes());
|
||||||
// out.write("Connection:keep-alive\r\n".getBytes());
|
// out.write("Connection:keep-alive\r\n".getBytes());
|
||||||
@@ -166,7 +215,7 @@ public class ProxySocket extends Socket {
|
|||||||
|
|
||||||
private void socks4_connect() throws IOException {
|
private void socks4_connect() throws IOException {
|
||||||
DataOutputStream out = new DataOutputStream(getOutputStream());
|
DataOutputStream out = new DataOutputStream(getOutputStream());
|
||||||
DataInputStream in = new DataInputStream(getInputStream());
|
DataInputStream in = new DataInputStream(getInputStream());
|
||||||
|
|
||||||
out.write(0x04);
|
out.write(0x04);
|
||||||
out.write(0x01); // connection type (TCP stream)
|
out.write(0x01); // connection type (TCP stream)
|
||||||
@@ -195,7 +244,7 @@ public class ProxySocket extends Socket {
|
|||||||
|
|
||||||
private void socks5_connect() throws IOException {
|
private void socks5_connect() throws IOException {
|
||||||
DataOutputStream out = new DataOutputStream(getOutputStream());
|
DataOutputStream out = new DataOutputStream(getOutputStream());
|
||||||
DataInputStream in = new DataInputStream(getInputStream());
|
DataInputStream in = new DataInputStream(getInputStream());
|
||||||
out.write(0x05); // the version
|
out.write(0x05); // the version
|
||||||
out.write(auth ? 2 : 1); // number of authentication methods (no auth
|
out.write(auth ? 2 : 1); // number of authentication methods (no auth
|
||||||
// for now)
|
// for now)
|
||||||
@@ -269,42 +318,4 @@ public class ProxySocket extends Socket {
|
|||||||
in.readShort(); // the returned port #, ignored
|
in.readShort(); // the returned port #, ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getPort() {
|
|
||||||
if (super.getInetAddress().equals(proxyInetAddress)) {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
return super.getPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InetAddress getInetAddress() {
|
|
||||||
if (super.getInetAddress().equals(proxyInetAddress)) {
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
return super.getInetAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SocketAddress getRemoteSocketAddress() {
|
|
||||||
if (super.getInetAddress().equals(proxyInetAddress)) {
|
|
||||||
return cachedAddr;
|
|
||||||
}
|
|
||||||
return super.getRemoteSocketAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SocketChannel getChannel() {
|
|
||||||
if (super.getInetAddress().equals(proxyInetAddress)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return super.getChannel();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws IOException {
|
|
||||||
connections.remove(this);
|
|
||||||
super.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,8 @@ package org.parabot.core.paint;
|
|||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
@@ -14,7 +15,7 @@ import java.util.Queue;
|
|||||||
*/
|
*/
|
||||||
public class PaintDebugger {
|
public class PaintDebugger {
|
||||||
private final HashMap<String, AbstractDebugger> debuggers;
|
private final HashMap<String, AbstractDebugger> debuggers;
|
||||||
private final Queue<String> stringDebug;
|
private final Queue<String> stringDebug;
|
||||||
|
|
||||||
public PaintDebugger() {
|
public PaintDebugger() {
|
||||||
this.debuggers = new HashMap<String, AbstractDebugger>();
|
this.debuggers = new HashMap<String, AbstractDebugger>();
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ package org.parabot.core.parsers.hooks;
|
|||||||
|
|
||||||
import org.parabot.core.asm.hooks.HookFile;
|
import org.parabot.core.asm.hooks.HookFile;
|
||||||
import org.parabot.core.asm.interfaces.Injectable;
|
import org.parabot.core.asm.interfaces.Injectable;
|
||||||
import org.parabot.core.asm.wrappers.*;
|
import org.parabot.core.asm.wrappers.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.forum.AccountManager;
|
import org.parabot.core.forum.AccountManager;
|
||||||
import org.parabot.core.forum.AccountManagerAccess;
|
import org.parabot.core.forum.AccountManagerAccess;
|
||||||
import org.parabot.environment.api.utils.PBPreferences;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -50,7 +54,7 @@ public abstract class HookParser {
|
|||||||
|
|
||||||
public Injectable[] getInjectables() {
|
public Injectable[] getInjectables() {
|
||||||
ArrayList<Injectable> injectables = new ArrayList<Injectable>();
|
ArrayList<Injectable> injectables = new ArrayList<Injectable>();
|
||||||
Interface[] interfaces = getInterfaces();
|
Interface[] interfaces = getInterfaces();
|
||||||
if (interfaces != null) {
|
if (interfaces != null) {
|
||||||
Collections.addAll(injectables, interfaces);
|
Collections.addAll(injectables, interfaces);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ import org.json.simple.JSONObject;
|
|||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
||||||
import org.parabot.core.asm.hooks.HookFile;
|
import org.parabot.core.asm.hooks.HookFile;
|
||||||
import org.parabot.core.asm.wrappers.*;
|
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 java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -18,8 +23,8 @@ import java.util.Map;
|
|||||||
* @author Dane, JKetelaar
|
* @author Dane, JKetelaar
|
||||||
*/
|
*/
|
||||||
public class JSONHookParser extends HookParser {
|
public class JSONHookParser extends HookParser {
|
||||||
private JSONObject root;
|
private JSONObject root;
|
||||||
private Map<String, String> interfaces;
|
private Map<String, String> interfaces;
|
||||||
private HashMap<String, String> constants;
|
private HashMap<String, String> constants;
|
||||||
|
|
||||||
public JSONHookParser(HookFile file) {
|
public JSONHookParser(HookFile file) {
|
||||||
@@ -63,7 +68,7 @@ public class JSONHookParser extends HookParser {
|
|||||||
for (int j = 0; j < a.size(); j++) {
|
for (int j = 0; j < a.size(); j++) {
|
||||||
JSONObject o = (JSONObject) a.get(j);
|
JSONObject o = (JSONObject) a.get(j);
|
||||||
|
|
||||||
String clazz = this.get(o, "class");
|
String clazz = this.get(o, "class");
|
||||||
String interfaze = this.get(o, "interface");
|
String interfaze = this.get(o, "interface");
|
||||||
|
|
||||||
interfaces.put(clazz, interfaze);
|
interfaces.put(clazz, interfaze);
|
||||||
@@ -118,9 +123,9 @@ public class JSONHookParser extends HookParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String clazz = o.containsKey("class") ? this.get(o, "class") : interfaces.get(this.get(o, "accessor"));
|
String clazz = o.containsKey("class") ? this.get(o, "class") : interfaces.get(this.get(o, "accessor"));
|
||||||
String into = o.containsKey("into") ? this.get(o, "into") : clazz;
|
String into = o.containsKey("into") ? this.get(o, "into") : clazz;
|
||||||
|
|
||||||
g[i] = new Getter(into, clazz, this.get(o, "field"), this.get(o, "method"), desc, o.containsKey("static") ? (boolean) o.get("static") : false, 0, null);
|
g[i] = new Getter(into, clazz, this.get(o, "field"), this.get(o, "method"), desc, o.containsKey("static") && (boolean) o.get("static"), 0, null);
|
||||||
}
|
}
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
@@ -151,9 +156,9 @@ public class JSONHookParser extends HookParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String clazz = o.containsKey("class") ? this.get(o, "class") : interfaces.get(this.get(o, "accessor"));
|
String clazz = o.containsKey("class") ? this.get(o, "class") : interfaces.get(this.get(o, "accessor"));
|
||||||
String into = o.containsKey("into") ? this.get(o, "into") : clazz;
|
String into = o.containsKey("into") ? this.get(o, "into") : clazz;
|
||||||
|
|
||||||
s[i] = new Setter(into, clazz, this.get(o, "field"), this.get(o, "method"), desc, o.containsKey("static") ? (boolean) o.get("static") : false, null);
|
s[i] = new Setter(into, clazz, this.get(o, "field"), this.get(o, "method"), desc, o.containsKey("static") && (boolean) o.get("static"), null);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -184,7 +189,7 @@ public class JSONHookParser extends HookParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String clazz = o.containsKey("class") ? this.get(o, "class") : interfaces.get(this.get(o, "accessor"));
|
String clazz = o.containsKey("class") ? this.get(o, "class") : interfaces.get(this.get(o, "accessor"));
|
||||||
String into = o.containsKey("into") ? this.get(o, "into") : clazz;
|
String into = o.containsKey("into") ? this.get(o, "into") : clazz;
|
||||||
|
|
||||||
i[j] = new Invoker(into, clazz, this.get(o, "invokemethod"), this.get(o, "argdesc"), this.get(o, "desc"), this.get(o, "method"), false, null, null);
|
i[j] = new Invoker(into, clazz, this.get(o, "invokemethod"), this.get(o, "argdesc"), this.get(o, "desc"), this.get(o, "method"), false, null, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,24 @@ package org.parabot.core.parsers.hooks;
|
|||||||
import org.parabot.core.Core;
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
import org.parabot.core.asm.adapters.AddInterfaceAdapter;
|
||||||
import org.parabot.core.asm.hooks.HookFile;
|
import org.parabot.core.asm.hooks.HookFile;
|
||||||
import org.parabot.core.asm.wrappers.*;
|
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.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses an XML file which injects the hooks and other bytecode manipulation
|
* Parses an XML file which injects the hooks and other bytecode manipulation
|
||||||
* methods
|
* methods
|
||||||
@@ -22,9 +28,9 @@ import java.util.Map;
|
|||||||
* @author JKetelaar
|
* @author JKetelaar
|
||||||
*/
|
*/
|
||||||
public class XMLHookParser extends HookParser {
|
public class XMLHookParser extends HookParser {
|
||||||
private Document doc;
|
private final Document doc;
|
||||||
private HashMap<String, String> interfaceMap;
|
private final HashMap<String, String> interfaceMap;
|
||||||
private HashMap<String, String> constants;
|
private final HashMap<String, String> constants;
|
||||||
private boolean parsedInterfaces;
|
private boolean parsedInterfaces;
|
||||||
|
|
||||||
public XMLHookParser(HookFile hookFile) {
|
public XMLHookParser(HookFile hookFile) {
|
||||||
@@ -170,8 +176,8 @@ public class XMLHookParser extends HookParser {
|
|||||||
final String fieldName = getValue("field", addGetter);
|
final String fieldName = getValue("field", addGetter);
|
||||||
final String fieldDesc = isSet("descfield", addGetter) ? getValue("descfield", addGetter) : null;
|
final String fieldDesc = isSet("descfield", addGetter) ? getValue("descfield", addGetter) : null;
|
||||||
final String methodName = getValue("methodname", addGetter);
|
final String methodName = getValue("methodname", addGetter);
|
||||||
boolean staticMethod = isSet("methstatic", addGetter) ? (getValue(
|
boolean staticMethod = isSet("methstatic", addGetter) && (getValue(
|
||||||
"methstatic", addGetter).equals("true")) : false;
|
"methstatic", addGetter).equals("true"));
|
||||||
String returnDesc = isSet("desc", addGetter) ? getValue("desc",
|
String returnDesc = isSet("desc", addGetter) ? getValue("desc",
|
||||||
addGetter) : null;
|
addGetter) : null;
|
||||||
String array = "";
|
String array = "";
|
||||||
@@ -244,8 +250,8 @@ public class XMLHookParser extends HookParser {
|
|||||||
final String fieldName = getValue("field", addSetter);
|
final String fieldName = getValue("field", addSetter);
|
||||||
final String fieldDesc = isSet("descfield", addSetter) ? getValue("descfield", addSetter) : null;
|
final String fieldDesc = isSet("descfield", addSetter) ? getValue("descfield", addSetter) : null;
|
||||||
final String methodName = getValue("methodname", addSetter);
|
final String methodName = getValue("methodname", addSetter);
|
||||||
boolean staticMethod = isSet("methstatic", addSetter) ? (getValue(
|
boolean staticMethod = isSet("methstatic", addSetter) && (getValue(
|
||||||
"methstatic", addSetter).equals("true")) : false;
|
"methstatic", addSetter).equals("true"));
|
||||||
String returnDesc = isSet("desc", addSetter) ? getValue("desc",
|
String returnDesc = isSet("desc", addSetter) ? getValue("desc",
|
||||||
addSetter) : null;
|
addSetter) : null;
|
||||||
String array = "";
|
String array = "";
|
||||||
@@ -320,7 +326,7 @@ public class XMLHookParser extends HookParser {
|
|||||||
String returnDesc = isSet("desc", addInvoker) ? resolveDesc(getValue(
|
String returnDesc = isSet("desc", addInvoker) ? resolveDesc(getValue(
|
||||||
"desc", addInvoker)) : null;
|
"desc", addInvoker)) : null;
|
||||||
|
|
||||||
final boolean isInterface = isSet("interface", addInvoker) ? Boolean.parseBoolean(getValue("interface", addInvoker)) : false;
|
final boolean isInterface = isSet("interface", addInvoker) && Boolean.parseBoolean(getValue("interface", addInvoker));
|
||||||
final String instanceCast = isSet("instancecast", addInvoker) ? getValue("instancecast", addInvoker) : null;
|
final String instanceCast = isSet("instancecast", addInvoker) ? getValue("instancecast", addInvoker) : null;
|
||||||
final String checkCastArgsDesc = isSet("castargs", addInvoker) ? getValue("castargs", addInvoker) : null;
|
final String checkCastArgsDesc = isSet("castargs", addInvoker) ? getValue("castargs", addInvoker) : null;
|
||||||
|
|
||||||
@@ -464,7 +470,7 @@ public class XMLHookParser extends HookParser {
|
|||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
Node node = (Node) nodes.item(0);
|
Node node = nodes.item(0);
|
||||||
return node.getNodeValue();
|
return node.getNodeValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
package org.parabot.core.parsers.randoms;
|
package org.parabot.core.parsers.randoms;
|
||||||
|
|
||||||
|
import org.parabot.api.io.WebUtil;
|
||||||
|
import org.parabot.core.Configuration;
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.Core;
|
||||||
|
import org.parabot.core.Directories;
|
||||||
|
import org.parabot.core.io.NoProgressListener;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import org.parabot.api.io.WebUtil;
|
|
||||||
import org.parabot.api.output.Logger;
|
|
||||||
import org.parabot.core.Configuration;
|
|
||||||
import org.parabot.core.Context;
|
|
||||||
import org.parabot.core.Core;
|
|
||||||
import org.parabot.core.Directories;
|
|
||||||
import org.parabot.core.io.NoProgressListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JKetelaar
|
* @author JKetelaar
|
||||||
*/
|
*/
|
||||||
public class PublicRandoms extends RandomParser {
|
public class PublicRandoms extends RandomParser {
|
||||||
|
|
||||||
private String fileName = ((Configuration.BOT_VERSION.isNightly()) ? "randoms-nightly.jar" : "randoms.jar");
|
private final String fileName = ((Configuration.BOT_VERSION.isNightly()) ? "randoms-nightly.jar" : "randoms.jar");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parse() {
|
public void parse() {
|
||||||
@@ -37,14 +37,14 @@ public class PublicRandoms extends RandomParser {
|
|||||||
download(destination, overrideDownload);
|
download(destination, overrideDownload);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
URL url = destination.toURI().toURL();
|
URL url = destination.toURI().toURL();
|
||||||
URL[] urls = new URL[]{ url };
|
URL[] urls = new URL[]{ url };
|
||||||
String server = Context.getInstance().getServerProviderInfo().getServerName();
|
String server = Context.getInstance().getServerProviderInfo().getServerName();
|
||||||
|
|
||||||
URLClassLoader child = new URLClassLoader(urls, this.getClass().getClassLoader());
|
URLClassLoader child = new URLClassLoader(urls, this.getClass().getClassLoader());
|
||||||
Class<?> classToLoad = Class.forName("org.parabot.randoms.Core", true, child);
|
Class<?> classToLoad = Class.forName("org.parabot.randoms.Core", true, child);
|
||||||
Method method = classToLoad.getDeclaredMethod("init", String.class);
|
Method method = classToLoad.getDeclaredMethod("init", String.class);
|
||||||
Object instance = classToLoad.newInstance();
|
Object instance = classToLoad.newInstance();
|
||||||
Core.verbose(String.format("[%s] %s %s", getClass().getSimpleName(), "Initing core Randoms for", server));
|
Core.verbose(String.format("[%s] %s %s", getClass().getSimpleName(), "Initing core Randoms for", server));
|
||||||
method.invoke(instance, server);
|
method.invoke(instance, server);
|
||||||
Core.verbose("Successfully parsed public random!");
|
Core.verbose("Successfully parsed public random!");
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ public class BDNScripts extends ScriptParser {
|
|||||||
String line;
|
String line;
|
||||||
|
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
JSONObject jsonObject = (JSONObject) parser.parse(line);
|
JSONObject jsonObject = (JSONObject) parser.parse(line);
|
||||||
int bdnId = Integer.parseInt(String.valueOf(jsonObject.get("id")));
|
int bdnId = Integer.parseInt(String.valueOf(jsonObject.get("id")));
|
||||||
String scriptName = String.valueOf(jsonObject.get("name"));
|
String scriptName = String.valueOf(jsonObject.get("name"));
|
||||||
String author = String.valueOf(jsonObject.get("author"));
|
String author = String.valueOf(jsonObject.get("author"));
|
||||||
double version = Double.parseDouble(String.valueOf(jsonObject.get("version")));
|
double version = Double.parseDouble(String.valueOf(jsonObject.get("version")));
|
||||||
String category = String.valueOf(jsonObject.get("category"));
|
String category = String.valueOf(jsonObject.get("category"));
|
||||||
String description = String.valueOf(jsonObject.get("description"));
|
String description = String.valueOf(jsonObject.get("description"));
|
||||||
|
|
||||||
final ScriptDescription desc = new ScriptDescription(scriptName,
|
final ScriptDescription desc = new ScriptDescription(scriptName,
|
||||||
author, category, version, description,
|
author, category, version, description,
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
package org.parabot.core.parsers.servers;
|
package org.parabot.core.parsers.servers;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
import org.parabot.core.Configuration;
|
import org.parabot.core.Configuration;
|
||||||
@@ -19,6 +14,12 @@ import org.parabot.environment.servers.executers.LocalPublicServerExecuter;
|
|||||||
import org.parabot.environment.servers.executers.LocalServerExecuter;
|
import org.parabot.environment.servers.executers.LocalServerExecuter;
|
||||||
import org.parabot.environment.servers.loader.ServerLoader;
|
import org.parabot.environment.servers.loader.ServerLoader;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses local server providers located in the servers directory
|
* Parses local server providers located in the servers directory
|
||||||
*
|
*
|
||||||
@@ -76,24 +77,23 @@ public class LocalServers extends ServerParser {
|
|||||||
for (File file : Directories.listJSONFiles(Directories.getServerPath())) {
|
for (File file : Directories.listJSONFiles(Directories.getServerPath())) {
|
||||||
Core.verbose("[Local server in]: " + file.getName());
|
Core.verbose("[Local server in]: " + file.getName());
|
||||||
try {
|
try {
|
||||||
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(new FileReader(file));
|
JSONObject object = (JSONObject) WebUtil.getJsonParser().parse(new FileReader(file));
|
||||||
String name = (String) object.get("name");
|
String name = (String) object.get("name");
|
||||||
String author = (String) object.get("author");
|
String author = (String) object.get("author");
|
||||||
double version = (Double) object.get("version");
|
double version = (Double) object.get("version");
|
||||||
String clientClass = (String) object.get("client-class");
|
String clientClass = (String) object.get("client-class");
|
||||||
Object bank;
|
Object bank;
|
||||||
int bankTabs = 0;
|
int bankTabs = 0;
|
||||||
if ((bank = object.get("bank")) != null) {
|
if ((bank = object.get("bank")) != null) {
|
||||||
bankTabs = (int) bank;
|
bankTabs = (int) bank;
|
||||||
}
|
}
|
||||||
String uuidStr = (String) object.get("uuid"); // optional
|
String uuidStr = (String) object.get("uuid"); // optional
|
||||||
|
|
||||||
|
|
||||||
JSONObject locations = (JSONObject) object.get("locations");
|
JSONObject locations = (JSONObject) object.get("locations");
|
||||||
String server = (String) locations.get("server");
|
String server = (String) locations.get("server");
|
||||||
String provider = (String) locations.get("provider");
|
String provider = (String) locations.get("provider");
|
||||||
String hooks = (String) locations.get("hooks");
|
String hooks = (String) locations.get("hooks");
|
||||||
String randoms = (String) locations.get("randoms");
|
String randoms = (String) locations.get("randoms");
|
||||||
|
|
||||||
if (randoms == null) {
|
if (randoms == null) {
|
||||||
randoms = Configuration.GET_RANDOMS + (Configuration.BOT_VERSION.isNightly() ? Configuration.NIGHTLY_APPEND : "");
|
randoms = Configuration.GET_RANDOMS + (Configuration.BOT_VERSION.isNightly() ? Configuration.NIGHTLY_APPEND : "");
|
||||||
|
|||||||
@@ -10,10 +10,11 @@ import org.parabot.core.ui.utils.UILog;
|
|||||||
import org.parabot.environment.api.utils.WebUtil;
|
import org.parabot.environment.api.utils.WebUtil;
|
||||||
import org.parabot.environment.servers.executers.PublicServerExecuter;
|
import org.parabot.environment.servers.executers.PublicServerExecuter;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses servers hosted on Parabot
|
* Parses servers hosted on Parabot
|
||||||
*
|
*
|
||||||
@@ -43,9 +44,9 @@ public class PublicServers extends ServerParser {
|
|||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
|
|
||||||
JSONObject jsonObject = (JSONObject) parser.parse(line);
|
JSONObject jsonObject = (JSONObject) parser.parse(line);
|
||||||
String name = String.valueOf(jsonObject.get("name"));
|
String name = String.valueOf(jsonObject.get("name"));
|
||||||
String author = String.valueOf(jsonObject.get("author"));
|
String author = String.valueOf(jsonObject.get("author"));
|
||||||
double version = Double.parseDouble(String.valueOf(jsonObject.get("version")));
|
double version = Double.parseDouble(String.valueOf(jsonObject.get("version")));
|
||||||
|
|
||||||
ServerDescription desc = new ServerDescription(name,
|
ServerDescription desc = new ServerDescription(name,
|
||||||
author, version);
|
author, version);
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import java.util.Arrays;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class RefClass extends RefModifiers {
|
public class RefClass extends RefModifiers {
|
||||||
private Object instance;
|
private final Class<?> clazz;
|
||||||
private Class<?> clazz;
|
private Object instance;
|
||||||
|
|
||||||
public RefClass(Class<?> clazz) {
|
public RefClass(Class<?> clazz) {
|
||||||
this(clazz, null);
|
this(clazz, null);
|
||||||
@@ -251,7 +251,7 @@ public class RefClass extends RefModifiers {
|
|||||||
* @return an array with all the constructors in this class
|
* @return an array with all the constructors in this class
|
||||||
*/
|
*/
|
||||||
public RefConstructor[] getConstructors() {
|
public RefConstructor[] getConstructors() {
|
||||||
Constructor<?>[] constructors = clazz.getDeclaredConstructors();
|
Constructor<?>[] constructors = clazz.getDeclaredConstructors();
|
||||||
RefConstructor[] refConstructors = new RefConstructor[constructors.length];
|
RefConstructor[] refConstructors = new RefConstructor[constructors.length];
|
||||||
for (int i = 0; i < constructors.length; i++) {
|
for (int i = 0; i < constructors.length; i++) {
|
||||||
refConstructors[i] = new RefConstructor(constructors[i]);
|
refConstructors[i] = new RefConstructor(constructors[i]);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.lang.reflect.Constructor;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class RefConstructor extends RefModifiers {
|
public class RefConstructor extends RefModifiers {
|
||||||
private Constructor<?> constructor;
|
private final Constructor<?> constructor;
|
||||||
|
|
||||||
public RefConstructor(Constructor<?> constructor) {
|
public RefConstructor(Constructor<?> constructor) {
|
||||||
super(constructor.getModifiers());
|
super(constructor.getModifiers());
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import java.lang.reflect.Type;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class RefField extends RefModifiers {
|
public class RefField extends RefModifiers {
|
||||||
private Field field;
|
private final Field field;
|
||||||
private Object instance;
|
private final Object instance;
|
||||||
|
|
||||||
public RefField(Field field) {
|
public RefField(Field field) {
|
||||||
this(field, null);
|
this(field, null);
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import java.lang.reflect.Method;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class RefMethod extends RefModifiers {
|
public class RefMethod extends RefModifiers {
|
||||||
private Method method;
|
private final Method method;
|
||||||
private Object instance;
|
private final Object instance;
|
||||||
|
|
||||||
public RefMethod(Method method) {
|
public RefMethod(Method method) {
|
||||||
this(method, null);
|
this(method, null);
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package org.parabot.core.ui;
|
|||||||
import org.parabot.core.ui.components.PaintComponent;
|
import org.parabot.core.ui.components.PaintComponent;
|
||||||
import org.parabot.environment.OperatingSystem;
|
import org.parabot.environment.OperatingSystem;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.Color;
|
||||||
import java.awt.*;
|
import java.awt.Dimension;
|
||||||
|
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Everel
|
* @author Everel
|
||||||
|
|||||||
@@ -13,15 +13,33 @@ import org.parabot.environment.api.utils.StringUtils;
|
|||||||
import org.parabot.environment.randoms.Random;
|
import org.parabot.environment.randoms.Random;
|
||||||
import org.parabot.environment.scripts.Script;
|
import org.parabot.environment.scripts.Script;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import java.awt.AWTException;
|
||||||
import javax.swing.*;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.*;
|
import java.awt.Point;
|
||||||
import java.awt.event.*;
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Robot;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
|
import java.awt.event.ComponentListener;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.awt.event.WindowListener;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JCheckBoxMenuItem;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.WindowConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The bot user interface
|
* The bot user interface
|
||||||
*
|
*
|
||||||
@@ -30,11 +48,11 @@ import java.util.ArrayList;
|
|||||||
public class BotUI extends JFrame implements ActionListener, ComponentListener, WindowListener {
|
public class BotUI extends JFrame implements ActionListener, ComponentListener, WindowListener {
|
||||||
|
|
||||||
private static final long serialVersionUID = -2126184292879805519L;
|
private static final long serialVersionUID = -2126184292879805519L;
|
||||||
private static BotUI instance;
|
private static BotUI instance;
|
||||||
private static JDialog dialog;
|
private static JDialog dialog;
|
||||||
|
|
||||||
private JMenuBar menuBar;
|
private JMenuBar menuBar;
|
||||||
private JMenu features, scripts, file;
|
private JMenu features, scripts, file;
|
||||||
private JMenuItem run, pause, stop, cacheClear, notifications;
|
private JMenuItem run, pause, stop, cacheClear, notifications;
|
||||||
private boolean runScript, pauseScript;
|
private boolean runScript, pauseScript;
|
||||||
|
|
||||||
@@ -73,79 +91,6 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createMenu() {
|
|
||||||
menuBar = new JMenuBar();
|
|
||||||
|
|
||||||
file = new JMenu("File");
|
|
||||||
scripts = new JMenu("Script");
|
|
||||||
features = new JMenu("Features");
|
|
||||||
|
|
||||||
JMenuItem screenshot = new JMenuItem("Create screenshot");
|
|
||||||
JMenuItem proxy = new JMenuItem("Network");
|
|
||||||
JMenuItem randoms = new JMenuItem("Randoms");
|
|
||||||
JMenuItem dialog = new JCheckBoxMenuItem("Disable dialog");
|
|
||||||
JMenuItem logger = new JCheckBoxMenuItem("Logger");
|
|
||||||
|
|
||||||
if (!OperatingSystem.getOS().equals(OperatingSystem.WINDOWS)) {
|
|
||||||
dialog.setSelected(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
JMenuItem explorer = new JMenuItem("Reflection explorer");
|
|
||||||
JMenuItem exit = new JMenuItem("Exit");
|
|
||||||
|
|
||||||
run = new JMenuItem("Run");
|
|
||||||
run.setIcon(new ImageIcon(Images.getResource("/storage/images/run.png")));
|
|
||||||
|
|
||||||
pause = new JMenuItem("Pause");
|
|
||||||
pause.setEnabled(false);
|
|
||||||
pause.setIcon(new ImageIcon(Images.getResource("/storage/images/pause.png")));
|
|
||||||
|
|
||||||
stop = new JMenuItem("Stop");
|
|
||||||
stop.setEnabled(false);
|
|
||||||
stop.setIcon(new ImageIcon(Images.getResource("/storage/images/stop.png")));
|
|
||||||
|
|
||||||
cacheClear = new JMenuItem("Clear cache");
|
|
||||||
cacheClear.setIcon(new ImageIcon(Images.getResource("/storage/images/trash.png")));
|
|
||||||
|
|
||||||
notifications = new JMenuItem("Notifications");
|
|
||||||
notifications.setIcon(new ImageIcon(Images.getResource("/storage/images/bell.png")));
|
|
||||||
|
|
||||||
screenshot.addActionListener(this);
|
|
||||||
proxy.addActionListener(this);
|
|
||||||
randoms.addActionListener(this);
|
|
||||||
dialog.addActionListener(this);
|
|
||||||
logger.addActionListener(this);
|
|
||||||
explorer.addActionListener(this);
|
|
||||||
exit.addActionListener(this);
|
|
||||||
cacheClear.addActionListener(this);
|
|
||||||
notifications.addActionListener(this);
|
|
||||||
|
|
||||||
run.addActionListener(this);
|
|
||||||
pause.addActionListener(this);
|
|
||||||
stop.addActionListener(this);
|
|
||||||
|
|
||||||
file.add(screenshot);
|
|
||||||
file.add(proxy);
|
|
||||||
file.add(randoms);
|
|
||||||
file.add(dialog);
|
|
||||||
file.add(logger);
|
|
||||||
file.add(explorer);
|
|
||||||
file.add(exit);
|
|
||||||
|
|
||||||
scripts.add(run);
|
|
||||||
scripts.add(pause);
|
|
||||||
scripts.add(stop);
|
|
||||||
|
|
||||||
features.add(cacheClear);
|
|
||||||
features.add(notifications);
|
|
||||||
|
|
||||||
menuBar.add(file);
|
|
||||||
menuBar.add(scripts);
|
|
||||||
menuBar.add(features);
|
|
||||||
|
|
||||||
setJMenuBar(menuBar);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
this.performCommand(e.getActionCommand());
|
this.performCommand(e.getActionCommand());
|
||||||
@@ -155,15 +100,15 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
switch (command) {
|
switch (command) {
|
||||||
case "Create screenshot":
|
case "Create screenshot":
|
||||||
try {
|
try {
|
||||||
Robot robot = new Robot();
|
Robot robot = new Robot();
|
||||||
int menuBarHeight = menuBar.getHeight() + file.getHeight();
|
int menuBarHeight = menuBar.getHeight() + file.getHeight();
|
||||||
Rectangle parabotScreen = new Rectangle(
|
Rectangle parabotScreen = new Rectangle(
|
||||||
(int) getLocation().getX(), (int) getLocation().getY() + menuBarHeight,
|
(int) getLocation().getX(), (int) getLocation().getY() + menuBarHeight,
|
||||||
getWidth(), getHeight() - menuBarHeight);
|
getWidth(), getHeight() - menuBarHeight);
|
||||||
BufferedImage image = robot.createScreenCapture(parabotScreen);
|
BufferedImage image = robot.createScreenCapture(parabotScreen);
|
||||||
String randString = StringUtils.randomString(10);
|
String randString = StringUtils.randomString(10);
|
||||||
boolean search = true;
|
boolean search = true;
|
||||||
boolean duplicate = false;
|
boolean duplicate = false;
|
||||||
while (search) {
|
while (search) {
|
||||||
File[] files;
|
File[] files;
|
||||||
if ((files = Directories.getScreenshotDir().listFiles()) != null) {
|
if ((files = Directories.getScreenshotDir().listFiles()) != null) {
|
||||||
@@ -254,10 +199,6 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setDialog(JDialog dialog) {
|
|
||||||
BotUI.dialog = dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentMoved(ComponentEvent e) {
|
public void componentMoved(ComponentEvent e) {
|
||||||
if (dialog == null || !isVisible()) {
|
if (dialog == null || !isVisible()) {
|
||||||
@@ -276,24 +217,6 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scriptRunning() {
|
|
||||||
run.setEnabled(false);
|
|
||||||
pause.setEnabled(true);
|
|
||||||
stop.setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scriptStopped() {
|
|
||||||
run.setEnabled(true);
|
|
||||||
pause.setEnabled(false);
|
|
||||||
stop.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setScriptState(int state) {
|
|
||||||
if (Context.getInstance().getRunningScript() != null) {
|
|
||||||
Context.getInstance().getRunningScript().setState(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentResized(ComponentEvent e) {
|
public void componentResized(ComponentEvent e) {
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
@@ -362,4 +285,99 @@ public class BotUI extends JFrame implements ActionListener, ComponentListener,
|
|||||||
public JMenuItem getNotifications() {
|
public JMenuItem getNotifications() {
|
||||||
return notifications;
|
return notifications;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setDialog(JDialog dialog) {
|
||||||
|
BotUI.dialog = dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createMenu() {
|
||||||
|
menuBar = new JMenuBar();
|
||||||
|
|
||||||
|
file = new JMenu("File");
|
||||||
|
scripts = new JMenu("Script");
|
||||||
|
features = new JMenu("Features");
|
||||||
|
|
||||||
|
JMenuItem screenshot = new JMenuItem("Create screenshot");
|
||||||
|
JMenuItem proxy = new JMenuItem("Network");
|
||||||
|
JMenuItem randoms = new JMenuItem("Randoms");
|
||||||
|
JMenuItem dialog = new JCheckBoxMenuItem("Disable dialog");
|
||||||
|
JMenuItem logger = new JCheckBoxMenuItem("Logger");
|
||||||
|
|
||||||
|
if (!OperatingSystem.getOS().equals(OperatingSystem.WINDOWS)) {
|
||||||
|
dialog.setSelected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
JMenuItem explorer = new JMenuItem("Reflection explorer");
|
||||||
|
JMenuItem exit = new JMenuItem("Exit");
|
||||||
|
|
||||||
|
run = new JMenuItem("Run");
|
||||||
|
run.setIcon(new ImageIcon(Images.getResource("/storage/images/run.png")));
|
||||||
|
|
||||||
|
pause = new JMenuItem("Pause");
|
||||||
|
pause.setEnabled(false);
|
||||||
|
pause.setIcon(new ImageIcon(Images.getResource("/storage/images/pause.png")));
|
||||||
|
|
||||||
|
stop = new JMenuItem("Stop");
|
||||||
|
stop.setEnabled(false);
|
||||||
|
stop.setIcon(new ImageIcon(Images.getResource("/storage/images/stop.png")));
|
||||||
|
|
||||||
|
cacheClear = new JMenuItem("Clear cache");
|
||||||
|
cacheClear.setIcon(new ImageIcon(Images.getResource("/storage/images/trash.png")));
|
||||||
|
|
||||||
|
notifications = new JMenuItem("Notifications");
|
||||||
|
notifications.setIcon(new ImageIcon(Images.getResource("/storage/images/bell.png")));
|
||||||
|
|
||||||
|
screenshot.addActionListener(this);
|
||||||
|
proxy.addActionListener(this);
|
||||||
|
randoms.addActionListener(this);
|
||||||
|
dialog.addActionListener(this);
|
||||||
|
logger.addActionListener(this);
|
||||||
|
explorer.addActionListener(this);
|
||||||
|
exit.addActionListener(this);
|
||||||
|
cacheClear.addActionListener(this);
|
||||||
|
notifications.addActionListener(this);
|
||||||
|
|
||||||
|
run.addActionListener(this);
|
||||||
|
pause.addActionListener(this);
|
||||||
|
stop.addActionListener(this);
|
||||||
|
|
||||||
|
file.add(screenshot);
|
||||||
|
file.add(proxy);
|
||||||
|
file.add(randoms);
|
||||||
|
file.add(dialog);
|
||||||
|
file.add(logger);
|
||||||
|
file.add(explorer);
|
||||||
|
file.add(exit);
|
||||||
|
|
||||||
|
scripts.add(run);
|
||||||
|
scripts.add(pause);
|
||||||
|
scripts.add(stop);
|
||||||
|
|
||||||
|
features.add(cacheClear);
|
||||||
|
features.add(notifications);
|
||||||
|
|
||||||
|
menuBar.add(file);
|
||||||
|
menuBar.add(scripts);
|
||||||
|
menuBar.add(features);
|
||||||
|
|
||||||
|
setJMenuBar(menuBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scriptRunning() {
|
||||||
|
run.setEnabled(false);
|
||||||
|
pause.setEnabled(true);
|
||||||
|
stop.setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scriptStopped() {
|
||||||
|
run.setEnabled(true);
|
||||||
|
pause.setEnabled(false);
|
||||||
|
stop.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setScriptState(int state) {
|
||||||
|
if (Context.getInstance().getRunningScript() != null) {
|
||||||
|
Context.getInstance().getRunningScript().setState(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,31 @@ package org.parabot.core.ui;
|
|||||||
|
|
||||||
import org.parabot.core.ui.components.GamePanel;
|
import org.parabot.core.ui.components.GamePanel;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.DefaultListCellRenderer;
|
||||||
|
import javax.swing.DefaultListModel;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.ListCellRenderer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JKetelaar
|
* @author JKetelaar
|
||||||
*/
|
*/
|
||||||
public class Logger extends JPanel {
|
public class Logger extends JPanel {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static Logger instance;
|
private static Logger instance;
|
||||||
private final DefaultListModel<String> model;
|
private final DefaultListModel<String> model;
|
||||||
private final JList<String> list;
|
private final JList<String> list;
|
||||||
|
|
||||||
private boolean clearable;
|
private boolean clearable;
|
||||||
|
|
||||||
@@ -78,6 +90,14 @@ public class Logger extends JPanel {
|
|||||||
addMessage(message, true);
|
addMessage(message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isClearable() {
|
||||||
|
return clearable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClearable() {
|
||||||
|
this.clearable = true;
|
||||||
|
}
|
||||||
|
|
||||||
protected static void clearLogger() {
|
protected static void clearLogger() {
|
||||||
instance.model.clear();
|
instance.model.clear();
|
||||||
}
|
}
|
||||||
@@ -96,12 +116,4 @@ public class Logger extends JPanel {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isClearable() {
|
|
||||||
return clearable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClearable() {
|
|
||||||
this.clearable = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,11 @@ import org.parabot.core.ui.utils.SwingUtil;
|
|||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
import org.parabot.environment.input.Keyboard;
|
import org.parabot.environment.input.Keyboard;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.*;
|
import java.awt.Desktop;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
@@ -17,6 +20,13 @@ import java.awt.event.KeyEvent;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPasswordField;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Users must login with their parabot account through this LoginUI class
|
* Users must login with their parabot account through this LoginUI class
|
||||||
*
|
*
|
||||||
@@ -24,13 +34,13 @@ import java.net.URI;
|
|||||||
*/
|
*/
|
||||||
public class LoginUI extends JFrame {
|
public class LoginUI extends JFrame {
|
||||||
private static final long serialVersionUID = 2032832552863466297L;
|
private static final long serialVersionUID = 2032832552863466297L;
|
||||||
private static LoginUI instance;
|
private static LoginUI instance;
|
||||||
private static AccountManager manager;
|
private static AccountManager manager;
|
||||||
|
|
||||||
private JTextField txtUsername;
|
private JTextField txtUsername;
|
||||||
private JPasswordField txtPassword;
|
private JPasswordField txtPassword;
|
||||||
private JButton cmdLogin;
|
private JButton cmdLogin;
|
||||||
private JButton cmdRegister;
|
private JButton cmdRegister;
|
||||||
|
|
||||||
public LoginUI(String username, String password) {
|
public LoginUI(String username, String password) {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|||||||
@@ -5,7 +5,26 @@ import org.parabot.core.network.proxy.ProxySocket;
|
|||||||
import org.parabot.core.network.proxy.ProxyType;
|
import org.parabot.core.network.proxy.ProxyType;
|
||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.KeyListener;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPasswordField;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
@@ -13,11 +32,6 @@ import javax.swing.text.AttributeSet;
|
|||||||
import javax.swing.text.BadLocationException;
|
import javax.swing.text.BadLocationException;
|
||||||
import javax.swing.text.Document;
|
import javax.swing.text.Document;
|
||||||
import javax.swing.text.PlainDocument;
|
import javax.swing.text.PlainDocument;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.KeyListener;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
||||||
DocumentListener {
|
DocumentListener {
|
||||||
@@ -27,17 +41,17 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
private static NetworkUI instance;
|
private static NetworkUI instance;
|
||||||
|
|
||||||
private JComboBox<ProxyType> proxyType;
|
private JComboBox<ProxyType> proxyType;
|
||||||
private JTextField proxyHost;
|
private JTextField proxyHost;
|
||||||
private IntTextField proxyPort;
|
private IntTextField proxyPort;
|
||||||
private JButton submitButton;
|
private JButton submitButton;
|
||||||
|
|
||||||
private JList<String>[] macList;
|
private JList<String>[] macList;
|
||||||
private JScrollPane[] macScrollList;
|
private JScrollPane[] macScrollList;
|
||||||
|
|
||||||
private JCheckBox authCheckBox;
|
private JCheckBox authCheckBox;
|
||||||
private JTextField authUsername;
|
private JTextField authUsername;
|
||||||
private JPasswordField authPassword;
|
private JPasswordField authPassword;
|
||||||
private JButton randomize;
|
private JButton randomize;
|
||||||
|
|
||||||
private NetworkUI() {
|
private NetworkUI() {
|
||||||
initGUI();
|
initGUI();
|
||||||
@@ -60,6 +74,110 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
super.setVisible(b);
|
super.setVisible(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
Object source = e.getSource();
|
||||||
|
if (source == proxyPort || source == proxyHost) {
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||||
|
actionPerformed(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyReleased(KeyEvent arg0) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyTyped(KeyEvent arg0) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changedUpdate(DocumentEvent arg0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertUpdate(DocumentEvent arg0) {
|
||||||
|
if (proxyPort.isValid()) {
|
||||||
|
proxyPort.setText("" + proxyPort.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeUpdate(DocumentEvent arg0) {
|
||||||
|
insertUpdate(arg0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
boolean b = false;
|
||||||
|
|
||||||
|
if (arg0.getSource() == proxyType) {
|
||||||
|
Object o = proxyType.getSelectedItem();
|
||||||
|
authCheckBox.setEnabled(o == ProxyType.SOCKS5);
|
||||||
|
proxyHost.setEnabled(o != ProxyType.NONE);
|
||||||
|
proxyPort.setEnabled(o != ProxyType.NONE);
|
||||||
|
b = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b || arg0.getSource() == authCheckBox) {
|
||||||
|
b = authCheckBox.isSelected() && authCheckBox.isEnabled();
|
||||||
|
ProxySocket.auth = b;
|
||||||
|
authUsername.setEnabled(b);
|
||||||
|
authPassword.setEnabled(b);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (proxyType.getSelectedItem() != ProxyType.NONE) {
|
||||||
|
if (proxyPort.getText().equals("")
|
||||||
|
|| proxyHost.getText().equals("")) {
|
||||||
|
UILog.log("Error", "Please supply proxy information!",
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String username = authUsername.getText();
|
||||||
|
char[] password = authPassword.getPassword();
|
||||||
|
|
||||||
|
ProxySocket
|
||||||
|
.setLogin(username, password);
|
||||||
|
|
||||||
|
byte[] mac = new byte[macList.length];
|
||||||
|
for (int i = 0; i < mac.length; i++) {
|
||||||
|
mac[i] = (byte) Short.parseShort(
|
||||||
|
macList[i].getSelectedValue(), 16);
|
||||||
|
}
|
||||||
|
NetworkInterface.setMac(mac);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (ProxySocket.getConnectionCount() > 0) {
|
||||||
|
try {
|
||||||
|
System.out.println("Closing Existing Connections...");
|
||||||
|
ProxySocket.closeConnections();
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ProxyType type = (ProxyType) proxyType.getSelectedItem();
|
||||||
|
String host = proxyHost.getText();
|
||||||
|
int port = proxyPort.getValue();
|
||||||
|
|
||||||
|
ProxySocket.setProxy(type, host, port);
|
||||||
|
UILog.log("Info", "Network settings have been set!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
UILog.log("Error",
|
||||||
|
"Unable to set proxy info!\n\nReason:" + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void initGUI() {
|
private void initGUI() {
|
||||||
proxyType = new JComboBox<ProxyType>(ProxyType.values());
|
proxyType = new JComboBox<ProxyType>(ProxyType.values());
|
||||||
@@ -93,7 +211,7 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
randomize.addActionListener(new ActionListener() {
|
randomize.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
byte[] macAddr = new byte[6];
|
byte[] macAddr = new byte[6];
|
||||||
rand.nextBytes(macAddr);
|
rand.nextBytes(macAddr);
|
||||||
macAddr[0] = (byte) (macAddr[0] & (byte) 254);
|
macAddr[0] = (byte) (macAddr[0] & (byte) 254);
|
||||||
@@ -187,110 +305,6 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyPressed(KeyEvent e) {
|
|
||||||
Object source = e.getSource();
|
|
||||||
if (source == proxyPort || source == proxyHost) {
|
|
||||||
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
|
|
||||||
actionPerformed(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyReleased(KeyEvent arg0) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyTyped(KeyEvent arg0) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void changedUpdate(DocumentEvent arg0) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void insertUpdate(DocumentEvent arg0) {
|
|
||||||
if (proxyPort.isValid()) {
|
|
||||||
proxyPort.setText("" + proxyPort.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeUpdate(DocumentEvent arg0) {
|
|
||||||
insertUpdate(arg0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
|
||||||
boolean b = false;
|
|
||||||
|
|
||||||
if (arg0.getSource() == proxyType) {
|
|
||||||
Object o = proxyType.getSelectedItem();
|
|
||||||
authCheckBox.setEnabled(o == ProxyType.SOCKS5);
|
|
||||||
proxyHost.setEnabled(o != ProxyType.NONE);
|
|
||||||
proxyPort.setEnabled(o != ProxyType.NONE);
|
|
||||||
b = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b || arg0.getSource() == authCheckBox) {
|
|
||||||
b = authCheckBox.isSelected() && authCheckBox.isEnabled();
|
|
||||||
ProxySocket.auth = b;
|
|
||||||
authUsername.setEnabled(b);
|
|
||||||
authPassword.setEnabled(b);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (proxyType.getSelectedItem() != ProxyType.NONE) {
|
|
||||||
if (proxyPort.getText().equals("")
|
|
||||||
|| proxyHost.getText().equals("")) {
|
|
||||||
UILog.log("Error", "Please supply proxy information!",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String username = authUsername.getText();
|
|
||||||
char[] password = authPassword.getPassword();
|
|
||||||
|
|
||||||
ProxySocket
|
|
||||||
.setLogin(username, password);
|
|
||||||
|
|
||||||
byte[] mac = new byte[macList.length];
|
|
||||||
for (int i = 0; i < mac.length; i++) {
|
|
||||||
mac[i] = (byte) Short.parseShort(
|
|
||||||
(String) macList[i].getSelectedValue(), 16);
|
|
||||||
}
|
|
||||||
NetworkInterface.setMac(mac);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (ProxySocket.getConnectionCount() > 0) {
|
|
||||||
try {
|
|
||||||
System.out.println("Closing Existing Connections...");
|
|
||||||
ProxySocket.closeConnections();
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ProxyType type = (ProxyType) proxyType.getSelectedItem();
|
|
||||||
String host = proxyHost.getText();
|
|
||||||
int port = proxyPort.getValue();
|
|
||||||
|
|
||||||
ProxySocket.setProxy(type, host, port);
|
|
||||||
UILog.log("Info", "Network settings have been set!");
|
|
||||||
} catch (Exception e) {
|
|
||||||
UILog.log("Error",
|
|
||||||
"Unable to set proxy info!\n\nReason:" + e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private JList<String> createMacList() {
|
private JList<String> createMacList() {
|
||||||
String[] hexStrings = new String[256];
|
String[] hexStrings = new String[256];
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
@@ -312,10 +326,6 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
super("" + defval, size);
|
super("" + defval, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Document createDefaultModel() {
|
|
||||||
return new IntTextDocument();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
try {
|
try {
|
||||||
int i = Integer.parseInt(getText());
|
int i = Integer.parseInt(getText());
|
||||||
@@ -333,6 +343,10 @@ public class NetworkUI extends JFrame implements KeyListener, ActionListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Document createDefaultModel() {
|
||||||
|
return new IntTextDocument();
|
||||||
|
}
|
||||||
|
|
||||||
class IntTextDocument extends PlainDocument {
|
class IntTextDocument extends PlainDocument {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -4,11 +4,16 @@ import org.parabot.core.Context;
|
|||||||
import org.parabot.core.Core;
|
import org.parabot.core.Core;
|
||||||
import org.parabot.environment.randoms.Random;
|
import org.parabot.environment.randoms.Random;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.WindowConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JKetelaar
|
* @author JKetelaar
|
||||||
*/
|
*/
|
||||||
@@ -16,7 +21,7 @@ public class RandomUI implements ActionListener {
|
|||||||
|
|
||||||
private static RandomUI instance;
|
private static RandomUI instance;
|
||||||
|
|
||||||
private JFrame frame;
|
private JFrame frame;
|
||||||
private ArrayList<JCheckBox> checkBoxes;
|
private ArrayList<JCheckBox> checkBoxes;
|
||||||
|
|
||||||
public static RandomUI getInstance() {
|
public static RandomUI getInstance() {
|
||||||
|
|||||||
@@ -7,18 +7,27 @@ import org.parabot.core.reflect.RefClass;
|
|||||||
import org.parabot.core.reflect.RefField;
|
import org.parabot.core.reflect.RefField;
|
||||||
import org.parabot.environment.api.utils.StringUtils;
|
import org.parabot.environment.api.utils.StringUtils;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JEditorPane;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JTree;
|
||||||
import javax.swing.event.TreeSelectionEvent;
|
import javax.swing.event.TreeSelectionEvent;
|
||||||
import javax.swing.event.TreeSelectionListener;
|
import javax.swing.event.TreeSelectionListener;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Reflection explorer
|
* A Reflection explorer
|
||||||
@@ -27,16 +36,16 @@ import java.util.HashMap;
|
|||||||
*/
|
*/
|
||||||
public class ReflectUI extends JFrame {
|
public class ReflectUI extends JFrame {
|
||||||
private static final long serialVersionUID = 98565034137367257L;
|
private static final long serialVersionUID = 98565034137367257L;
|
||||||
private JTree tree;
|
private final JTree tree;
|
||||||
private DefaultMutableTreeNode root;
|
private final DefaultMutableTreeNode root;
|
||||||
private DefaultTreeModel model;
|
private final DefaultTreeModel model;
|
||||||
private JEditorPane basicInfoPane;
|
private final JEditorPane basicInfoPane;
|
||||||
private JEditorPane selectionInfoPane;
|
private final JEditorPane selectionInfoPane;
|
||||||
|
|
||||||
private Object instance;
|
private final Object instance;
|
||||||
|
|
||||||
private HashMap<DefaultMutableTreeNode, RefClass> classes;
|
private final HashMap<DefaultMutableTreeNode, RefClass> classes;
|
||||||
private HashMap<DefaultMutableTreeNode, RefField> fields;
|
private final HashMap<DefaultMutableTreeNode, RefField> fields;
|
||||||
|
|
||||||
public ReflectUI() {
|
public ReflectUI() {
|
||||||
this.root = new DefaultMutableTreeNode("Classes");
|
this.root = new DefaultMutableTreeNode("Classes");
|
||||||
@@ -267,7 +276,7 @@ public class ReflectUI extends JFrame {
|
|||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("<h1>").append(refClass.getClassName()).append("</h1><br/>");
|
builder.append("<h1>").append(refClass.getClassName()).append("</h1><br/>");
|
||||||
if (refClass.getClassName().contains(".")) {
|
if (refClass.getClassName().contains(".")) {
|
||||||
builder.append("<b>Package: </b>").append(refClass.getClassName().substring(0, refClass.getClassName().lastIndexOf("."))).append("<br/>");
|
builder.append("<b>Package: </b>").append(refClass.getClassName(), 0, refClass.getClassName().lastIndexOf(".")).append("<br/>");
|
||||||
}
|
}
|
||||||
builder.append("<b>Abstract: </b>").append(refClass.isAbstract() ? "yes" : "no").append("<br/>");
|
builder.append("<b>Abstract: </b>").append(refClass.isAbstract() ? "yes" : "no").append("<br/>");
|
||||||
builder.append("<b>Interface: </b>").append(refClass.isInterface() ? "yes" : "no").append("<br/>");
|
builder.append("<b>Interface: </b>").append(refClass.isInterface() ? "yes" : "no").append("<br/>");
|
||||||
|
|||||||
@@ -5,25 +5,35 @@ import org.parabot.core.Context;
|
|||||||
import org.parabot.core.Directories;
|
import org.parabot.core.Directories;
|
||||||
import org.parabot.core.desc.ScriptDescription;
|
import org.parabot.core.desc.ScriptDescription;
|
||||||
import org.parabot.core.parsers.scripts.ScriptParser;
|
import org.parabot.core.parsers.scripts.ScriptParser;
|
||||||
import org.parabot.environment.api.utils.WebUtil;
|
|
||||||
import org.parabot.environment.scripts.Category;
|
import org.parabot.environment.scripts.Category;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Desktop;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JEditorPane;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTree;
|
||||||
import javax.swing.event.TreeSelectionEvent;
|
import javax.swing.event.TreeSelectionEvent;
|
||||||
import javax.swing.event.TreeSelectionListener;
|
import javax.swing.event.TreeSelectionListener;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
import javax.swing.tree.TreeCellRenderer;
|
import javax.swing.tree.TreeCellRenderer;
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Script Selector GUI, shows all scripts
|
* Script Selector GUI, shows all scripts
|
||||||
@@ -35,12 +45,12 @@ public final class ScriptSelector extends JFrame {
|
|||||||
public static ScriptParser parser;
|
public static ScriptParser parser;
|
||||||
private final int WIDTH;
|
private final int WIDTH;
|
||||||
private final int HEIGHT;
|
private final int HEIGHT;
|
||||||
private HashMap<String, DefaultMutableTreeNode> categories;
|
private final HashMap<String, DefaultMutableTreeNode> categories;
|
||||||
private HashMap<String, ScriptDescription> format;
|
private final HashMap<String, ScriptDescription> format;
|
||||||
private DefaultMutableTreeNode root;
|
private final DefaultMutableTreeNode root;
|
||||||
private DefaultTreeModel model;
|
private final DefaultTreeModel model;
|
||||||
private Font fontCategory = new Font("Arial", Font.BOLD, 12);
|
private final Font fontCategory = new Font("Arial", Font.BOLD, 12);
|
||||||
private Font fontScript = new Font("Arial", Font.PLAIN, 12);
|
private final Font fontScript = new Font("Arial", Font.PLAIN, 12);
|
||||||
private JTree tree;
|
private JTree tree;
|
||||||
private JEditorPane scriptInfo;
|
private JEditorPane scriptInfo;
|
||||||
|
|
||||||
@@ -212,7 +222,7 @@ public final class ScriptSelector extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ScriptTreeCellRenderer implements TreeCellRenderer {
|
private class ScriptTreeCellRenderer implements TreeCellRenderer {
|
||||||
private JLabel label;
|
private final JLabel label;
|
||||||
|
|
||||||
ScriptTreeCellRenderer() {
|
ScriptTreeCellRenderer() {
|
||||||
label = new JLabel();
|
label = new JLabel();
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ import org.parabot.core.parsers.servers.ServerParser;
|
|||||||
import org.parabot.core.ui.components.ServerComponent;
|
import org.parabot.core.ui.components.ServerComponent;
|
||||||
import org.parabot.environment.Environment;
|
import org.parabot.environment.Environment;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.*;
|
import java.awt.Dimension;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a list of every supported server which can be started
|
* Shows a list of every supported server which can be started
|
||||||
*
|
*
|
||||||
@@ -69,6 +72,22 @@ public class ServerSelector extends JPanel {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches array of server widgets
|
||||||
|
*
|
||||||
|
* @return widgets array
|
||||||
|
*/
|
||||||
|
public Queue<ServerComponent> getServers() {
|
||||||
|
final Queue<ServerComponent> widgets = new LinkedList<>();
|
||||||
|
ServerDescription[] servers = ServerParser.getDescriptions();
|
||||||
|
if (servers != null) {
|
||||||
|
for (ServerDescription desc : servers) {
|
||||||
|
widgets.add(new ServerComponent(desc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return widgets;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called when -server argument is given, or -uuid arg is given.
|
* This method is called when -server argument is given, or -uuid arg is given.
|
||||||
*
|
*
|
||||||
@@ -80,7 +99,7 @@ public class ServerSelector extends JPanel {
|
|||||||
}
|
}
|
||||||
if (Core.getQuickLaunchByUuid() > -1) { // match the pre-requested server config uuid to quick-launch
|
if (Core.getQuickLaunchByUuid() > -1) { // match the pre-requested server config uuid to quick-launch
|
||||||
for (ServerComponent widget : widgets) {
|
for (ServerComponent widget : widgets) {
|
||||||
if (widget.desc.uuid == Core.getQuickLaunchByUuid()) {
|
if (widget.desc.uuid == Core.getQuickLaunchByUuid()) {
|
||||||
Environment.load(widget.desc);
|
Environment.load(widget.desc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -101,20 +120,4 @@ public class ServerSelector extends JPanel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches array of server widgets
|
|
||||||
*
|
|
||||||
* @return widgets array
|
|
||||||
*/
|
|
||||||
public Queue<ServerComponent> getServers() {
|
|
||||||
final Queue<ServerComponent> widgets = new LinkedList<>();
|
|
||||||
ServerDescription[] servers = ServerParser.getDescriptions();
|
|
||||||
if (servers != null) {
|
|
||||||
for (ServerDescription desc : servers) {
|
|
||||||
widgets.add(new ServerComponent(desc));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return widgets;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ package org.parabot.core.ui.components;
|
|||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
|
||||||
|
import javax.swing.GroupLayout;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main panel where applets are added.
|
* Main panel where applets are added.
|
||||||
|
|||||||
@@ -4,10 +4,14 @@ import org.parabot.core.Context;
|
|||||||
import org.parabot.environment.api.interfaces.Paintable;
|
import org.parabot.environment.api.interfaces.Paintable;
|
||||||
import org.parabot.environment.api.utils.Time;
|
import org.parabot.environment.api.utils.Time;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.AlphaComposite;
|
||||||
import java.awt.*;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The panel that is painted on
|
* The panel that is painted on
|
||||||
*
|
*
|
||||||
@@ -18,9 +22,9 @@ public class PaintComponent extends JComponent implements Runnable {
|
|||||||
private static PaintComponent instance;
|
private static PaintComponent instance;
|
||||||
|
|
||||||
private BufferedImage buffer;
|
private BufferedImage buffer;
|
||||||
private Graphics2D g2;
|
private Graphics2D g2;
|
||||||
private Dimension dimensions;
|
private Dimension dimensions;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
private PaintComponent(Dimension dimensions) {
|
private PaintComponent(Dimension dimensions) {
|
||||||
this.dimensions = dimensions;
|
this.dimensions = dimensions;
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package org.parabot.core.ui.components;
|
package org.parabot.core.ui.components;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9,14 +13,14 @@ import java.awt.geom.Rectangle2D;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class ProgressBar {
|
public class ProgressBar {
|
||||||
private double value;
|
private final int width;
|
||||||
private int width;
|
private final int height;
|
||||||
private int height;
|
private final Color backColor;
|
||||||
private double locX;
|
private double value;
|
||||||
private Color progColor;
|
private double locX;
|
||||||
private Color backColor;
|
private Color progColor;
|
||||||
private FontMetrics fontMetrics;
|
private FontMetrics fontMetrics;
|
||||||
private String text;
|
private String text;
|
||||||
|
|
||||||
public ProgressBar(int width, int height) {
|
public ProgressBar(int width, int height) {
|
||||||
this.progColor = new Color(255, 0, 0);
|
this.progColor = new Color(255, 0, 0);
|
||||||
@@ -53,9 +57,9 @@ public class ProgressBar {
|
|||||||
100 + (2 * val), 0);
|
100 + (2 * val), 0);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
int r = (int) (((double) (225 - 218) * (double) val) / ((double) 100.D));
|
int r = (int) (((double) (225 - 218) * (double) val) / 100.D);
|
||||||
int g = (int) (((double) (253 - 165) * (double) val) / ((double) 100.D));
|
int g = (int) (((double) (253 - 165) * (double) val) / 100.D);
|
||||||
int b = (int) (((double) (145 - 32) * (double) val) / ((double) 100.D));
|
int b = (int) (((double) (145 - 32) * (double) val) / 100.D);
|
||||||
this.progColor = new Color(255 - r, 253 - g, 145 - b);
|
this.progColor = new Color(255 - r, 253 - g, 145 - b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,8 +78,8 @@ public class ProgressBar {
|
|||||||
g2.setColor(this.progColor);
|
g2.setColor(this.progColor);
|
||||||
g2.fill(new Rectangle2D.Double(x, y, locX, height));
|
g2.fill(new Rectangle2D.Double(x, y, locX, height));
|
||||||
|
|
||||||
int value = (int) getValue();
|
int value = (int) getValue();
|
||||||
String percent = Integer.toString(value) + "% " + text;
|
String percent = value + "% " + text;
|
||||||
|
|
||||||
int strX = (x + (width / 2)) - (fontMetrics.stringWidth(percent) / 2);
|
int strX = (x + (width / 2)) - (fontMetrics.stringWidth(percent) / 2);
|
||||||
g2.setColor(Color.white);
|
g2.setColor(Color.white);
|
||||||
|
|||||||
@@ -4,12 +4,18 @@ import org.parabot.core.desc.ServerDescription;
|
|||||||
import org.parabot.core.ui.fonts.Fonts;
|
import org.parabot.core.ui.fonts.Fonts;
|
||||||
import org.parabot.environment.Environment;
|
import org.parabot.environment.Environment;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.Color;
|
||||||
import java.awt.*;
|
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.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A neat looking server component
|
* A neat looking server component
|
||||||
*
|
*
|
||||||
@@ -18,10 +24,9 @@ import java.awt.event.MouseMotionListener;
|
|||||||
public class ServerComponent extends JPanel implements MouseListener,
|
public class ServerComponent extends JPanel implements MouseListener,
|
||||||
MouseMotionListener {
|
MouseMotionListener {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
private final String name;
|
||||||
public ServerDescription desc;
|
public ServerDescription desc;
|
||||||
private String name;
|
private boolean hovered;
|
||||||
private boolean hovered;
|
|
||||||
|
|
||||||
public ServerComponent(final ServerDescription desc) {
|
public ServerComponent(final ServerDescription desc) {
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
@@ -58,14 +63,14 @@ public class ServerComponent extends JPanel implements MouseListener,
|
|||||||
Font title = Fonts.getResource("leelawadee.ttf", 16);
|
Font title = Fonts.getResource("leelawadee.ttf", 16);
|
||||||
g.setFont(title);
|
g.setFont(title);
|
||||||
String serverName = desc.getServerName();
|
String serverName = desc.getServerName();
|
||||||
int sw = g.getFontMetrics().stringWidth(serverName);
|
int sw = g.getFontMetrics().stringWidth(serverName);
|
||||||
g.drawString(serverName, (w / 2) - (sw / 2), 30);
|
g.drawString(serverName, (w / 2) - (sw / 2), 30);
|
||||||
|
|
||||||
Font normal = Fonts.getResource("leelawadee.ttf");
|
Font normal = Fonts.getResource("leelawadee.ttf");
|
||||||
g.setFont(normal);
|
g.setFont(normal);
|
||||||
FontMetrics fm = g.getFontMetrics();
|
FontMetrics fm = g.getFontMetrics();
|
||||||
String author = "Author: " + desc.getAuthor();
|
String author = "Author: " + desc.getAuthor();
|
||||||
String revision = "Revision: " + desc.getRevision();
|
String revision = "Revision: " + desc.getRevision();
|
||||||
|
|
||||||
g.drawString(author, (w / 2) - (fm.stringWidth(author) / 2), 55);
|
g.drawString(author, (w / 2) - (fm.stringWidth(author) / 2), 55);
|
||||||
g.drawString(revision, (w / 2) - (fm.stringWidth(revision) / 2), 70);
|
g.drawString(revision, (w / 2) - (fm.stringWidth(revision) / 2), 70);
|
||||||
|
|||||||
@@ -10,24 +10,42 @@ import org.parabot.core.ui.fonts.Fonts;
|
|||||||
import org.parabot.core.ui.images.Images;
|
import org.parabot.core.ui.images.Images;
|
||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.BasicStroke;
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.geom.Line2D;
|
import java.awt.geom.Line2D;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.RescaleOp;
|
import java.awt.image.RescaleOp;
|
||||||
|
|
||||||
|
import javax.swing.Box;
|
||||||
|
import javax.swing.BoxLayout;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPasswordField;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An informative JPanel which tells the user what bot is doing
|
* An informative JPanel which tells the user what bot is doing
|
||||||
*
|
*
|
||||||
* @author Everel, EmmaStone
|
* @author Everel, EmmaStone
|
||||||
*/
|
*/
|
||||||
public class VerboseLoader extends JPanel implements ProgressListener {
|
public class VerboseLoader extends JPanel implements ProgressListener {
|
||||||
public static final int STATE_LOADING = 1;
|
public static final int STATE_LOADING = 1;
|
||||||
private static final long serialVersionUID = 7412412644921803896L;
|
private static final long serialVersionUID = 7412412644921803896L;
|
||||||
private static final int STATE_AUTHENTICATION = 0;
|
private static final int STATE_AUTHENTICATION = 0;
|
||||||
private static final int STATE_SERVER_SELECT = 2;
|
private static final int STATE_SERVER_SELECT = 2;
|
||||||
private static VerboseLoader current;
|
private static VerboseLoader current;
|
||||||
private static String state = "Initializing loader...";
|
private static String state = "Initializing loader...";
|
||||||
private static AccountManager manager;
|
private static AccountManager manager;
|
||||||
@@ -39,11 +57,13 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
private final BufferedImage background;
|
||||||
|
private final BufferedImage banner;
|
||||||
|
private final BufferedImage loginBox;
|
||||||
|
private final ProgressBar progressBar;
|
||||||
private int currentState;
|
private int currentState;
|
||||||
private FontMetrics fontMetrics;
|
private FontMetrics fontMetrics;
|
||||||
private BufferedImage background, banner, loginBox;
|
private JPanel loginPanel;
|
||||||
private ProgressBar progressBar;
|
|
||||||
private JPanel loginPanel;
|
|
||||||
|
|
||||||
private VerboseLoader(String username, String password) {
|
private VerboseLoader(String username, String password) {
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
@@ -102,9 +122,9 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addServerPanel() {
|
public void addServerPanel() {
|
||||||
JPanel servers = ServerSelector.getInstance();
|
JPanel servers = ServerSelector.getInstance();
|
||||||
GridBagLayout bagLayout = (GridBagLayout) getLayout();
|
GridBagLayout bagLayout = (GridBagLayout) getLayout();
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
|
|
||||||
c.weightx = 1;
|
c.weightx = 1;
|
||||||
c.weighty = 1;
|
c.weighty = 1;
|
||||||
@@ -218,9 +238,9 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
|||||||
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||||
|
|
||||||
g.drawImage(background, 0, 0, null);
|
g.drawImage(background, 0, 0, null);
|
||||||
float[] scales = { 1f, 1f, 1f, 0.9f };
|
float[] scales = { 1f, 1f, 1f, 0.9f };
|
||||||
float[] offsets = new float[4];
|
float[] offsets = new float[4];
|
||||||
RescaleOp rop = new RescaleOp(scales, offsets, null);
|
RescaleOp rop = new RescaleOp(scales, offsets, null);
|
||||||
g.drawImage(banner, rop, 0, 0);
|
g.drawImage(banner, rop, 0, 0);
|
||||||
|
|
||||||
g.setStroke(new BasicStroke(5));
|
g.setStroke(new BasicStroke(5));
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import java.awt.event.WindowAdapter;
|
|||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A JavaFX Panel embedded into a Swing JFrame - handles notification settings
|
* A JavaFX Panel embedded into a Swing JFrame - handles notification settings
|
||||||
|
|||||||
+5
-4
@@ -1,15 +1,16 @@
|
|||||||
package org.parabot.core.ui.components.notifications;
|
package org.parabot.core.ui.components.notifications;
|
||||||
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.Initializable;
|
|
||||||
import javafx.scene.control.ListView;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
import org.parabot.api.notifications.NotificationManager;
|
import org.parabot.api.notifications.NotificationManager;
|
||||||
import org.parabot.api.notifications.types.NotificationType;
|
import org.parabot.api.notifications.types.NotificationType;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.control.ListView;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JKetelaar
|
* @author JKetelaar
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.control.CheckBox?>
|
||||||
<BorderPane xmlns:fx="http://javafx.com/fxml/1" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="500.0" minWidth="500.0"
|
<?import javafx.scene.control.ComboBox?>
|
||||||
|
<?import javafx.scene.control.ContextMenu?>
|
||||||
|
<?import javafx.scene.control.Menu?>
|
||||||
|
<?import javafx.scene.control.MenuBar?>
|
||||||
|
<?import javafx.scene.control.MenuItem?>
|
||||||
|
<?import javafx.scene.control.Separator?>
|
||||||
|
<?import javafx.scene.control.Tab?>
|
||||||
|
<?import javafx.scene.control.TableColumn?>
|
||||||
|
<?import javafx.scene.control.TableView?>
|
||||||
|
<?import javafx.scene.control.TabPane?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.control.ToolBar?>
|
||||||
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
<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">
|
prefHeight="503.0" prefWidth="735.0" xmlns="http://javafx.com/javafx/8">
|
||||||
<top>
|
<top>
|
||||||
<MenuBar BorderPane.alignment="CENTER">
|
<MenuBar BorderPane.alignment="CENTER">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.parabot.core.ui.fonts;
|
package org.parabot.core.ui.fonts;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Font;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.parabot.core.ui.fonts;
|
package org.parabot.core.ui.fonts;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Font;
|
||||||
|
import java.awt.FontFormatException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8,8 +9,8 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class ParabotFont {
|
public class ParabotFont {
|
||||||
|
|
||||||
private String location;
|
private final String location;
|
||||||
private Font font;
|
private Font font;
|
||||||
|
|
||||||
public ParabotFont(String location, float size) {
|
public ParabotFont(String location, float size) {
|
||||||
if (!location.toLowerCase().startsWith("/storage/fonts/")) {
|
if (!location.toLowerCase().startsWith("/storage/fonts/")) {
|
||||||
@@ -24,10 +25,6 @@ public class ParabotFont {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Font createFont(float size) throws IOException, FontFormatException {
|
|
||||||
return Font.createFont(Font.TRUETYPE_FONT, Fonts.class.getResourceAsStream(this.location)).deriveFont(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getSize() {
|
public float getSize() {
|
||||||
return font.getSize();
|
return font.getSize();
|
||||||
}
|
}
|
||||||
@@ -45,11 +42,13 @@ public class ParabotFont {
|
|||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
if (obj instanceof ParabotFont) {
|
if (obj instanceof ParabotFont) {
|
||||||
ParabotFont otherFont = (ParabotFont) obj;
|
ParabotFont otherFont = (ParabotFont) obj;
|
||||||
if (otherFont.getSize() == this.getSize()) {
|
return otherFont.getSize() == this.getSize();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Font createFont(float size) throws IOException, FontFormatException {
|
||||||
|
return Font.createFont(Font.TRUETYPE_FONT, Fonts.class.getResourceAsStream(this.location)).deriveFont(size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,6 @@ public class PBKeyListener implements KeyListener {
|
|||||||
this.fillBindings();
|
this.fillBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillBindings() {
|
|
||||||
this.bindings.add(new ActionEventBinding(KeyEvent.VK_R, "Run"));
|
|
||||||
this.bindings.add(new ActionEventBinding(KeyEvent.VK_R, "Stop"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Binding> getBindings() {
|
public List<Binding> getBindings() {
|
||||||
return bindings;
|
return bindings;
|
||||||
}
|
}
|
||||||
@@ -63,4 +58,9 @@ public class PBKeyListener implements KeyListener {
|
|||||||
public void keyReleased(KeyEvent e) {
|
public void keyReleased(KeyEvent e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fillBindings() {
|
||||||
|
this.bindings.add(new ActionEventBinding(KeyEvent.VK_R, "Run"));
|
||||||
|
this.bindings.add(new ActionEventBinding(KeyEvent.VK_R, "Stop"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.parabot.core.ui.BotUI;
|
|||||||
*/
|
*/
|
||||||
public class ActionEventBinding extends Binding {
|
public class ActionEventBinding extends Binding {
|
||||||
|
|
||||||
private String actionString;
|
private final String actionString;
|
||||||
|
|
||||||
public ActionEventBinding(int key, String actionString) {
|
public ActionEventBinding(int key, String actionString) {
|
||||||
super(key);
|
super(key);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.parabot.core.ui.utils;
|
package org.parabot.core.ui.utils;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log messages to the log user interface which is attached to the bot user interface
|
* Log messages to the log user interface which is attached to the bot user interface
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.util.LinkedList;
|
|||||||
*/
|
*/
|
||||||
public class Environment extends org.parabot.api.io.libraries.Environment {
|
public class Environment extends org.parabot.api.io.libraries.Environment {
|
||||||
|
|
||||||
private static LinkedList<Library> libs = new LinkedList<>();
|
private static final LinkedList<Library> libs = new LinkedList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
libs.add(new JavaFX());
|
libs.add(new JavaFX());
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package org.parabot.environment.api.interfaces;
|
package org.parabot.environment.api.interfaces;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Graphics;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Everel
|
* @author Everel
|
||||||
@@ -10,6 +10,6 @@ public interface Paintable {
|
|||||||
/**
|
/**
|
||||||
* @param g
|
* @param g
|
||||||
*/
|
*/
|
||||||
public void paint(Graphics g);
|
void paint(Graphics g);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
package org.parabot.environment.api.utils;
|
package org.parabot.environment.api.utils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
@@ -16,8 +21,8 @@ public class FileUtil {
|
|||||||
try {
|
try {
|
||||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
FileInputStream fis = new FileInputStream(file);
|
FileInputStream fis = new FileInputStream(file);
|
||||||
byte[] dataBytes = new byte[1024];
|
byte[] dataBytes = new byte[1024];
|
||||||
|
|
||||||
int nread;
|
int nread;
|
||||||
|
|
||||||
@@ -27,7 +32,7 @@ public class FileUtil {
|
|||||||
|
|
||||||
byte[] mdbytes = md.digest();
|
byte[] mdbytes = md.digest();
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder("");
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < mdbytes.length; i++) {
|
for (int i = 0; i < mdbytes.length; i++) {
|
||||||
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
|
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
|
||||||
}
|
}
|
||||||
@@ -47,8 +52,8 @@ public class FileUtil {
|
|||||||
try {
|
try {
|
||||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
FileInputStream fis = new FileInputStream(file);
|
FileInputStream fis = new FileInputStream(file);
|
||||||
byte[] dataBytes = new byte[1024];
|
byte[] dataBytes = new byte[1024];
|
||||||
|
|
||||||
int nread;
|
int nread;
|
||||||
|
|
||||||
@@ -74,7 +79,7 @@ public class FileUtil {
|
|||||||
if (!destFile.exists()) {
|
if (!destFile.exists()) {
|
||||||
destFile.createNewFile();
|
destFile.createNewFile();
|
||||||
}
|
}
|
||||||
FileChannel source = null;
|
FileChannel source = null;
|
||||||
FileChannel destination = null;
|
FileChannel destination = null;
|
||||||
source = new FileInputStream(sourceFile).getChannel();
|
source = new FileInputStream(sourceFile).getChannel();
|
||||||
destination = new FileOutputStream(destFile).getChannel();
|
destination = new FileOutputStream(destFile).getChannel();
|
||||||
@@ -91,7 +96,9 @@ public class FileUtil {
|
|||||||
* Reads the contents of a text file
|
* Reads the contents of a text file
|
||||||
*
|
*
|
||||||
* @param file file to get contents from
|
* @param file file to get contents from
|
||||||
|
*
|
||||||
* @return file contents
|
* @return file contents
|
||||||
|
*
|
||||||
* @throws IOException when anything goes wrong
|
* @throws IOException when anything goes wrong
|
||||||
*/
|
*/
|
||||||
public static String getFileContents(File file) throws IOException {
|
public static String getFileContents(File file) throws IOException {
|
||||||
@@ -101,8 +108,9 @@ public class FileUtil {
|
|||||||
/**
|
/**
|
||||||
* Writes a string to a file overwriting the existing contents if present
|
* Writes a string to a file overwriting the existing contents if present
|
||||||
*
|
*
|
||||||
* @param file file to write to
|
* @param file file to write to
|
||||||
* @param contents contents to write to given file
|
* @param contents contents to write to given file
|
||||||
|
*
|
||||||
* @throws IOException when anything goes wrong
|
* @throws IOException when anything goes wrong
|
||||||
*/
|
*/
|
||||||
public static void writeFileContents(File file, String contents) throws IOException {
|
public static void writeFileContents(File file, String contents) throws IOException {
|
||||||
|
|||||||
@@ -15,5 +15,5 @@ public interface Filter<F> {
|
|||||||
*
|
*
|
||||||
* @return <b>true</b> to include this object, otherwise <b>false</b> to exclude.
|
* @return <b>true</b> to include this object, otherwise <b>false</b> to exclude.
|
||||||
*/
|
*/
|
||||||
public boolean accept(F f);
|
boolean accept(F f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class JavaUtil {
|
|||||||
|
|
||||||
static double getVersion() {
|
static double getVersion() {
|
||||||
String version = System.getProperty("java.version");
|
String version = System.getProperty("java.version");
|
||||||
int pos = version.indexOf('.');
|
int pos = version.indexOf('.');
|
||||||
pos = version.indexOf('.', pos + 1);
|
pos = version.indexOf('.', pos + 1);
|
||||||
return Double.parseDouble(version.substring(0, pos));
|
return Double.parseDouble(version.substring(0, pos));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ public class Multipliers {
|
|||||||
* @return the correct setter value
|
* @return the correct setter value
|
||||||
*/
|
*/
|
||||||
public static int getIntSetter(int multiplier, int set) {
|
public static int getIntSetter(int multiplier, int set) {
|
||||||
int bits = 32;
|
int bits = 32;
|
||||||
BigInteger quotient = new BigInteger(Integer.toString(multiplier));
|
BigInteger quotient = new BigInteger(Integer.toString(multiplier));
|
||||||
BigInteger shift = BigInteger.ONE.shiftLeft(bits);
|
BigInteger shift = BigInteger.ONE.shiftLeft(bits);
|
||||||
int value = quotient.modInverse(shift).intValue();
|
int value = quotient.modInverse(shift).intValue();
|
||||||
return value * set;
|
return value * set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,10 +30,10 @@ public class Multipliers {
|
|||||||
* @return the correct setter value
|
* @return the correct setter value
|
||||||
*/
|
*/
|
||||||
public static long getLongSetter(long multiplier, long set) {
|
public static long getLongSetter(long multiplier, long set) {
|
||||||
int bits = 64;
|
int bits = 64;
|
||||||
BigInteger quotient = new BigInteger(Long.toString(multiplier));
|
BigInteger quotient = new BigInteger(Long.toString(multiplier));
|
||||||
BigInteger shift = BigInteger.ONE.shiftLeft(bits);
|
BigInteger shift = BigInteger.ONE.shiftLeft(bits);
|
||||||
long value = quotient.modInverse(shift).longValue();
|
long value = quotient.modInverse(shift).longValue();
|
||||||
return value * set;
|
return value * set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import java.util.HashMap;
|
|||||||
* @author AlexanderBielen
|
* @author AlexanderBielen
|
||||||
*/
|
*/
|
||||||
public class PBLocalPreferences {
|
public class PBLocalPreferences {
|
||||||
private static JSONParser parser = new JSONParser();
|
private static final JSONParser parser = new JSONParser();
|
||||||
private File settingsFile;
|
private final File settingsFile;
|
||||||
|
|
||||||
public PBLocalPreferences(String fileName) {
|
public PBLocalPreferences(String fileName) {
|
||||||
settingsFile = new File(Directories.getSettingsPath() + "/" + secureFileName(fileName));
|
settingsFile = new File(Directories.getSettingsPath() + "/" + secureFileName(fileName));
|
||||||
@@ -29,7 +29,7 @@ public class PBLocalPreferences {
|
|||||||
try {
|
try {
|
||||||
String stringContents = FileUtil.getFileContents(settingsFile);
|
String stringContents = FileUtil.getFileContents(settingsFile);
|
||||||
return (JSONObject) parser.parse(stringContents);
|
return (JSONObject) parser.parse(stringContents);
|
||||||
} catch(Exception ex) {
|
} catch (Exception ex) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,11 +38,11 @@ public class PBLocalPreferences {
|
|||||||
* Convert a HashMap to json and writes it to the file
|
* Convert a HashMap to json and writes it to the file
|
||||||
*
|
*
|
||||||
* @param settings HashMap<String, String>
|
* @param settings HashMap<String, String>
|
||||||
* @param append If true, append to existing settings in file
|
* @param append If true, append to existing settings in file
|
||||||
*/
|
*/
|
||||||
public void writeSettings(HashMap<String, String> settings, boolean append) {
|
public void writeSettings(HashMap<String, String> settings, boolean append) {
|
||||||
JSONObject existingSettings;
|
JSONObject existingSettings;
|
||||||
if(append && (existingSettings = getSettings()) != null) {
|
if (append && (existingSettings = getSettings()) != null) {
|
||||||
existingSettings.putAll(settings);
|
existingSettings.putAll(settings);
|
||||||
settings = existingSettings;
|
settings = existingSettings;
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ public class PBLocalPreferences {
|
|||||||
/**
|
/**
|
||||||
* Adds a setting, or overwrites it if it exists
|
* Adds a setting, or overwrites it if it exists
|
||||||
*
|
*
|
||||||
* @param key key of the setting
|
* @param key key of the setting
|
||||||
* @param value value of the setting
|
* @param value value of the setting
|
||||||
*/
|
*/
|
||||||
public void addSetting(String key, String value) {
|
public void addSetting(String key, String value) {
|
||||||
@@ -75,10 +75,11 @@ public class PBLocalPreferences {
|
|||||||
* Fetches a setting
|
* Fetches a setting
|
||||||
*
|
*
|
||||||
* @param key key to get the value for
|
* @param key key to get the value for
|
||||||
|
*
|
||||||
* @return value that belongs to given key or null if non-existent
|
* @return value that belongs to given key or null if non-existent
|
||||||
*/
|
*/
|
||||||
public String getSetting(String key) {
|
public String getSetting(String key) {
|
||||||
if(getSettings() == null) {
|
if (getSettings() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ public class PBLocalPreferences {
|
|||||||
/**
|
/**
|
||||||
* Adjusts an existing setting
|
* Adjusts an existing setting
|
||||||
*
|
*
|
||||||
* @param key key to adjust the value for
|
* @param key key to adjust the value for
|
||||||
* @param value value for the key
|
* @param value value for the key
|
||||||
*/
|
*/
|
||||||
public void adjustSetting(String key, String value) {
|
public void adjustSetting(String key, String value) {
|
||||||
@@ -110,6 +111,7 @@ public class PBLocalPreferences {
|
|||||||
* Replaces all double dots to make sure the link does not leave the settings folder
|
* Replaces all double dots to make sure the link does not leave the settings folder
|
||||||
*
|
*
|
||||||
* @param filePath path to secure
|
* @param filePath path to secure
|
||||||
|
*
|
||||||
* @return secured string
|
* @return secured string
|
||||||
*/
|
*/
|
||||||
private static String secureFileName(String filePath) {
|
private static String secureFileName(String filePath) {
|
||||||
|
|||||||
@@ -25,37 +25,14 @@ public class PBPreferences {
|
|||||||
PBPreferences.manager = manager;
|
PBPreferences.manager = manager;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private final int scriptID;
|
||||||
private Properties properties;
|
private Properties properties;
|
||||||
private int scriptID;
|
|
||||||
|
|
||||||
public PBPreferences(int scriptID) {
|
public PBPreferences(int scriptID) {
|
||||||
this.scriptID = scriptID;
|
this.scriptID = scriptID;
|
||||||
this.updateSettings();
|
this.updateSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSettings() {
|
|
||||||
properties = new Properties();
|
|
||||||
try {
|
|
||||||
JSONObject result = (JSONObject) WebUtil.getJsonParser().parse(
|
|
||||||
WebUtil.getContents("http://bdn.parabot.org/api/v2/user/preferences/" + scriptID,
|
|
||||||
"apikey=" + manager.getAccount().getApi())
|
|
||||||
);
|
|
||||||
|
|
||||||
JSONArray resultArray;
|
|
||||||
if ((resultArray = ((JSONArray) result.get("result"))) != null) {
|
|
||||||
for (Object rObject : resultArray) {
|
|
||||||
JSONObject resultObject = (JSONObject) rObject;
|
|
||||||
for (Object map : resultObject.entrySet()) {
|
|
||||||
Map.Entry<?, ?> pairs = (Map.Entry<?, ?>) map;
|
|
||||||
properties.put(pairs.getKey(), pairs.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException | ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change a setting
|
* Change a setting
|
||||||
*
|
*
|
||||||
@@ -99,7 +76,7 @@ public class PBPreferences {
|
|||||||
WebUtil.getContents("http://bdn.parabot.org/api/v2/user/preferences/set/",
|
WebUtil.getContents("http://bdn.parabot.org/api/v2/user/preferences/set/",
|
||||||
"apikey=" + manager.getAccount().getApi() +
|
"apikey=" + manager.getAccount().getApi() +
|
||||||
"&key=" + URLEncoder.encode(String.valueOf(key), "UTF-8") +
|
"&key=" + URLEncoder.encode(String.valueOf(key), "UTF-8") +
|
||||||
"&script=" + String.valueOf(scriptID)
|
"&script=" + scriptID
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ((boolean) result.get("result")) {
|
if ((boolean) result.get("result")) {
|
||||||
@@ -123,7 +100,7 @@ public class PBPreferences {
|
|||||||
"apikey=" + manager.getAccount().getApi() +
|
"apikey=" + manager.getAccount().getApi() +
|
||||||
"&key=" + URLEncoder.encode(String.valueOf(key), "UTF-8") +
|
"&key=" + URLEncoder.encode(String.valueOf(key), "UTF-8") +
|
||||||
"&value=" + URLEncoder.encode(String.valueOf(value), "UTF-8") +
|
"&value=" + URLEncoder.encode(String.valueOf(value), "UTF-8") +
|
||||||
"&script=" + String.valueOf(scriptID)
|
"&script=" + scriptID
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ((boolean) result.get("result")) {
|
if ((boolean) result.get("result")) {
|
||||||
@@ -134,4 +111,27 @@ public class PBPreferences {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSettings() {
|
||||||
|
properties = new Properties();
|
||||||
|
try {
|
||||||
|
JSONObject result = (JSONObject) WebUtil.getJsonParser().parse(
|
||||||
|
WebUtil.getContents("http://bdn.parabot.org/api/v2/user/preferences/" + scriptID,
|
||||||
|
"apikey=" + manager.getAccount().getApi())
|
||||||
|
);
|
||||||
|
|
||||||
|
JSONArray resultArray;
|
||||||
|
if ((resultArray = ((JSONArray) result.get("result"))) != null) {
|
||||||
|
for (Object rObject : resultArray) {
|
||||||
|
JSONObject resultObject = (JSONObject) rObject;
|
||||||
|
for (Object map : resultObject.entrySet()) {
|
||||||
|
Map.Entry<?, ?> pairs = (Map.Entry<?, ?>) map;
|
||||||
|
properties.put(pairs.getKey(), pairs.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException | ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,22 +56,22 @@ public final class Time {
|
|||||||
/**
|
/**
|
||||||
* Sleeps until SleepCondition is valid, but with a minimum timeout.
|
* Sleeps until SleepCondition is valid, but with a minimum timeout.
|
||||||
*
|
*
|
||||||
* @param conn the condition.
|
* @param conn the condition.
|
||||||
* @param timeout the time in milliseconds before it stops sleeping.
|
* @param timeout the time in milliseconds before it stops sleeping.
|
||||||
* @param minimumTimeout the minimum time to sleep.
|
* @param minimumTimeout the minimum time to sleep.
|
||||||
*
|
*
|
||||||
* @return whether it ran successfully without timing out.
|
* @return whether it ran successfully without timing out.
|
||||||
*/
|
*/
|
||||||
public static boolean sleep(SleepCondition conn, int timeout, int minimumTimeout) {
|
public static boolean sleep(SleepCondition conn, int timeout, int minimumTimeout) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
if(!sleep(conn, timeout)) {
|
if (!sleep(conn, timeout)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
long t;
|
long t;
|
||||||
if((t = System.currentTimeMillis() - start) < minimumTimeout) {
|
if ((t = System.currentTimeMillis() - start) < minimumTimeout) {
|
||||||
Time.sleep((int)(minimumTimeout - t));
|
Time.sleep((int) (minimumTimeout - t));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -111,9 +111,10 @@ public class Timer {
|
|||||||
/**
|
/**
|
||||||
* Calculates hourly gains based on given variable, with variable start amount
|
* Calculates hourly gains based on given variable, with variable start amount
|
||||||
*
|
*
|
||||||
* @param gained total gained amount
|
* @param gained total gained amount
|
||||||
* @param startAmount start amount
|
* @param startAmount start amount
|
||||||
* @return hourly gains
|
*
|
||||||
|
* @return hourly gains
|
||||||
*/
|
*/
|
||||||
public int getPerHour(final int gained, final int startAmount) {
|
public int getPerHour(final int gained, final int startAmount) {
|
||||||
return (int) (((gained - startAmount) * 3600000D) / (System.currentTimeMillis() - start));
|
return (int) (((gained - startAmount) * 3600000D) / (System.currentTimeMillis() - start));
|
||||||
@@ -126,9 +127,9 @@ public class Timer {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
long elapsed = getElapsedTime();
|
long elapsed = getElapsedTime();
|
||||||
int day = (int) (elapsed / 86400000);
|
int day = (int) (elapsed / 86400000);
|
||||||
elapsed -= day * 86400000;
|
elapsed -= day * 86400000;
|
||||||
int hour = (int) (elapsed / 3600000);
|
int hour = (int) (elapsed / 3600000);
|
||||||
elapsed -= hour * 3600000;
|
elapsed -= hour * 3600000;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.parabot.core.ui.utils.UILog;
|
|||||||
public class Version implements Comparable<Version> {
|
public class Version implements Comparable<Version> {
|
||||||
|
|
||||||
private static boolean notified;
|
private static boolean notified;
|
||||||
private String version;
|
private final String version;
|
||||||
|
|
||||||
public Version(String version) {
|
public Version(String version) {
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
@@ -17,19 +17,6 @@ public class Version implements Comparable<Version> {
|
|||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void notifyRC() {
|
|
||||||
if (!notified) {
|
|
||||||
UILog.log(
|
|
||||||
"Version warning",
|
|
||||||
"This is an RC version of Parabot\n" +
|
|
||||||
"This could be an unstable version of Parabot, and might crash at anytime\n\n" +
|
|
||||||
"If you find an error within the client, please report any at:\n" +
|
|
||||||
"https://github.com/Parabot/Parabot/issues"
|
|
||||||
);
|
|
||||||
notified = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String get() {
|
public final String get() {
|
||||||
return this.version;
|
return this.version;
|
||||||
}
|
}
|
||||||
@@ -51,7 +38,7 @@ public class Version implements Comparable<Version> {
|
|||||||
|
|
||||||
String[] thisParts = this.get().split("\\.");
|
String[] thisParts = this.get().split("\\.");
|
||||||
String[] thatParts = that.get().split("\\.");
|
String[] thatParts = that.get().split("\\.");
|
||||||
int length = Math.max(thisParts.length, thatParts.length);
|
int length = Math.max(thisParts.length, thatParts.length);
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
int thisPart = i < thisParts.length ?
|
int thisPart = i < thisParts.length ?
|
||||||
@@ -72,4 +59,17 @@ public class Version implements Comparable<Version> {
|
|||||||
public boolean equals(Object that) {
|
public boolean equals(Object that) {
|
||||||
return this == that || that != null && this.getClass() == that.getClass() && this.compareTo((Version) that) == 0;
|
return this == that || that != null && this.getClass() == that.getClass() && this.compareTo((Version) that) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void notifyRC() {
|
||||||
|
if (!notified) {
|
||||||
|
UILog.log(
|
||||||
|
"Version warning",
|
||||||
|
"This is an RC version of Parabot\n" +
|
||||||
|
"This could be an unstable version of Parabot, and might crash at anytime\n\n" +
|
||||||
|
"If you find an error within the client, please report any at:\n" +
|
||||||
|
"https://github.com/Parabot/Parabot/issues"
|
||||||
|
);
|
||||||
|
notified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -14,13 +14,14 @@ public class WebUtil extends org.parabot.api.io.WebUtil {
|
|||||||
*
|
*
|
||||||
* @param url url to get the JSON string from
|
* @param url url to get the JSON string from
|
||||||
* @param key key to search for in the JSON string
|
* @param key key to search for in the JSON string
|
||||||
|
*
|
||||||
* @return value that belongs to given key
|
* @return value that belongs to given key
|
||||||
*/
|
*/
|
||||||
public static String getJsonValue(String url, String key) {
|
public static String getJsonValue(String url, String key) {
|
||||||
try {
|
try {
|
||||||
String response = WebUtil.getContents(url);
|
String response = WebUtil.getContents(url);
|
||||||
|
|
||||||
if(response.length() > 0) {
|
if (response.length() > 0) {
|
||||||
JSONObject jsonObject = (JSONObject) WebUtil.getJsonParser().parse(response);
|
JSONObject jsonObject = (JSONObject) WebUtil.getJsonParser().parse(response);
|
||||||
if (jsonObject.get(key) != null) {
|
if (jsonObject.get(key) != null) {
|
||||||
return jsonObject.get(key).toString();
|
return jsonObject.get(key).toString();
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public abstract class ExceptionHandler implements Thread.UncaughtExceptionHandle
|
|||||||
SCRIPT("Script"),
|
SCRIPT("Script"),
|
||||||
CLIENT("Client");
|
CLIENT("Client");
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
ExceptionType(String name) {
|
ExceptionType(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ import org.parabot.core.Directories;
|
|||||||
import org.parabot.core.ui.utils.UILog;
|
import org.parabot.core.ui.utils.UILog;
|
||||||
import org.parabot.environment.api.utils.FileUtil;
|
import org.parabot.environment.api.utils.FileUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
import java.awt.Desktop;
|
||||||
import java.awt.*;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes exceptions to a file and reports the file location back to the user
|
* Writes exceptions to a file and reports the file location back to the user
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package org.parabot.environment.input;
|
|||||||
|
|
||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Component;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -14,13 +14,12 @@ import java.util.Random;
|
|||||||
* @author Everel, Matt, Dane
|
* @author Everel, Matt, Dane
|
||||||
*/
|
*/
|
||||||
public class Keyboard implements KeyListener {
|
public class Keyboard implements KeyListener {
|
||||||
private static HashMap<Character, Character> specialChars;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code KeyEvent.VK_ENTER} is actually New Line, '\n'.
|
* {@code KeyEvent.VK_ENTER} is actually New Line, '\n'.
|
||||||
* The code for the Enter button is 13. It has no associated {@link KeyEvent} constant.
|
* The code for the Enter button is 13. It has no associated {@link KeyEvent} constant.
|
||||||
*/
|
*/
|
||||||
public static final int ENTER_KEYCODE = 13;
|
public static final int ENTER_KEYCODE = 13;
|
||||||
|
private static final HashMap<Character, Character> specialChars;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
char[] spChars = { '~', '!', '@', '#', '%', '^', '&', '*', '(', ')',
|
char[] spChars = { '~', '!', '@', '#', '%', '^', '&', '*', '(', ')',
|
||||||
@@ -33,8 +32,8 @@ public class Keyboard implements KeyListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Component component;
|
private final Component component;
|
||||||
private long pressTime;
|
private long pressTime;
|
||||||
|
|
||||||
public Keyboard(Component component) {
|
public Keyboard(Component component) {
|
||||||
this.component = component;
|
this.component = component;
|
||||||
@@ -44,15 +43,6 @@ public class Keyboard implements KeyListener {
|
|||||||
return Context.getInstance().getKeyboard();
|
return Context.getInstance().getKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a random number in the range of 40-140.
|
|
||||||
* @return The random number
|
|
||||||
*/
|
|
||||||
private static long getRandom() {
|
|
||||||
Random rand = new Random();
|
|
||||||
return rand.nextInt(100) + 40;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types the given String and afterwards presses Enter.
|
* Types the given String and afterwards presses Enter.
|
||||||
*
|
*
|
||||||
@@ -64,7 +54,8 @@ public class Keyboard implements KeyListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Types the given String and optionally presses Enter afterwards.
|
* Types the given String and optionally presses Enter afterwards.
|
||||||
* @param s The String to type.
|
*
|
||||||
|
* @param s The String to type.
|
||||||
* @param enterAfter True if {@code KeyEvent.VK_ENTER} should be pressed afterwards. This is actually the '\n' character, for New Line. Useful for logging in.
|
* @param enterAfter True if {@code KeyEvent.VK_ENTER} should be pressed afterwards. This is actually the '\n' character, for New Line. Useful for logging in.
|
||||||
*/
|
*/
|
||||||
public void sendKeys(String s, boolean enterAfter) {
|
public void sendKeys(String s, boolean enterAfter) {
|
||||||
@@ -87,6 +78,7 @@ public class Keyboard implements KeyListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and sends a single KeyEvent using the given Char.
|
* Creates and sends a single KeyEvent using the given Char.
|
||||||
|
*
|
||||||
* @param c The char to send.
|
* @param c The char to send.
|
||||||
*/
|
*/
|
||||||
public void clickKey(char c) {
|
public void clickKey(char c) {
|
||||||
@@ -100,6 +92,7 @@ public class Keyboard implements KeyListener {
|
|||||||
/**
|
/**
|
||||||
* Creates and sends a given KeyEvent using the given keyCode.
|
* Creates and sends a given KeyEvent using the given keyCode.
|
||||||
* <p>Use constants where possible, from {@link KeyEvent}, such as {@code KeyEvent.VK_ENTER}
|
* <p>Use constants where possible, from {@link KeyEvent}, such as {@code KeyEvent.VK_ENTER}
|
||||||
|
*
|
||||||
* @param keyCode The keycode to send.
|
* @param keyCode The keycode to send.
|
||||||
*/
|
*/
|
||||||
public void clickKey(int keyCode) {
|
public void clickKey(int keyCode) {
|
||||||
@@ -114,6 +107,7 @@ public class Keyboard implements KeyListener {
|
|||||||
* Creates and sends a given PRESS KeyEvent using the given keyCode. Note, this does not send a Release Event
|
* Creates and sends a given PRESS KeyEvent using the given keyCode. Note, this does not send a Release Event
|
||||||
* typically associated with a key click.
|
* typically associated with a key click.
|
||||||
* <p>Use constants where possible, from {@link KeyEvent}, such as {@code KeyEvent.VK_ENTER}
|
* <p>Use constants where possible, from {@link KeyEvent}, such as {@code KeyEvent.VK_ENTER}
|
||||||
|
*
|
||||||
* @param keyCode
|
* @param keyCode
|
||||||
*/
|
*/
|
||||||
public void pressKey(int keyCode) {
|
public void pressKey(int keyCode) {
|
||||||
@@ -127,6 +121,7 @@ public class Keyboard implements KeyListener {
|
|||||||
* Creates and sends a given RELEASE KeyEvent using the given keyCode. Note, this does not send a Press Event
|
* Creates and sends a given RELEASE KeyEvent using the given keyCode. Note, this does not send a Press Event
|
||||||
* typically associated with a key click.
|
* typically associated with a key click.
|
||||||
* <p>Use constants where possible, from {@link KeyEvent}, such as {@code KeyEvent.VK_ENTER}
|
* <p>Use constants where possible, from {@link KeyEvent}, such as {@code KeyEvent.VK_ENTER}
|
||||||
|
*
|
||||||
* @param keyCode
|
* @param keyCode
|
||||||
*/
|
*/
|
||||||
public void releaseKey(int keyCode) {
|
public void releaseKey(int keyCode) {
|
||||||
@@ -136,13 +131,81 @@ public class Keyboard implements KeyListener {
|
|||||||
sendKeyEvent(ke);
|
sendKeyEvent(ke);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actually triggers sending of a given KeyEvent in the instance of KeyListeners' {@code component} field.
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
public void sendKeyEvent(KeyEvent e) {
|
||||||
|
for (KeyListener kl : component.getKeyListeners()) {
|
||||||
|
if (kl instanceof Keyboard) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!e.isConsumed()) {
|
||||||
|
switch (e.getID()) {
|
||||||
|
case KeyEvent.KEY_PRESSED:
|
||||||
|
kl.keyPressed(e);
|
||||||
|
break;
|
||||||
|
case KeyEvent.KEY_RELEASED:
|
||||||
|
kl.keyReleased(e);
|
||||||
|
break;
|
||||||
|
case KeyEvent.KEY_TYPED:
|
||||||
|
kl.keyTyped(e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the {@code KeyListener.keyPressed} event to be overridden.
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the {@code KeyListener.keyReleased} event to be overridden.
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void keyReleased(KeyEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the {@code KeyListener.keyTyped} event to be overridden.
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void keyTyped(KeyEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a random number in the range of 40-140.
|
||||||
|
*
|
||||||
|
* @return The random number
|
||||||
|
*/
|
||||||
|
private static long getRandom() {
|
||||||
|
Random rand = new Random();
|
||||||
|
return rand.nextInt(100) + 40;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates KeyEvents to perform a Click of the given Char. This includes a Press, Typed and Release event
|
* Creates KeyEvents to perform a Click of the given Char. This includes a Press, Typed and Release event
|
||||||
* in addition to an initial shiftDown and ending shiftUp if the character is a Special Char such as {@code !"£$%^&*(}
|
* in addition to an initial shiftDown and ending shiftUp if the character is a Special Char such as {@code !"£$%^&*(}
|
||||||
|
* <p>
|
||||||
|
* {@see specialChars}
|
||||||
*
|
*
|
||||||
* {@see specialChars}
|
|
||||||
* @param target Component this event is linked to.
|
* @param target Component this event is linked to.
|
||||||
* @param c Char to send.
|
* @param c Char to send.
|
||||||
|
*
|
||||||
* @return KeyEvents for each action.
|
* @return KeyEvents for each action.
|
||||||
*/
|
*/
|
||||||
private KeyEvent[] createKeyClick(Component target, char c) {
|
private KeyEvent[] createKeyClick(Component target, char c) {
|
||||||
@@ -150,7 +213,7 @@ public class Keyboard implements KeyListener {
|
|||||||
pressTime += 2 * getRandom();
|
pressTime += 2 * getRandom();
|
||||||
|
|
||||||
Character newChar = specialChars.get(c);
|
Character newChar = specialChars.get(c);
|
||||||
int keyCode = Character.toUpperCase((newChar == null) ? c : newChar);
|
int keyCode = Character.toUpperCase((newChar == null) ? c : newChar);
|
||||||
|
|
||||||
if (Character.isLowerCase(c)
|
if (Character.isLowerCase(c)
|
||||||
|| (!Character.isLetter(c) && (newChar == null))) {
|
|| (!Character.isLetter(c) && (newChar == null))) {
|
||||||
@@ -187,8 +250,10 @@ public class Keyboard implements KeyListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates KeyEvents for Press and Release of the given keyCode.
|
* Creates KeyEvents for Press and Release of the given keyCode.
|
||||||
|
*
|
||||||
* @param target
|
* @param target
|
||||||
* @param keyCode
|
* @param keyCode
|
||||||
|
*
|
||||||
* @return An array containing Press and Release KeyEvents.
|
* @return An array containing Press and Release KeyEvents.
|
||||||
*/
|
*/
|
||||||
private KeyEvent[] createKeyClick(Component target, int keyCode) {
|
private KeyEvent[] createKeyClick(Component target, int keyCode) {
|
||||||
@@ -198,8 +263,10 @@ public class Keyboard implements KeyListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Press type KeyEvent
|
* Creates a Press type KeyEvent
|
||||||
|
*
|
||||||
* @param target
|
* @param target
|
||||||
* @param keyCode
|
* @param keyCode
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private KeyEvent createKeyPress(Component target, int keyCode) {
|
private KeyEvent createKeyPress(Component target, int keyCode) {
|
||||||
@@ -223,8 +290,10 @@ public class Keyboard implements KeyListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Release type KeyEvent
|
* Creates a Release type KeyEvent
|
||||||
|
*
|
||||||
* @param target
|
* @param target
|
||||||
* @param keyCode
|
* @param keyCode
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private KeyEvent createKeyRelease(Component target, int keyCode) {
|
private KeyEvent createKeyRelease(Component target, int keyCode) {
|
||||||
@@ -234,56 +303,4 @@ public class Keyboard implements KeyListener {
|
|||||||
return released;
|
return released;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Actually triggers sending of a given KeyEvent in the instance of KeyListeners' {@code component} field.
|
|
||||||
* @param e
|
|
||||||
*/
|
|
||||||
public void sendKeyEvent(KeyEvent e) {
|
|
||||||
for (KeyListener kl : component.getKeyListeners()) {
|
|
||||||
if (kl instanceof Keyboard) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!e.isConsumed()) {
|
|
||||||
switch (e.getID()) {
|
|
||||||
case KeyEvent.KEY_PRESSED:
|
|
||||||
kl.keyPressed(e);
|
|
||||||
break;
|
|
||||||
case KeyEvent.KEY_RELEASED:
|
|
||||||
kl.keyReleased(e);
|
|
||||||
break;
|
|
||||||
case KeyEvent.KEY_TYPED:
|
|
||||||
kl.keyTyped(e);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows the {@code KeyListener.keyPressed} event to be overridden.
|
|
||||||
* @param e
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void keyPressed(KeyEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows the {@code KeyListener.keyReleased} event to be overridden.
|
|
||||||
* @param e
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void keyReleased(KeyEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows the {@code KeyListener.keyTyped} event to be overridden.
|
|
||||||
* @param e
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void keyTyped(KeyEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ package org.parabot.environment.input;
|
|||||||
import org.parabot.core.Context;
|
import org.parabot.core.Context;
|
||||||
import org.parabot.environment.api.utils.Time;
|
import org.parabot.environment.api.utils.Time;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Component;
|
||||||
|
import java.awt.Point;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
@@ -14,9 +15,9 @@ import java.awt.event.MouseMotionListener;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class Mouse implements MouseListener, MouseMotionListener {
|
public class Mouse implements MouseListener, MouseMotionListener {
|
||||||
private Component component;
|
private final Component component;
|
||||||
private int x;
|
private int x;
|
||||||
private int y;
|
private int y;
|
||||||
|
|
||||||
public Mouse(Component component) {
|
public Mouse(Component component) {
|
||||||
this.component = component;
|
this.component = component;
|
||||||
|
|||||||
@@ -10,32 +10,32 @@ public interface Random {
|
|||||||
*
|
*
|
||||||
* @return <b>true</b> if this random should be activate
|
* @return <b>true</b> if this random should be activate
|
||||||
*/
|
*/
|
||||||
public boolean activate();
|
boolean activate();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes this random
|
* Executes this random
|
||||||
*/
|
*/
|
||||||
public void execute();
|
void execute();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the random
|
* Returns the name of the random
|
||||||
*
|
*
|
||||||
* @return Name of the random
|
* @return Name of the random
|
||||||
*/
|
*/
|
||||||
public String getName();
|
String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the server which the random is made for
|
* Returns the name of the server which the random is made for
|
||||||
*
|
*
|
||||||
* @return Name of the server
|
* @return Name of the server
|
||||||
*/
|
*/
|
||||||
public String getServer();
|
String getServer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the RandomType of the random
|
* Returns the RandomType of the random
|
||||||
*
|
*
|
||||||
* @return The RandomType of the random
|
* @return The RandomType of the random
|
||||||
*/
|
*/
|
||||||
public RandomType getRandomType();
|
RandomType getRandomType();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,11 @@ import java.util.ArrayList;
|
|||||||
* @author JKetelaar
|
* @author JKetelaar
|
||||||
*/
|
*/
|
||||||
public class RandomHandler {
|
public class RandomHandler {
|
||||||
private ArrayList<Random> randoms;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The randoms that will actually run
|
* The randoms that will actually run
|
||||||
*/
|
*/
|
||||||
private ArrayList<Random> activeRandoms;
|
private final ArrayList<Random> activeRandoms;
|
||||||
|
private ArrayList<Random> randoms;
|
||||||
|
|
||||||
public RandomHandler() {
|
public RandomHandler() {
|
||||||
this.randoms = new ArrayList<>();
|
this.randoms = new ArrayList<>();
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ public enum RandomType {
|
|||||||
ON_SERVER_START(2, "On server start"),
|
ON_SERVER_START(2, "On server start"),
|
||||||
ON_SCRIPT_FINISH(3, "On script finish");
|
ON_SCRIPT_FINISH(3, "On script finish");
|
||||||
|
|
||||||
private int id;
|
private final int id;
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
RandomType(int id, String name) {
|
RandomType(int id, String name) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public enum Category {
|
|||||||
/**
|
/**
|
||||||
* Cache
|
* Cache
|
||||||
*/
|
*/
|
||||||
private static HashMap<String, BufferedImage> images = new HashMap<>();
|
private static final HashMap<String, BufferedImage> images = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
images.put("script", Images.getResource("/storage/images/category/script.png"));
|
images.put("script", Images.getResource("/storage/images/category/script.png"));
|
||||||
|
|||||||
@@ -8,8 +8,11 @@ import org.parabot.environment.api.utils.PBPreferences;
|
|||||||
import org.parabot.environment.api.utils.Time;
|
import org.parabot.environment.api.utils.Time;
|
||||||
import org.parabot.environment.randoms.Random;
|
import org.parabot.environment.randoms.Random;
|
||||||
import org.parabot.environment.randoms.RandomType;
|
import org.parabot.environment.randoms.RandomType;
|
||||||
import org.parabot.environment.scripts.framework.*;
|
import org.parabot.environment.scripts.framework.AbstractFramework;
|
||||||
import org.parabot.environment.scripts.framework.Frameworks;
|
import org.parabot.environment.scripts.framework.Frameworks;
|
||||||
|
import org.parabot.environment.scripts.framework.LoopTask;
|
||||||
|
import org.parabot.environment.scripts.framework.SleepCondition;
|
||||||
|
import org.parabot.environment.scripts.framework.Strategy;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -20,19 +23,19 @@ import java.util.Collection;
|
|||||||
*/
|
*/
|
||||||
public class Script implements Runnable {
|
public class Script implements Runnable {
|
||||||
public static final int TYPE_STRATEGY = 0;
|
public static final int TYPE_STRATEGY = 0;
|
||||||
public static final int TYPE_LOOP = 1;
|
public static final int TYPE_LOOP = 1;
|
||||||
public static final int TYPE_OTHER = 2;
|
public static final int TYPE_OTHER = 2;
|
||||||
|
|
||||||
public static final int STATE_RUNNING = 0;
|
public static final int STATE_RUNNING = 0;
|
||||||
public static final int STATE_PAUSE = 1;
|
public static final int STATE_PAUSE = 1;
|
||||||
public static final int STATE_STOPPED = 2;
|
public static final int STATE_STOPPED = 2;
|
||||||
|
|
||||||
private Collection<Strategy> strategies;
|
private Collection<Strategy> strategies;
|
||||||
private PBPreferences preferences;
|
private PBPreferences preferences;
|
||||||
private AbstractFramework frameWork;
|
private AbstractFramework frameWork;
|
||||||
private int state;
|
private int state;
|
||||||
private int frameWorkType;
|
private int frameWorkType;
|
||||||
private int scriptID;
|
private int scriptID;
|
||||||
|
|
||||||
public boolean onExecute() {
|
public boolean onExecute() {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ import org.parabot.environment.api.utils.WebUtil;
|
|||||||
import org.parabot.environment.scripts.Script;
|
import org.parabot.environment.scripts.Script;
|
||||||
import org.parabot.environment.scripts.loader.JavaScriptLoader;
|
import org.parabot.environment.scripts.loader.JavaScriptLoader;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a script from the BDN
|
* Loads a script from the BDN
|
||||||
*
|
*
|
||||||
@@ -68,9 +69,9 @@ public class BDNScriptsExecuter extends ScriptExecuter {
|
|||||||
|
|
||||||
final String className = scriptClasses[0];
|
final String className = scriptClasses[0];
|
||||||
try {
|
try {
|
||||||
final Class<?> scriptClass = loader.loadClass(className);
|
final Class<?> scriptClass = loader.loadClass(className);
|
||||||
final Constructor<?> con = scriptClass.getConstructor();
|
final Constructor<?> con = scriptClass.getConstructor();
|
||||||
final Script script = (Script) con.newInstance();
|
final Script script = (Script) con.newInstance();
|
||||||
script.setScriptID(this.id);
|
script.setScriptID(this.id);
|
||||||
super.finalize(tg, script);
|
super.finalize(tg, script);
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.lang.reflect.Constructor;
|
|||||||
* @author Everel
|
* @author Everel
|
||||||
*/
|
*/
|
||||||
public class LocalScriptExecuter extends ScriptExecuter {
|
public class LocalScriptExecuter extends ScriptExecuter {
|
||||||
private Constructor<?> scriptConstructor;
|
private final Constructor<?> scriptConstructor;
|
||||||
|
|
||||||
public LocalScriptExecuter(final Constructor<?> scriptConstructor) {
|
public LocalScriptExecuter(final Constructor<?> scriptConstructor) {
|
||||||
this.scriptConstructor = scriptConstructor;
|
this.scriptConstructor = scriptConstructor;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class Looper extends AbstractFramework {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class StrategyWorker extends AbstractFramework {
|
class StrategyWorker extends AbstractFramework {
|
||||||
private Collection<Strategy> strategies;
|
private final Collection<Strategy> strategies;
|
||||||
|
|
||||||
public StrategyWorker(Collection<Strategy> strategies) {
|
public StrategyWorker(Collection<Strategy> strategies) {
|
||||||
this.strategies = strategies;
|
this.strategies = strategies;
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ public interface LoopTask {
|
|||||||
/**
|
/**
|
||||||
* @return sleepTime in ms
|
* @return sleepTime in ms
|
||||||
*/
|
*/
|
||||||
public int loop();
|
int loop();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public interface SleepCondition {
|
|||||||
*
|
*
|
||||||
* @return <b>true</b> if valid, otherwise <b>false</b>.
|
* @return <b>true</b> if valid, otherwise <b>false</b>.
|
||||||
*/
|
*/
|
||||||
public boolean isValid();
|
boolean isValid();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ public interface Strategy {
|
|||||||
*
|
*
|
||||||
* @return <b>true</b> if this strategy should be executed, otherwise <b>false</b>.
|
* @return <b>true</b> if this strategy should be executed, otherwise <b>false</b>.
|
||||||
*/
|
*/
|
||||||
public boolean activate();
|
boolean activate();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes this strategy
|
* Executes this strategy
|
||||||
*/
|
*/
|
||||||
public void execute();
|
void execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user