Fixed some formats

This commit is contained in:
Jeroen Ketelaar
2014-02-14 03:40:19 +01:00
parent d11849bebb
commit 570601c534
2 changed files with 269 additions and 263 deletions
@@ -1,20 +1,18 @@
package org.parabot.core; package org.parabot.core;
/** /**
*
* Holds some important constants * Holds some important constants
*
* @author Everel
* *
* @author Everel
*/ */
public class Configuration { public class Configuration {
public static final String LOGIN_SERVER = "http://www.parabot.org/community/api/login.php?username=%s&password=%s"; public static final String LOGIN_SERVER = "http://www.parabot.org/community/api/login.php?username=%s&password=%s";
public static final String SDN_SCRIPTS = "http://sdn.parabot.org/scripts.php?user=%s"; public static final String SDN_SCRIPTS = "http://sdn.parabot.org/scripts.php?user=%s";
public static final String GET_SDN_SCRIPT = "http://sdn.parabot.org/getscript.php?user=%s&pass=%s&scriptid=%d"; public static final String GET_SDN_SCRIPT = "http://sdn.parabot.org/getscript.php?user=%s&pass=%s&scriptid=%d";
public static final String GET_SERVER_PROVIDERS = "http://sdn.parabot.org/list/providers.php"; public static final String GET_SERVER_PROVIDERS = "http://sdn.parabot.org/list/providers.php";
public static final String GET_SERVER_PROVIDER = "http://sdn.parabot.org/providers/%s"; public static final String GET_SERVER_PROVIDER = "http://sdn.parabot.org/providers/%s";
public static final String GET_BOT_VERSION = "http://bot.parabot.org/version.txt"; public static final String GET_BOT_VERSION = "http://bot.parabot.org/version.txt";
public static final double BOT_VERSION = 2.04; // BETA public static final double BOT_VERSION = 2.04; // BETA
} }
+259 -251
View File
@@ -1,10 +1,5 @@
package org.parabot.core; package org.parabot.core;
import java.applet.Applet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.TimerTask;
import org.parabot.core.asm.ASMClassLoader; import org.parabot.core.asm.ASMClassLoader;
import org.parabot.core.classpath.ClassPath; import org.parabot.core.classpath.ClassPath;
import org.parabot.core.paint.PaintDebugger; import org.parabot.core.paint.PaintDebugger;
@@ -17,277 +12,290 @@ import org.parabot.environment.input.Mouse;
import org.parabot.environment.scripts.Script; import org.parabot.environment.scripts.Script;
import org.parabot.environment.servers.ServerProvider; import org.parabot.environment.servers.ServerProvider;
import java.applet.Applet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.TimerTask;
/** /**
* Game context * Game context
* *
* @author Everel * @author Everel
*
*/ */
public class Context { public class Context {
public static HashMap<ThreadGroup, Context> threadGroups = new HashMap<ThreadGroup, Context>(); public static HashMap<ThreadGroup, Context> threadGroups = new HashMap<ThreadGroup, Context>();
private static int id = 1; private static int id = 1;
private ASMClassLoader classLoader = null; private ASMClassLoader classLoader = null;
private ClassPath classPath = null; private ClassPath classPath = null;
private ServerProvider serverProvider = null; private ServerProvider serverProvider = null;
private int tab = 0; private int tab = 0;
private Applet gameApplet = null; private Applet gameApplet = null;
private HookParser hookParser = null; private HookParser hookParser = null;
private Script runningScript = null; private Script runningScript = null;
private Object clientInstance = null; private Object clientInstance = null;
private static ArrayList<Paintable> paintables = new ArrayList<Paintable>(); private static ArrayList<Paintable> paintables = new ArrayList<Paintable>();
private PaintDebugger paintDebugger = new PaintDebugger(); private PaintDebugger paintDebugger = new PaintDebugger();
public boolean added = false; public boolean added = false;
private Mouse mouse = null;
private Keyboard keyboard = null;
public Context(final ServerProvider serverProvider) { private Mouse mouse = null;
threadGroups.put(Thread.currentThread().getThreadGroup(), this); private Keyboard keyboard = null;
tab = id;
this.serverProvider = serverProvider;
id++;
this.classPath = new ClassPath();
classLoader = new ASMClassLoader(classPath);
}
/**
* Resolves the context from threadgroup
*
* @return context
*/
public static Context resolve() {
return threadGroups.get(Thread.currentThread().getThreadGroup());
}
public static Context currentTab() {
// TODO
return threadGroups.values().iterator().next();
}
public void setEnvironment() { public Context(final ServerProvider serverProvider) {
classLoader = new ASMClassLoader(classPath); threadGroups.put(Thread.currentThread().getThreadGroup(), this);
} tab = id;
this.serverProvider = serverProvider;
id++;
this.classPath = new ClassPath();
classLoader = new ASMClassLoader(classPath);
}
/** /**
* Sets the main client instance * Resolves the context from threadgroup
*/ *
public void setClientInstance(Object object) { * @return context
this.clientInstance = object; */
} public static Context resolve() {
return threadGroups.get(Thread.currentThread().getThreadGroup());
/** }
* Sets the hook parser
* @param hookParser
*/
public void setHookParser(final HookParser hookParser) {
this.hookParser = hookParser;
}
/**
* Sets the mouse
* @param mouse
*/
public void setMouse(final Mouse mouse) {
this.mouse = mouse;
}
/**
* Gets the mouse
* @return mouse
*/
public Mouse getMouse() {
return mouse;
}
/**
* Sets the keyboard
* @param keyboard
*/
public void setKeyboard(final Keyboard keyboard) {
this.keyboard = keyboard;
}
/**
* Gets the keyboard
* @return keyboard
*/
public Keyboard getKeyboard() {
return keyboard;
}
/** public static Context currentTab() {
* ClassPath // TODO
* return threadGroups.values().iterator().next();
* @return classpath }
*/
public ClassPath getClassPath() {
return classPath;
}
/** public void setEnvironment() {
* Determines if applet has been set classLoader = new ASMClassLoader(classPath);
* }
* @return <b>true</b> if set
*/
public boolean appletSet() {
return gameApplet != null;
}
/** /**
* Gets game applet * Sets the main client instance
* */
* @return applet public void setClientInstance(Object object) {
*/ this.clientInstance = object;
public Applet getApplet() { }
return gameApplet;
}
/** /**
* Loads the game * Sets the hook parser
*/ *
public void load() { * @param hookParser
Core.verbose("Parsing server jar..."); */
serverProvider.parseJar(); public void setHookParser(final HookParser hookParser) {
Core.verbose("Done."); this.hookParser = hookParser;
Core.verbose("Injecting hooks..."); }
serverProvider.injectHooks();
Core.verbose("Done.");
Core.verbose("Fetching game applet...");;
gameApplet = serverProvider.fetchApplet();
if (getClient() == null) {
setClientInstance(gameApplet);
}
Core.verbose("Applet fetched.");
serverProvider.addMenuItems(BotUI.getInstance().getJMenuBar());
BotUI.getInstance().validate();
final GamePanel panel = GamePanel.getInstance();
panel.removeLoader();
panel.setContext(this);
gameApplet.setSize(765, 503);
java.util.Timer t = new java.util.Timer();
t.schedule(new TimerTask() {
@Override
public void run() {
gameApplet.setBounds(0, 0, 765, 503);
}
}, 1000);
Core.verbose("Initializing mouse...");
serverProvider.initMouse();
Core.verbose("Done.");
Core.verbose("Initializing keyboard...");
serverProvider.initKeyboard();
Core.verbose("Done.");
}
/** /**
* Gets the server prodiver belonging to this context * Sets the mouse
* *
* @return server provider * @param mouse
*/ */
public ServerProvider getServerProvider() { public void setMouse(final Mouse mouse) {
return serverProvider; this.mouse = mouse;
} }
/** /**
* Gets class loader of server from this context * Gets the mouse
* *
* @return class loader * @return mouse
*/ */
public ASMClassLoader getASMClassLoader() { public Mouse getMouse() {
return classLoader; return mouse;
} }
/**
* Gets the id of this context
*
* @return id context
*/
public static int getID() {
return id;
}
/** /**
* Tab id of this context * Sets the keyboard
* *
* @return tab id of this context * @param keyboard
*/ */
public int getTab() { public void setKeyboard(final Keyboard keyboard) {
return tab; this.keyboard = keyboard;
} }
/** /**
* Adds a paintable instance to the paintables * Gets the keyboard
* *
* @param paintable * @return keyboard
*/ */
public void addPaintable(Paintable paintable) { public Keyboard getKeyboard() {
paintables.add(paintable); return keyboard;
} }
/** /**
* Removes a paintable instance from the paintables * ClassPath
* *
* @param paintable * @return classpath
*/ */
public void removePaintable(Paintable paintable) { public ClassPath getClassPath() {
paintables.remove(paintable); return classPath;
} }
/** /**
* Gets the paintable instances * Determines if applet has been set
* *
* @return array of paintable instances * @return <b>true</b> if set
*/ */
public Paintable[] getPaintables() { public boolean appletSet() {
return paintables.toArray(new Paintable[paintables.size()]); return gameApplet != null;
} }
/** /**
* The client debug painter * Gets game applet
* *
* @return debug painter * @return applet
*/ */
public PaintDebugger getPaintDebugger() { public Applet getApplet() {
return paintDebugger; return gameApplet;
} }
/** /**
* Gets the main/client instance * Loads the game
* */
* @return instance of the the client public void load() {
*/ Core.verbose("Parsing server jar...");
public Object getClient() { serverProvider.parseJar();
return this.clientInstance; Core.verbose("Done.");
} Core.verbose("Injecting hooks...");
serverProvider.injectHooks();
/** Core.verbose("Done.");
* Gets the hook parser, may be null if injection is not used or a custom hook parser is used for injecting Core.verbose("Fetching game applet...");
* @return hook parser ;
*/ gameApplet = serverProvider.fetchApplet();
public HookParser getHookParser() { if (getClient() == null) {
return hookParser; setClientInstance(gameApplet);
} }
Core.verbose("Applet fetched.");
/** serverProvider.addMenuItems(BotUI.getInstance().getJMenuBar());
* Sets the current running script, if a script stops it will call this method with a null argument BotUI.getInstance().validate();
* @param script final GamePanel panel = GamePanel.getInstance();
*/ panel.removeLoader();
public void setRunningScript(final Script script) { panel.setContext(this);
this.runningScript = script; gameApplet.setSize(765, 503);
} java.util.Timer t = new java.util.Timer();
t.schedule(new TimerTask() {
/** @Override
* Gets the current running script public void run() {
* @return script gameApplet.setBounds(0, 0, 765, 503);
*/ }
public Script getRunningScript() { }, 1000);
return this.runningScript; Core.verbose("Initializing mouse...");
} serverProvider.initMouse();
Core.verbose("Done.");
Core.verbose("Initializing keyboard...");
serverProvider.initKeyboard();
Core.verbose("Done.");
}
/**
* Gets the server prodiver belonging to this context
*
* @return server provider
*/
public ServerProvider getServerProvider() {
return serverProvider;
}
/**
* Gets class loader of server from this context
*
* @return class loader
*/
public ASMClassLoader getASMClassLoader() {
return classLoader;
}
/**
* Gets the id of this context
*
* @return id context
*/
public static int getID() {
return id;
}
/**
* Tab id of this context
*
* @return tab id of this context
*/
public int getTab() {
return tab;
}
/**
* Adds a paintable instance to the paintables
*
* @param paintable
*/
public void addPaintable(Paintable paintable) {
paintables.add(paintable);
}
/**
* Removes a paintable instance from the paintables
*
* @param paintable
*/
public void removePaintable(Paintable paintable) {
paintables.remove(paintable);
}
/**
* Gets the paintable instances
*
* @return array of paintable instances
*/
public Paintable[] getPaintables() {
return paintables.toArray(new Paintable[paintables.size()]);
}
/**
* The client debug painter
*
* @return debug painter
*/
public PaintDebugger getPaintDebugger() {
return paintDebugger;
}
/**
* Gets the main/client instance
*
* @return instance of the the client
*/
public Object getClient() {
return this.clientInstance;
}
/**
* Gets the hook parser, may be null if injection is not used or a custom hook parser is used for injecting
*
* @return hook parser
*/
public HookParser getHookParser() {
return hookParser;
}
/**
* Sets the current running script, if a script stops it will call this method with a null argument
*
* @param script
*/
public void setRunningScript(final Script script) {
this.runningScript = script;
}
/**
* Gets the current running script
*
* @return script
*/
public Script getRunningScript() {
return this.runningScript;
}
} }