mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 00:38:16 +00:00
Get rid of threadgroups
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package org.parabot.environment;
|
||||
|
||||
import org.parabot.core.Context;
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.desc.ServerDescription;
|
||||
import org.parabot.core.jython.Jython;
|
||||
@@ -35,10 +34,7 @@ public class Environment {
|
||||
|
||||
Core.verbose("Loading server: " + desc.toString());
|
||||
|
||||
final String id = "tab" + Context.getID();
|
||||
final ThreadGroup bot = new ThreadGroup(id);
|
||||
|
||||
ServerParser.SERVER_CACHE.get(desc).run(bot);
|
||||
ServerParser.SERVER_CACHE.get(desc).run();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Keyboard implements KeyListener {
|
||||
}
|
||||
|
||||
public static Keyboard getInstance() {
|
||||
return Context.resolve().getKeyboard();
|
||||
return Context.getInstance().getKeyboard();
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Mouse implements MouseListener, MouseMotionListener {
|
||||
}
|
||||
|
||||
public static Mouse getInstance() {
|
||||
return Context.resolve().getMouse();
|
||||
return Context.getInstance().getMouse();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,7 @@ public class Script implements Runnable {
|
||||
|
||||
@Override
|
||||
public final void run() {
|
||||
Context context = Context.resolve();
|
||||
Context context = Context.getInstance();
|
||||
|
||||
Core.verbose("Initializing script...");
|
||||
context.getServerProvider().initScript(this);
|
||||
@@ -70,7 +70,7 @@ public class Script implements Runnable {
|
||||
|
||||
if(!onExecute()) {
|
||||
Core.verbose("Script#onExecute returned false, unloading and stopping script...");
|
||||
Context.resolve().getServerProvider().unloadScript(this);
|
||||
context.getServerProvider().unloadScript(this);
|
||||
this.state = STATE_STOPPED;
|
||||
Core.verbose("Done.");
|
||||
return;
|
||||
@@ -113,9 +113,9 @@ public class Script implements Runnable {
|
||||
Core.verbose("Script stopped/finished, unloading and stopping...");
|
||||
onFinish();
|
||||
LogArea.log("Script stopped.");
|
||||
Context.resolve().getServerProvider().unloadScript(this);
|
||||
context.getServerProvider().unloadScript(this);
|
||||
this.state = STATE_STOPPED;
|
||||
Context.resolve().setRunningScript(null);
|
||||
context.setRunningScript(null);
|
||||
BotToolbar.getInstance().toggleRun();
|
||||
Core.verbose("Done.");
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class LocalServerExecuter extends ServerExecuter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ThreadGroup tg) {
|
||||
public void run() {
|
||||
// add jar or directory to buildpath.
|
||||
if (this.classPath.isJar()) {
|
||||
Core.verbose("Adding server provider jar to buildpath: "
|
||||
@@ -43,7 +43,7 @@ public class LocalServerExecuter extends ServerExecuter {
|
||||
}
|
||||
}
|
||||
// finalize
|
||||
super.finalize(tg, this.serverProvider, this.serverName);
|
||||
super.finalize(this.serverProvider, this.serverName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class PublicServerExecuter extends ServerExecuter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ThreadGroup tg) {
|
||||
public void run() {
|
||||
try {
|
||||
final File destination = new File(Directories.getCachePath(),
|
||||
this.serverID);
|
||||
@@ -86,7 +86,7 @@ public class PublicServerExecuter extends ServerExecuter {
|
||||
final Constructor<?> con = providerClass.getConstructor();
|
||||
final ServerProvider serverProvider = (ServerProvider) con
|
||||
.newInstance();
|
||||
super.finalize(tg, serverProvider, this.serverName);
|
||||
super.finalize(serverProvider, this.serverName);
|
||||
} catch (NoClassDefFoundError ignored) {
|
||||
UILog.log(
|
||||
"Error",
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.parabot.environment.servers;
|
||||
|
||||
import org.parabot.core.Context;
|
||||
import org.parabot.core.ui.components.BotToolbar;
|
||||
import org.parabot.core.ui.components.PaintComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -12,17 +13,17 @@ import org.parabot.core.ui.components.BotToolbar;
|
||||
*/
|
||||
public abstract class ServerExecuter {
|
||||
|
||||
public abstract void run(final ThreadGroup tg);
|
||||
public abstract void run();
|
||||
|
||||
public void finalize(final ThreadGroup tg, final ServerProvider provider, final String serverName) {
|
||||
// loads the server and its it to the gui
|
||||
new Thread(tg, new Runnable() {
|
||||
public void finalize(final ServerProvider provider, final String serverName) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final Context context = new Context(provider);
|
||||
Context context = Context.getInstance(provider);
|
||||
BotToolbar.getInstance().addTab(context, serverName);
|
||||
context.load();
|
||||
PaintComponent.getInstance().startPainting(context.getPaintDebugger());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public abstract class ServerProvider implements Opcodes {
|
||||
for (Injectable inj : injectables) {
|
||||
inj.inject();
|
||||
}
|
||||
Context.resolve().setHookParser(parser);
|
||||
Context.getInstance().setHookParser(parser);
|
||||
}
|
||||
|
||||
private HookFile fetchHookFile() {
|
||||
@@ -106,11 +106,11 @@ public abstract class ServerProvider implements Opcodes {
|
||||
}
|
||||
|
||||
public void setClientInstance(Object client) {
|
||||
Context.resolve().setClientInstance(client);
|
||||
Context.getInstance().setClientInstance(client);
|
||||
}
|
||||
|
||||
public void parseJar() {
|
||||
Context.resolve().getClassPath().addJar(getJar());
|
||||
Context.getInstance().getClassPath().addJar(getJar());
|
||||
}
|
||||
|
||||
public void initScript(Script script) {
|
||||
@@ -122,7 +122,7 @@ public abstract class ServerProvider implements Opcodes {
|
||||
}
|
||||
|
||||
public void initMouse() {
|
||||
final Context context = Context.resolve();
|
||||
final Context context = Context.getInstance();
|
||||
final Applet applet = context.getApplet();
|
||||
final Mouse mouse = new Mouse(applet);
|
||||
applet.addMouseListener(mouse);
|
||||
@@ -131,7 +131,7 @@ public abstract class ServerProvider implements Opcodes {
|
||||
}
|
||||
|
||||
public void initKeyboard() {
|
||||
final Context context = Context.resolve();
|
||||
final Context context = Context.getInstance();
|
||||
final Applet applet = context.getApplet();
|
||||
final Keyboard keyboard = new Keyboard(applet);
|
||||
applet.addKeyListener(keyboard);
|
||||
|
||||
Reference in New Issue
Block a user