mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-06 08:39:33 +00:00
Fixed some formats
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 Mouse mouse = null;
|
||||||
private Keyboard keyboard = null;
|
private Keyboard keyboard = null;
|
||||||
|
|
||||||
public Context(final ServerProvider serverProvider) {
|
public Context(final ServerProvider serverProvider) {
|
||||||
threadGroups.put(Thread.currentThread().getThreadGroup(), this);
|
threadGroups.put(Thread.currentThread().getThreadGroup(), this);
|
||||||
tab = id;
|
tab = id;
|
||||||
this.serverProvider = serverProvider;
|
this.serverProvider = serverProvider;
|
||||||
id++;
|
id++;
|
||||||
this.classPath = new ClassPath();
|
this.classPath = new ClassPath();
|
||||||
classLoader = new ASMClassLoader(classPath);
|
classLoader = new ASMClassLoader(classPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves the context from threadgroup
|
* Resolves the context from threadgroup
|
||||||
*
|
*
|
||||||
* @return context
|
* @return context
|
||||||
*/
|
*/
|
||||||
public static Context resolve() {
|
public static Context resolve() {
|
||||||
return threadGroups.get(Thread.currentThread().getThreadGroup());
|
return threadGroups.get(Thread.currentThread().getThreadGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Context currentTab() {
|
public static Context currentTab() {
|
||||||
// TODO
|
// TODO
|
||||||
return threadGroups.values().iterator().next();
|
return threadGroups.values().iterator().next();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnvironment() {
|
public void setEnvironment() {
|
||||||
classLoader = new ASMClassLoader(classPath);
|
classLoader = new ASMClassLoader(classPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the main client instance
|
* Sets the main client instance
|
||||||
*/
|
*/
|
||||||
public void setClientInstance(Object object) {
|
public void setClientInstance(Object object) {
|
||||||
this.clientInstance = object;
|
this.clientInstance = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the hook parser
|
* Sets the hook parser
|
||||||
* @param hookParser
|
*
|
||||||
*/
|
* @param hookParser
|
||||||
public void setHookParser(final HookParser hookParser) {
|
*/
|
||||||
this.hookParser = hookParser;
|
public void setHookParser(final HookParser hookParser) {
|
||||||
}
|
this.hookParser = hookParser;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the mouse
|
* Sets the mouse
|
||||||
* @param mouse
|
*
|
||||||
*/
|
* @param mouse
|
||||||
public void setMouse(final Mouse mouse) {
|
*/
|
||||||
this.mouse = mouse;
|
public void setMouse(final Mouse mouse) {
|
||||||
}
|
this.mouse = mouse;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the mouse
|
* Gets the mouse
|
||||||
* @return mouse
|
*
|
||||||
*/
|
* @return mouse
|
||||||
public Mouse getMouse() {
|
*/
|
||||||
return mouse;
|
public Mouse getMouse() {
|
||||||
}
|
return mouse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the keyboard
|
* Sets the keyboard
|
||||||
* @param keyboard
|
*
|
||||||
*/
|
* @param keyboard
|
||||||
public void setKeyboard(final Keyboard keyboard) {
|
*/
|
||||||
this.keyboard = keyboard;
|
public void setKeyboard(final Keyboard keyboard) {
|
||||||
}
|
this.keyboard = keyboard;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the keyboard
|
* Gets the keyboard
|
||||||
* @return keyboard
|
*
|
||||||
*/
|
* @return keyboard
|
||||||
public Keyboard getKeyboard() {
|
*/
|
||||||
return keyboard;
|
public Keyboard getKeyboard() {
|
||||||
}
|
return keyboard;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClassPath
|
* ClassPath
|
||||||
*
|
*
|
||||||
* @return classpath
|
* @return classpath
|
||||||
*/
|
*/
|
||||||
public ClassPath getClassPath() {
|
public ClassPath getClassPath() {
|
||||||
return classPath;
|
return classPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if applet has been set
|
* Determines if applet has been set
|
||||||
*
|
*
|
||||||
* @return <b>true</b> if set
|
* @return <b>true</b> if set
|
||||||
*/
|
*/
|
||||||
public boolean appletSet() {
|
public boolean appletSet() {
|
||||||
return gameApplet != null;
|
return gameApplet != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets game applet
|
* Gets game applet
|
||||||
*
|
*
|
||||||
* @return applet
|
* @return applet
|
||||||
*/
|
*/
|
||||||
public Applet getApplet() {
|
public Applet getApplet() {
|
||||||
return gameApplet;
|
return gameApplet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the game
|
* Loads the game
|
||||||
*/
|
*/
|
||||||
public void load() {
|
public void load() {
|
||||||
Core.verbose("Parsing server jar...");
|
Core.verbose("Parsing server jar...");
|
||||||
serverProvider.parseJar();
|
serverProvider.parseJar();
|
||||||
Core.verbose("Done.");
|
Core.verbose("Done.");
|
||||||
Core.verbose("Injecting hooks...");
|
Core.verbose("Injecting hooks...");
|
||||||
serverProvider.injectHooks();
|
serverProvider.injectHooks();
|
||||||
Core.verbose("Done.");
|
Core.verbose("Done.");
|
||||||
Core.verbose("Fetching game applet...");;
|
Core.verbose("Fetching game applet...");
|
||||||
gameApplet = serverProvider.fetchApplet();
|
;
|
||||||
if (getClient() == null) {
|
gameApplet = serverProvider.fetchApplet();
|
||||||
setClientInstance(gameApplet);
|
if (getClient() == null) {
|
||||||
}
|
setClientInstance(gameApplet);
|
||||||
Core.verbose("Applet fetched.");
|
}
|
||||||
serverProvider.addMenuItems(BotUI.getInstance().getJMenuBar());
|
Core.verbose("Applet fetched.");
|
||||||
BotUI.getInstance().validate();
|
serverProvider.addMenuItems(BotUI.getInstance().getJMenuBar());
|
||||||
final GamePanel panel = GamePanel.getInstance();
|
BotUI.getInstance().validate();
|
||||||
panel.removeLoader();
|
final GamePanel panel = GamePanel.getInstance();
|
||||||
panel.setContext(this);
|
panel.removeLoader();
|
||||||
gameApplet.setSize(765, 503);
|
panel.setContext(this);
|
||||||
java.util.Timer t = new java.util.Timer();
|
gameApplet.setSize(765, 503);
|
||||||
t.schedule(new TimerTask() {
|
java.util.Timer t = new java.util.Timer();
|
||||||
@Override
|
t.schedule(new TimerTask() {
|
||||||
public void run() {
|
@Override
|
||||||
gameApplet.setBounds(0, 0, 765, 503);
|
public void run() {
|
||||||
}
|
gameApplet.setBounds(0, 0, 765, 503);
|
||||||
}, 1000);
|
}
|
||||||
Core.verbose("Initializing mouse...");
|
}, 1000);
|
||||||
serverProvider.initMouse();
|
Core.verbose("Initializing mouse...");
|
||||||
Core.verbose("Done.");
|
serverProvider.initMouse();
|
||||||
Core.verbose("Initializing keyboard...");
|
Core.verbose("Done.");
|
||||||
serverProvider.initKeyboard();
|
Core.verbose("Initializing keyboard...");
|
||||||
Core.verbose("Done.");
|
serverProvider.initKeyboard();
|
||||||
}
|
Core.verbose("Done.");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the server prodiver belonging to this context
|
* Gets the server prodiver belonging to this context
|
||||||
*
|
*
|
||||||
* @return server provider
|
* @return server provider
|
||||||
*/
|
*/
|
||||||
public ServerProvider getServerProvider() {
|
public ServerProvider getServerProvider() {
|
||||||
return serverProvider;
|
return serverProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets class loader of server from this context
|
* Gets class loader of server from this context
|
||||||
*
|
*
|
||||||
* @return class loader
|
* @return class loader
|
||||||
*/
|
*/
|
||||||
public ASMClassLoader getASMClassLoader() {
|
public ASMClassLoader getASMClassLoader() {
|
||||||
return classLoader;
|
return classLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the id of this context
|
* Gets the id of this context
|
||||||
*
|
*
|
||||||
* @return id context
|
* @return id context
|
||||||
*/
|
*/
|
||||||
public static int getID() {
|
public static int getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tab id of this context
|
* Tab id of this context
|
||||||
*
|
*
|
||||||
* @return tab id of this context
|
* @return tab id of this context
|
||||||
*/
|
*/
|
||||||
public int getTab() {
|
public int getTab() {
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a paintable instance to the paintables
|
* Adds a paintable instance to the paintables
|
||||||
*
|
*
|
||||||
* @param paintable
|
* @param paintable
|
||||||
*/
|
*/
|
||||||
public void addPaintable(Paintable paintable) {
|
public void addPaintable(Paintable paintable) {
|
||||||
paintables.add(paintable);
|
paintables.add(paintable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a paintable instance from the paintables
|
* Removes a paintable instance from the paintables
|
||||||
*
|
*
|
||||||
* @param paintable
|
* @param paintable
|
||||||
*/
|
*/
|
||||||
public void removePaintable(Paintable paintable) {
|
public void removePaintable(Paintable paintable) {
|
||||||
paintables.remove(paintable);
|
paintables.remove(paintable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the paintable instances
|
* Gets the paintable instances
|
||||||
*
|
*
|
||||||
* @return array of paintable instances
|
* @return array of paintable instances
|
||||||
*/
|
*/
|
||||||
public Paintable[] getPaintables() {
|
public Paintable[] getPaintables() {
|
||||||
return paintables.toArray(new Paintable[paintables.size()]);
|
return paintables.toArray(new Paintable[paintables.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client debug painter
|
* The client debug painter
|
||||||
*
|
*
|
||||||
* @return debug painter
|
* @return debug painter
|
||||||
*/
|
*/
|
||||||
public PaintDebugger getPaintDebugger() {
|
public PaintDebugger getPaintDebugger() {
|
||||||
return paintDebugger;
|
return paintDebugger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the main/client instance
|
* Gets the main/client instance
|
||||||
*
|
*
|
||||||
* @return instance of the the client
|
* @return instance of the the client
|
||||||
*/
|
*/
|
||||||
public Object getClient() {
|
public Object getClient() {
|
||||||
return this.clientInstance;
|
return this.clientInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the hook parser, may be null if injection is not used or a custom hook parser is used for injecting
|
* Gets the hook parser, may be null if injection is not used or a custom hook parser is used for injecting
|
||||||
* @return hook parser
|
*
|
||||||
*/
|
* @return hook parser
|
||||||
public HookParser getHookParser() {
|
*/
|
||||||
return hookParser;
|
public HookParser getHookParser() {
|
||||||
}
|
return hookParser;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current running script, if a script stops it will call this method with a null argument
|
* Sets the current running script, if a script stops it will call this method with a null argument
|
||||||
* @param script
|
*
|
||||||
*/
|
* @param script
|
||||||
public void setRunningScript(final Script script) {
|
*/
|
||||||
this.runningScript = script;
|
public void setRunningScript(final Script script) {
|
||||||
}
|
this.runningScript = script;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current running script
|
* Gets the current running script
|
||||||
* @return script
|
*
|
||||||
*/
|
* @return script
|
||||||
public Script getRunningScript() {
|
*/
|
||||||
return this.runningScript;
|
public Script getRunningScript() {
|
||||||
}
|
return this.runningScript;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user