mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 00:37:55 +00:00
Fixed some formats
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
package org.parabot.core;
|
||||
|
||||
/**
|
||||
*
|
||||
* Holds some important constants
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
* @author Everel
|
||||
*/
|
||||
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 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_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_BOT_VERSION = "http://bot.parabot.org/version.txt";
|
||||
|
||||
public static final double BOT_VERSION = 2.04; // BETA
|
||||
|
||||
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 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_PROVIDER = "http://sdn.parabot.org/providers/%s";
|
||||
public static final String GET_BOT_VERSION = "http://bot.parabot.org/version.txt";
|
||||
|
||||
public static final double BOT_VERSION = 2.04; // BETA
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
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.classpath.ClassPath;
|
||||
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.servers.ServerProvider;
|
||||
|
||||
import java.applet.Applet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* Game context
|
||||
*
|
||||
*
|
||||
* @author Everel
|
||||
*
|
||||
*/
|
||||
public class Context {
|
||||
public static HashMap<ThreadGroup, Context> threadGroups = new HashMap<ThreadGroup, Context>();
|
||||
private static int id = 1;
|
||||
public static HashMap<ThreadGroup, Context> threadGroups = new HashMap<ThreadGroup, Context>();
|
||||
private static int id = 1;
|
||||
|
||||
private ASMClassLoader classLoader = null;
|
||||
private ClassPath classPath = null;
|
||||
private ServerProvider serverProvider = null;
|
||||
private int tab = 0;
|
||||
private Applet gameApplet = null;
|
||||
private HookParser hookParser = null;
|
||||
private Script runningScript = null;
|
||||
private ASMClassLoader classLoader = null;
|
||||
private ClassPath classPath = null;
|
||||
private ServerProvider serverProvider = null;
|
||||
private int tab = 0;
|
||||
private Applet gameApplet = null;
|
||||
private HookParser hookParser = 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;
|
||||
|
||||
private Mouse mouse = null;
|
||||
private Keyboard keyboard = null;
|
||||
public boolean added = false;
|
||||
|
||||
public Context(final ServerProvider serverProvider) {
|
||||
threadGroups.put(Thread.currentThread().getThreadGroup(), this);
|
||||
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();
|
||||
}
|
||||
private Mouse mouse = null;
|
||||
private Keyboard keyboard = null;
|
||||
|
||||
public void setEnvironment() {
|
||||
classLoader = new ASMClassLoader(classPath);
|
||||
}
|
||||
public Context(final ServerProvider serverProvider) {
|
||||
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
|
||||
*/
|
||||
public void setClientInstance(Object object) {
|
||||
this.clientInstance = object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* Resolves the context from threadgroup
|
||||
*
|
||||
* @return context
|
||||
*/
|
||||
public static Context resolve() {
|
||||
return threadGroups.get(Thread.currentThread().getThreadGroup());
|
||||
}
|
||||
|
||||
/**
|
||||
* ClassPath
|
||||
*
|
||||
* @return classpath
|
||||
*/
|
||||
public ClassPath getClassPath() {
|
||||
return classPath;
|
||||
}
|
||||
public static Context currentTab() {
|
||||
// TODO
|
||||
return threadGroups.values().iterator().next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if applet has been set
|
||||
*
|
||||
* @return <b>true</b> if set
|
||||
*/
|
||||
public boolean appletSet() {
|
||||
return gameApplet != null;
|
||||
}
|
||||
public void setEnvironment() {
|
||||
classLoader = new ASMClassLoader(classPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets game applet
|
||||
*
|
||||
* @return applet
|
||||
*/
|
||||
public Applet getApplet() {
|
||||
return gameApplet;
|
||||
}
|
||||
/**
|
||||
* Sets the main client instance
|
||||
*/
|
||||
public void setClientInstance(Object object) {
|
||||
this.clientInstance = object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the game
|
||||
*/
|
||||
public void load() {
|
||||
Core.verbose("Parsing server jar...");
|
||||
serverProvider.parseJar();
|
||||
Core.verbose("Done.");
|
||||
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.");
|
||||
}
|
||||
/**
|
||||
* Sets the hook parser
|
||||
*
|
||||
* @param hookParser
|
||||
*/
|
||||
public void setHookParser(final HookParser hookParser) {
|
||||
this.hookParser = hookParser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server prodiver belonging to this context
|
||||
*
|
||||
* @return server provider
|
||||
*/
|
||||
public ServerProvider getServerProvider() {
|
||||
return serverProvider;
|
||||
}
|
||||
/**
|
||||
* Sets the mouse
|
||||
*
|
||||
* @param mouse
|
||||
*/
|
||||
public void setMouse(final Mouse mouse) {
|
||||
this.mouse = mouse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets class loader of server from this context
|
||||
*
|
||||
* @return class loader
|
||||
*/
|
||||
public ASMClassLoader getASMClassLoader() {
|
||||
return classLoader;
|
||||
}
|
||||
/**
|
||||
* Gets the mouse
|
||||
*
|
||||
* @return mouse
|
||||
*/
|
||||
public Mouse getMouse() {
|
||||
return mouse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* Sets the keyboard
|
||||
*
|
||||
* @param keyboard
|
||||
*/
|
||||
public void setKeyboard(final Keyboard keyboard) {
|
||||
this.keyboard = keyboard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a paintable instance to the paintables
|
||||
*
|
||||
* @param paintable
|
||||
*/
|
||||
public void addPaintable(Paintable paintable) {
|
||||
paintables.add(paintable);
|
||||
}
|
||||
/**
|
||||
* Gets the keyboard
|
||||
*
|
||||
* @return keyboard
|
||||
*/
|
||||
public Keyboard getKeyboard() {
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a paintable instance from the paintables
|
||||
*
|
||||
* @param paintable
|
||||
*/
|
||||
public void removePaintable(Paintable paintable) {
|
||||
paintables.remove(paintable);
|
||||
}
|
||||
/**
|
||||
* ClassPath
|
||||
*
|
||||
* @return classpath
|
||||
*/
|
||||
public ClassPath getClassPath() {
|
||||
return classPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the paintable instances
|
||||
*
|
||||
* @return array of paintable instances
|
||||
*/
|
||||
public Paintable[] getPaintables() {
|
||||
return paintables.toArray(new Paintable[paintables.size()]);
|
||||
}
|
||||
/**
|
||||
* Determines if applet has been set
|
||||
*
|
||||
* @return <b>true</b> if set
|
||||
*/
|
||||
public boolean appletSet() {
|
||||
return gameApplet != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The client debug painter
|
||||
*
|
||||
* @return debug painter
|
||||
*/
|
||||
public PaintDebugger getPaintDebugger() {
|
||||
return paintDebugger;
|
||||
}
|
||||
/**
|
||||
* Gets game applet
|
||||
*
|
||||
* @return applet
|
||||
*/
|
||||
public Applet getApplet() {
|
||||
return gameApplet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* Loads the game
|
||||
*/
|
||||
public void load() {
|
||||
Core.verbose("Parsing server jar...");
|
||||
serverProvider.parseJar();
|
||||
Core.verbose("Done.");
|
||||
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
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user