mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-02 16:49:10 +00:00
Merge branch 'development' into various-fixes
This commit is contained in:
@@ -73,7 +73,7 @@
|
||||
<dependency>
|
||||
<groupId>org.parabot</groupId>
|
||||
<artifactId>internal-api</artifactId>
|
||||
<version>1.51.1</version>
|
||||
<version>1.52.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ import java.util.TimerTask;
|
||||
* @author Everel, JKetelaar, Matt
|
||||
*/
|
||||
public class Context {
|
||||
public static final HashMap<ThreadGroup, Context> threadGroups = new HashMap<ThreadGroup, Context>();
|
||||
private static ArrayList<Paintable> paintables = new ArrayList<Paintable>();
|
||||
public static final HashMap<ThreadGroup, Context> threadGroups = new HashMap<>();
|
||||
|
||||
private static Context instance;
|
||||
private static String username;
|
||||
private static ArrayList<Paintable> paintables = new ArrayList<>();
|
||||
private static Context instance;
|
||||
private static String username;
|
||||
|
||||
private ASMClassLoader classLoader;
|
||||
private ClassPath classPath;
|
||||
@@ -52,38 +52,58 @@ public class Context {
|
||||
private PBKeyListener pbKeyListener;
|
||||
private ServerProviderInfo providerInfo;
|
||||
private JSONParser jsonParser;
|
||||
|
||||
private PrintStream defaultOut;
|
||||
private PrintStream defaultErr = System.err;
|
||||
private PrintStream defaultOut;
|
||||
private PrintStream defaultErr;
|
||||
|
||||
private Context(final ServerProvider serverProvider) {
|
||||
threadGroups.put(Thread.currentThread().getThreadGroup(), this);
|
||||
|
||||
System.setProperty("sun.java.command", "");
|
||||
|
||||
this.serverProvider = serverProvider;
|
||||
this.paintDebugger = new PaintDebugger();
|
||||
this.classPath = new ClassPath();
|
||||
this.classLoader = new ASMClassLoader(classPath);
|
||||
this.randomHandler = new RandomHandler();
|
||||
|
||||
this.jsonParser = new JSONParser();
|
||||
|
||||
this.defaultOut = System.out;
|
||||
this.defaultErr = System.err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the instance of this class, based on a given ServerProvider
|
||||
*
|
||||
* @param serverProvider
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Context getInstance(ServerProvider serverProvider) {
|
||||
return instance == null ? instance = new Context(serverProvider) : instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the instance of this class
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Context getInstance() {
|
||||
return getInstance(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the username of the current logged in user to Parabot
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username for the logged in user to Parabot
|
||||
*
|
||||
* @param username
|
||||
*/
|
||||
public static void setUsername(String username) {
|
||||
Context.username = username;
|
||||
}
|
||||
@@ -234,7 +254,8 @@ public class Context {
|
||||
Core.verbose(TranslationHelper.translate("DONE"));
|
||||
}
|
||||
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) {
|
||||
setApplet(applet);
|
||||
}
|
||||
@@ -367,10 +388,20 @@ public class Context {
|
||||
return this.randomHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the JSON Parser instance
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public JSONParser getJsonParser() {
|
||||
return jsonParser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the PBKeyListener instance
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PBKeyListener getPbKeyListener() {
|
||||
return pbKeyListener;
|
||||
}
|
||||
|
||||
@@ -13,4 +13,19 @@ public class NoProgressListener implements ProgressListener {
|
||||
public void updateDownloadSpeed(double mbPerSecond) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMessage(String message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMessageAndProgress(String message, double progress) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCurrentProgress() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,4 +275,20 @@ public class VerboseLoader extends JPanel implements ProgressListener {
|
||||
public void updateDownloadSpeed(double mbPerSecond) {
|
||||
progressBar.setText(String.format("(%.2fMB/s)", mbPerSecond));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMessage(String message) {
|
||||
VerboseLoader.setState(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMessageAndProgress(String message, double progress) {
|
||||
VerboseLoader.setState(message);
|
||||
onProgressUpdate(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCurrentProgress() {
|
||||
return progressBar.getValue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user