mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 00:37:55 +00:00
Merge branch 'development' into cleanup/github
This commit is contained in:
@@ -32,11 +32,11 @@ import java.util.TimerTask;
|
|||||||
* @author Everel, JKetelaar, Matt
|
* @author Everel, JKetelaar, Matt
|
||||||
*/
|
*/
|
||||||
public class Context {
|
public class Context {
|
||||||
public static final HashMap<ThreadGroup, Context> threadGroups = new HashMap<ThreadGroup, Context>();
|
public static final HashMap<ThreadGroup, Context> threadGroups = new HashMap<>();
|
||||||
private static ArrayList<Paintable> paintables = new ArrayList<Paintable>();
|
|
||||||
|
|
||||||
private static Context instance;
|
private static ArrayList<Paintable> paintables = new ArrayList<>();
|
||||||
private static String username;
|
private static Context instance;
|
||||||
|
private static String username;
|
||||||
|
|
||||||
private ASMClassLoader classLoader;
|
private ASMClassLoader classLoader;
|
||||||
private ClassPath classPath;
|
private ClassPath classPath;
|
||||||
@@ -52,38 +52,58 @@ public class Context {
|
|||||||
private PBKeyListener pbKeyListener;
|
private PBKeyListener pbKeyListener;
|
||||||
private ServerProviderInfo providerInfo;
|
private ServerProviderInfo providerInfo;
|
||||||
private JSONParser jsonParser;
|
private JSONParser jsonParser;
|
||||||
|
private PrintStream defaultOut;
|
||||||
private PrintStream defaultOut;
|
private PrintStream defaultErr;
|
||||||
private PrintStream defaultErr = System.err;
|
|
||||||
|
|
||||||
private Context(final ServerProvider serverProvider) {
|
private Context(final ServerProvider serverProvider) {
|
||||||
threadGroups.put(Thread.currentThread().getThreadGroup(), this);
|
threadGroups.put(Thread.currentThread().getThreadGroup(), this);
|
||||||
|
|
||||||
System.setProperty("sun.java.command", "");
|
System.setProperty("sun.java.command", "");
|
||||||
|
|
||||||
this.serverProvider = serverProvider;
|
this.serverProvider = serverProvider;
|
||||||
this.paintDebugger = new PaintDebugger();
|
this.paintDebugger = new PaintDebugger();
|
||||||
this.classPath = new ClassPath();
|
this.classPath = new ClassPath();
|
||||||
this.classLoader = new ASMClassLoader(classPath);
|
this.classLoader = new ASMClassLoader(classPath);
|
||||||
this.randomHandler = new RandomHandler();
|
this.randomHandler = new RandomHandler();
|
||||||
|
|
||||||
this.jsonParser = new JSONParser();
|
this.jsonParser = new JSONParser();
|
||||||
|
|
||||||
this.defaultOut = System.out;
|
this.defaultOut = System.out;
|
||||||
this.defaultErr = System.err;
|
this.defaultErr = System.err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the instance of this class, based on a given ServerProvider
|
||||||
|
*
|
||||||
|
* @param serverProvider
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static Context getInstance(ServerProvider serverProvider) {
|
public static Context getInstance(ServerProvider serverProvider) {
|
||||||
return instance == null ? instance = new Context(serverProvider) : instance;
|
return instance == null ? instance = new Context(serverProvider) : instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the instance of this class
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static Context getInstance() {
|
public static Context getInstance() {
|
||||||
return getInstance(null);
|
return getInstance(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the username of the current logged in user to Parabot
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static String getUsername() {
|
public static String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the username for the logged in user to Parabot
|
||||||
|
*
|
||||||
|
* @param username
|
||||||
|
*/
|
||||||
public static void setUsername(String username) {
|
public static void setUsername(String username) {
|
||||||
Context.username = username;
|
Context.username = username;
|
||||||
}
|
}
|
||||||
@@ -234,7 +254,8 @@ public class Context {
|
|||||||
Core.verbose(TranslationHelper.translate("DONE"));
|
Core.verbose(TranslationHelper.translate("DONE"));
|
||||||
}
|
}
|
||||||
Applet applet = serverProvider.fetchApplet();
|
Applet applet = serverProvider.fetchApplet();
|
||||||
// if applet is null the server provider will call setApplet itself
|
|
||||||
|
// If applet is null the server provider will call setApplet itself
|
||||||
if (applet != null) {
|
if (applet != null) {
|
||||||
setApplet(applet);
|
setApplet(applet);
|
||||||
}
|
}
|
||||||
@@ -367,10 +388,20 @@ public class Context {
|
|||||||
return this.randomHandler;
|
return this.randomHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the JSON Parser instance
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public JSONParser getJsonParser() {
|
public JSONParser getJsonParser() {
|
||||||
return jsonParser;
|
return jsonParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the PBKeyListener instance
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public PBKeyListener getPbKeyListener() {
|
public PBKeyListener getPbKeyListener() {
|
||||||
return pbKeyListener;
|
return pbKeyListener;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user