rendered paste bodyimport impsoft.ibot.methods.Script;
import java.awt.event.MouseListener;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URL;
import java.security.CodeSource;
public class unitTest2 extends Script {
public static double version = 2.1;
public static String[] commands = new String[] { "mouselistener", };
public String author = "ruler";
public String description = "a simple demo";
public static String args[];
@Override
public boolean doStart(String cmd, String[] args) {
return true;
}
@Override
public void script() throws InterruptedException {
while (true) {
MouseListener mouseListener = theBot.theApplet.getComponentAt(1, 1)
.getListeners(MouseListener.class)[0];
// hehe mouseListener.mouseClicked(e);
log("IBOT runescape static listener");
printClass("", mouseListener);
log("IBOT runescape applet");
printClass("", theBot.theApplet);
sleep(1000);
}
}
public void printClass(String front, Object test) {
Class theClass = test.getClass();
CodeSource source = theClass.getProtectionDomain().getCodeSource();
if (source != null) {
front += theClass.getName() + ".";
URL location = source.getLocation();
log(theClass.getPackage() + " : " + location);
String classDeclaration = getModifiers(theClass)
+ theClass.getName();
if (theClass.getSuperclass() != null) {
classDeclaration += " extends "
+ theClass.getSuperclass().getName();
}
Class interfaces[] = theClass.getInterfaces();
for(int i=0;i<interfaces.length;i++){
if(i==0)
classDeclaration+=" Implements ";
classDeclaration+=" "+ interfaces[i].getName();
}
log(classDeclaration + "{");
Field fields[] = theClass.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
fields[i].setAccessible(true);
Class typeClass = fields[i].getType();
if (typeClass.isArray()) {
Class componentClass = typeClass.getComponentType();
String componentName = componentClass.getName();
int depth = 1;
while (componentClass.isArray()) {
componentClass = componentClass.getComponentType();
componentName = componentClass.getName();
depth++;
}
String printOut = "";
while (depth > 0) {
printOut += "[]";
depth--;
}
//log(getModifiers(fields[i]) + componentName + printOut
// + " " + front + fields[i].getName() + " = "
//+ value(front, fields[i], theClass));
String front2 = getModifiers(fields[i]) + " "
+ componentName + printOut + " " + front
+ fields[i].getName();
valueArray(front2, fields[i], theClass);
} else {
// log(" " + getModifiers(fields[i]) + typeClass.getName()
// + " " + fields[i].getName() + " "
// + value(fields[i], theClass));
String value = value(front, fields[i], theClass, test);
if (value.length() > 1) {
log(getModifiers(fields[i]) + " " + typeClass.getName()
+ " " + front + fields[i].getName() + " = "
+ value);
}
}
fields[i].setAccessible(false);
}
Method methods[] = theClass.getDeclaredMethods();
for(int i=0;i<methods.length;i++){
log(methods[i].toString());
}
}
}
public String getModifiers(Class theClass) {
if (!Modifier.isInterface(theClass.getModifiers())) {
return Modifier.toString(theClass.getModifiers()) + " class ";
}
return Modifier.toString(theClass.getModifiers()) + " ";
}
public String getModifiers(Field theField) {
String modifiers = Modifier.toString(theField.getModifiers());
return modifiers;
}
public String getModifiers(Method theMethod) {
return Modifier.toString(theMethod.getModifiers());
}
public String value(String front, Field theField, Class theClass,
Object test) {
Class typeClass = theField.getType();
String fieldType = typeClass.getName();
if (fieldType.equalsIgnoreCase("boolean")) {
try {
if (theClass != null && theField != null) {
boolean x = theField.getBoolean(test);
return "" + x;
}
} catch (Exception e) {
exception(e);
}
} else if (fieldType.equalsIgnoreCase("int")) {
try {
if (theClass != null && theField != null) {
int x = theField.getInt(test);
return " " + x;
}
} catch (Exception e) {
exception(e);
}
} else if (fieldType.equalsIgnoreCase("double")) {
try {
if (theClass != null && theField != null) {
double x = theField.getDouble(test);
return "" + x;
}
} catch (Exception e) {
exception(e);
}
} else if (fieldType.equalsIgnoreCase("long")) {
try {
if (theClass != null && theField != null) {
long x = theField.getLong(test);
return "" + x;
}
} catch (Exception e) {
exception(e);
}
} else if (fieldType.equalsIgnoreCase("byte")) {
try {
if (theClass != null && theField != null) {
byte x = theField.getByte(test);
return "" + x;
}
} catch (Exception e) {
exception(e);
}
} else if (fieldType.equalsIgnoreCase("char")) {
try {
if (theClass != null && theField != null) {
char x = theField.getChar(test);
return "" + x;
}
} catch (Exception e) {
exception(e);
}
} else if (fieldType.equalsIgnoreCase("float")) {
try {
if (theClass != null && theField != null) {
float x = theField.getFloat(test);
return "" + x;
}
} catch (Exception e) {
exception(e);
}
} else if (fieldType.equalsIgnoreCase("short")) {
try {
if (theClass != null && theField != null) {
short x = theField.getShort(test);
return "" + x;
}
} catch (Exception e) {
exception(e);
}
} else if (!fieldType.equalsIgnoreCase(theClass.getName())) {
try {
if (theClass != null && theField != null) {
Object x = theField.get(test);
if (x != null) {
if (typeClass.isArray()) {
return "" + x;
} else {
boolean unique = true;
String strings[] = front.split("\\.");
String newClass = x.getClass().getName();
for (int i = 0; i < strings.length; i++) {
if (strings[i].equalsIgnoreCase(newClass)) {
unique = false;
break;
}
}
if (unique) {
//printClass(front, x);
}
try{
return "" + x;
}catch(Exception e){
}
return "null";
}
} else {
return "null";
}
}
} catch (Exception e) {
exception(e);
}
}
return "";
}
public void valueArray(String front2, Field theField, Class theClass) {
Object x;
try {
x = theField.get((theClass));
if (x != null) {
valueArray(front2, theField, x);
} else {
log(front2 + " = null");
}
} catch (Exception e) {
log(front2 + " = null");
}
}
public void valueArray(String front2, Field theField, Object objectArray) {
if (objectArray instanceof int[]) {
int[] array = (int[]) objectArray;
log(front2 + "[" + array.length + "]");
// for (int i = 0; i < array.length; i++) {
// log(front2 + "[" + i + "] = " + array[i]);
// }
} else if (objectArray instanceof boolean[]) {
boolean[] array = (boolean[]) objectArray;
log(front2 + "[" + array.length + "]");
// for (int i = 0; i < array.length; i++) {
// log(front2 + "[" + i + "] = " + array[i]);
// }
} else if (objectArray instanceof short[]) {
short[] array = (short[]) objectArray;
log(front2 + "[" + array.length + "]");
// for (int i = 0; i < array.length; i++) {
// log(front2 + "[" + i + "] = " + array[i]);
// }
} else if (objectArray instanceof byte[][]) {
byte[][] array = (byte[][]) objectArray;
log(front2 + "[" + array.length + "]" + "[" + array[0].length + "]");
// for (int i = 0; i < array.length; i++) {
// for (int o = 0; o < array[0].length; o++) {
// log(front2 + "[" + i + "]" + "[" + o + "] = " + array[i][o]);
// }
// }
} else if (objectArray instanceof byte[]) {
byte[] array = (byte[]) objectArray;
log(front2 + "[" + array.length + "]");
// for (int i = 0; i < array.length; i++) {
// log(front2 + "[" + i + "] = " + array[i]);
// }
} else if (objectArray instanceof long[]) {
long[] array = (long[]) objectArray;
log(front2 + "[" + array.length + "]");
// for (int i = 0; i < array.length; i++) {
// log(front2 + "[" + i + "] = " + array[i]);
// }
} else if (objectArray instanceof Object[]) {
Object[] array = (Object[]) objectArray;
for (int i = 0; i < array.length; i++) {
printClass(front2 + "[" + i + "]", array[i]);
}
} else {
log("!!!!!!!" + objectArray);
}
}
}