mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 00:38:16 +00:00
Merge branch 'development' into feature/expand-progresslistener
This commit is contained in:
@@ -135,6 +135,9 @@ public final class Landing {
|
|||||||
case "-no_validation":
|
case "-no_validation":
|
||||||
Core.disableValidation();
|
Core.disableValidation();
|
||||||
break;
|
break;
|
||||||
|
case "-uuid":
|
||||||
|
Core.setQuickLaunchByUuid(Integer.parseInt(args[++i]));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,9 +185,13 @@ public class Context {
|
|||||||
panel.add(gameApplet);
|
panel.add(gameApplet);
|
||||||
panel.validate();
|
panel.validate();
|
||||||
|
|
||||||
|
serverProvider.preAppletInit();
|
||||||
|
|
||||||
gameApplet.init();
|
gameApplet.init();
|
||||||
gameApplet.start();
|
gameApplet.start();
|
||||||
|
|
||||||
|
serverProvider.postAppletStart();
|
||||||
|
|
||||||
java.util.Timer t = new java.util.Timer();
|
java.util.Timer t = new java.util.Timer();
|
||||||
t.schedule(new TimerTask() {
|
t.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
public class Core {
|
public class Core {
|
||||||
|
|
||||||
private static boolean debug;
|
private static int quickLaunchByUuid = -1; // used like -server, but denoted by an Int rather than the server name
|
||||||
|
private static boolean debug; // in debug mode, we will print more detailed error messages.
|
||||||
private static boolean verbose;
|
private static boolean verbose;
|
||||||
private static boolean dump;
|
private static boolean dump;
|
||||||
private static boolean loadLocal; //Loads both local and public scripts/servers
|
private static boolean loadLocal; //Loads both local and public scripts/servers
|
||||||
@@ -46,6 +47,14 @@ public class Core {
|
|||||||
return validate;
|
return validate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getQuickLaunchByUuid() {
|
||||||
|
return quickLaunchByUuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setQuickLaunchByUuid(int quickLaunchByUuid) {
|
||||||
|
Core.quickLaunchByUuid = quickLaunchByUuid;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enabled loadLocal mode
|
* Enabled loadLocal mode
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -40,17 +40,19 @@ public class AddCallbackAdapter implements Injectable, Opcodes {
|
|||||||
Label l0 = new Label();
|
Label l0 = new Label();
|
||||||
inject.add(new LabelNode(l0));
|
inject.add(new LabelNode(l0));
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for (int arg : args) {
|
if (args != null) {
|
||||||
if (Modifier.isStatic(method.access)) {
|
for (int arg : args) {
|
||||||
int loadOpcode = ASMUtils.getLoadOpcode(types[arg]
|
if (Modifier.isStatic(method.access)) {
|
||||||
.getDescriptor());
|
int loadOpcode = ASMUtils.getLoadOpcode(types[arg]
|
||||||
inject.add(new VarInsnNode(loadOpcode, arg + offset));
|
.getDescriptor());
|
||||||
if (loadOpcode == Opcodes.LLOAD) {
|
inject.add(new VarInsnNode(loadOpcode, arg + offset));
|
||||||
offset++;
|
if (loadOpcode == Opcodes.LLOAD) {
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
inject.add(new VarInsnNode(ASMUtils.getLoadOpcode(types[arg]
|
||||||
|
.getDescriptor()), arg + 1));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
inject.add(new VarInsnNode(ASMUtils.getLoadOpcode(types[arg]
|
|
||||||
.getDescriptor()), arg + 1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inject.add(new MethodInsnNode(INVOKESTATIC,
|
inject.add(new MethodInsnNode(INVOKESTATIC,
|
||||||
|
|||||||
@@ -26,14 +26,16 @@ public class Callback implements Injectable {
|
|||||||
this.invokeMethod = callbackMethod;
|
this.invokeMethod = callbackMethod;
|
||||||
this.desc = callbackDesc;
|
this.desc = callbackDesc;
|
||||||
this.conditional = conditional;
|
this.conditional = conditional;
|
||||||
if (args.contains(",")) {
|
if (args.length() > 0) {
|
||||||
final String[] strArgs = args.split(",");
|
if (args.contains(",")) {
|
||||||
this.args = new int[strArgs.length];
|
final String[] strArgs = args.split(",");
|
||||||
for (int i = 0; i < this.args.length; i++) {
|
this.args = new int[strArgs.length];
|
||||||
this.args[i] = Integer.parseInt(strArgs[i]);
|
for (int i = 0; i < this.args.length; i++) {
|
||||||
|
this.args[i] = Integer.parseInt(strArgs[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.args = new int[]{Integer.parseInt(args)};
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.args = new int[]{ Integer.parseInt(args) };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public class ServerDescription implements Comparable<ServerDescription> {
|
|||||||
private String serverName;
|
private String serverName;
|
||||||
private String author;
|
private String author;
|
||||||
private double revision;
|
private double revision;
|
||||||
|
public int uuid;
|
||||||
|
|
||||||
public ServerDescription(final String serverName, final String author,
|
public ServerDescription(final String serverName, final String author,
|
||||||
final double revision) {
|
final double revision) {
|
||||||
@@ -37,6 +38,9 @@ public class ServerDescription implements Comparable<ServerDescription> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(ServerDescription o) {
|
public int compareTo(ServerDescription o) {
|
||||||
|
if (this.getServerName().equalsIgnoreCase(o.getServerName())) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return this.getServerName().compareTo(o.getServerName());
|
return this.getServerName().compareTo(o.getServerName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,28 @@ public class ServerProviderInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize configuration with data provided by {@link org.parabot.core.parsers.servers.LocalServers} from a {@code /parabot/servers/config.json} file. Also loads the default Settings map from the BDN.
|
||||||
|
* @param clientJar Name of the client jar file
|
||||||
|
* @param hooks Name of the hooks file
|
||||||
|
* @param name Server name
|
||||||
|
* @param clientClass Entry class within the client jar
|
||||||
|
* @param bankTabs Bank tabs - only relevant for certain servers. Default 0
|
||||||
|
*/
|
||||||
public ServerProviderInfo(String clientJar, String hooks, String name, String clientClass, int bankTabs) {
|
public ServerProviderInfo(String clientJar, String hooks, String name, String clientClass, int bankTabs) {
|
||||||
|
this(clientJar, hooks, name, clientClass, bankTabs, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize configuration with data provided by {@link org.parabot.core.parsers.servers.LocalServers} from a {@code /parabot/servers/config.json} file. Also loads the default Settings map from the BDN.
|
||||||
|
* @param clientJar Name of the client jar file
|
||||||
|
* @param hooks Name of the hooks file
|
||||||
|
* @param name Server name
|
||||||
|
* @param clientClass Entry class within the client jar
|
||||||
|
* @param bankTabs Bank tabs - only relevant for certain servers. Default 0
|
||||||
|
* @param randoms A URL to an endpoint where the Randoms are located. Can be Null, in which case getRandoms() will fallback to the default BDN Randoms URL.
|
||||||
|
*/
|
||||||
|
public ServerProviderInfo(String clientJar, String hooks, String name, String clientClass, int bankTabs, String randoms) {
|
||||||
this.properties = new Properties();
|
this.properties = new Properties();
|
||||||
this.settings = new HashMap<>();
|
this.settings = new HashMap<>();
|
||||||
|
|
||||||
@@ -69,6 +90,7 @@ public class ServerProviderInfo {
|
|||||||
this.properties.setProperty("provider_crc32", String.valueOf(getCRC32(name, "provider")));
|
this.properties.setProperty("provider_crc32", String.valueOf(getCRC32(name, "provider")));
|
||||||
this.properties.setProperty("client_crc32", String.valueOf(getCRC32(name, "client")));
|
this.properties.setProperty("client_crc32", String.valueOf(getCRC32(name, "client")));
|
||||||
this.properties.setProperty("bank_tabs", String.valueOf(bankTabs));
|
this.properties.setProperty("bank_tabs", String.valueOf(bankTabs));
|
||||||
|
this.properties.setProperty("randoms_jar", randoms);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getCRC32(String name, String type) {
|
private long getCRC32(String name, String type) {
|
||||||
@@ -141,4 +163,23 @@ public class ServerProviderInfo {
|
|||||||
public HashMap<String, Integer> getSettings() {
|
public HashMap<String, Integer> getSettings() {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the URL to download the Randoms JAR from.
|
||||||
|
* @return The provided URL in the server config JSON (denoted by 'randoms:') or, fallback to the default BDN URL.
|
||||||
|
*/
|
||||||
|
public URL getRandoms() {
|
||||||
|
try {
|
||||||
|
String randomsUrl = properties.getProperty("randoms_jar");
|
||||||
|
if (randomsUrl == null || randomsUrl.length() == 0) {
|
||||||
|
// Fallback to default BDN URL if there is no 'randoms' specified in the server JSON configuration.
|
||||||
|
randomsUrl = Configuration.GET_RANDOMS + (Configuration.BOT_VERSION.isNightly() ? Configuration.NIGHTLY_APPEND : "");
|
||||||
|
}
|
||||||
|
return new URL(randomsUrl);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// Will never return null, unless the BDN URL is changed. It shouldn't be.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,17 @@ public class XMLHookParser extends HookParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final String getValue(String tag, Element element) {
|
private static final String getValue(String tag, Element element) {
|
||||||
|
if (element.getElementsByTagName(tag).item(0) == null) {
|
||||||
|
throw new NullPointerException("MISSING HOOK TAG: The '" + tag + "' xml tag is missing from one of the hooks of type: " + element.getParentNode().getNodeName());
|
||||||
|
}
|
||||||
NodeList nodes = element.getElementsByTagName(tag).item(0)
|
NodeList nodes = element.getElementsByTagName(tag).item(0)
|
||||||
.getChildNodes();
|
.getChildNodes();
|
||||||
|
if (nodes.getLength() == 0 || nodes.item(0) == null) {
|
||||||
|
if (Core.inVerboseMode()) {
|
||||||
|
System.err.println("WARNING: Invalid Hook " + tag + " subnode. Tag is missing or empty?");
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
Node node = (Node) nodes.item(0);
|
Node node = (Node) nodes.item(0);
|
||||||
return node.getNodeValue();
|
return node.getNodeValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
package org.parabot.core.parsers.randoms;
|
package org.parabot.core.parsers.randoms;
|
||||||
|
|
||||||
import org.parabot.api.io.WebUtil;
|
|
||||||
import org.parabot.core.Configuration;
|
|
||||||
import org.parabot.core.Context;
|
|
||||||
import org.parabot.core.Core;
|
|
||||||
import org.parabot.core.Directories;
|
|
||||||
import org.parabot.core.io.NoProgressListener;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
import org.parabot.api.io.WebUtil;
|
||||||
|
import org.parabot.api.output.Logger;
|
||||||
|
import org.parabot.core.Configuration;
|
||||||
|
import org.parabot.core.Context;
|
||||||
|
import org.parabot.core.Core;
|
||||||
|
import org.parabot.core.Directories;
|
||||||
|
import org.parabot.core.io.NoProgressListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JKetelaar
|
* @author JKetelaar
|
||||||
@@ -23,12 +23,21 @@ public class PublicRandoms extends RandomParser {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parse() {
|
public void parse() {
|
||||||
File myJar = new File(Directories.getCachePath() + File.separator + fileName);
|
|
||||||
if (!myJar.exists() || !myJar.canRead()) {
|
final File destination = new File(Directories.getCachePath() + File.separator + fileName);
|
||||||
download();
|
final URL overrideDownload = Context.getInstance().getServerProviderInfo().getRandoms();
|
||||||
|
if (overrideDownload == null) {
|
||||||
|
throw new NullPointerException("Unable to grab URL for Randoms jar. Default URL for BDN randoms must have changed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Core.verbose(String.format("[%s] Destination: %s | dl: %s", getClass().getSimpleName(), destination, overrideDownload));
|
||||||
|
|
||||||
|
if (!destination.exists() || !destination.canRead()) {
|
||||||
|
Core.verbose(String.format("[%s] Missing %s - downloading from %s...", getClass().getSimpleName(), destination.getAbsolutePath(), overrideDownload));
|
||||||
|
download(destination, overrideDownload);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
URL url = myJar.toURI().toURL();
|
URL url = destination.toURI().toURL();
|
||||||
URL[] urls = new URL[]{ url };
|
URL[] urls = new URL[]{ url };
|
||||||
String server = Context.getInstance().getServerProviderInfo().getServerName();
|
String server = Context.getInstance().getServerProviderInfo().getServerName();
|
||||||
|
|
||||||
@@ -36,7 +45,7 @@ public class PublicRandoms extends RandomParser {
|
|||||||
Class<?> classToLoad = Class.forName("org.parabot.randoms.Core", true, child);
|
Class<?> classToLoad = Class.forName("org.parabot.randoms.Core", true, child);
|
||||||
Method method = classToLoad.getDeclaredMethod("init", String.class);
|
Method method = classToLoad.getDeclaredMethod("init", String.class);
|
||||||
Object instance = classToLoad.newInstance();
|
Object instance = classToLoad.newInstance();
|
||||||
System.out.println(server);
|
Core.verbose(String.format("[%s] %s %s", getClass().getSimpleName(), "Initing core Randoms for", server));
|
||||||
method.invoke(instance, server);
|
method.invoke(instance, server);
|
||||||
Core.verbose("Successfully parsed public random!");
|
Core.verbose("Successfully parsed public random!");
|
||||||
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException | ClassNotFoundException | MalformedURLException e) {
|
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException | ClassNotFoundException | MalformedURLException e) {
|
||||||
@@ -45,17 +54,14 @@ public class PublicRandoms extends RandomParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void download() {
|
private void download(final File destination, URL downloadLink) {
|
||||||
try {
|
try {
|
||||||
File random = new File(Directories.getCachePath() + File.separator + fileName);
|
if (destination.exists()) {
|
||||||
if (random.exists()) {
|
|
||||||
Core.verbose("Public random dependency already exists, no need to download it...");
|
Core.verbose("Public random dependency already exists, no need to download it...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String downloadLink = ((Configuration.BOT_VERSION.isNightly()) ? Configuration.GET_RANDOMS + Configuration.NIGHTLY_APPEND : Configuration.GET_RANDOMS);
|
WebUtil.downloadFile(downloadLink, destination, new NoProgressListener());
|
||||||
|
|
||||||
WebUtil.downloadFile(new URL(downloadLink), random, new NoProgressListener());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package org.parabot.core.parsers.servers;
|
package org.parabot.core.parsers.servers;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.ArrayList;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
|
import org.parabot.core.Configuration;
|
||||||
import org.parabot.core.Core;
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.Directories;
|
import org.parabot.core.Directories;
|
||||||
import org.parabot.core.classpath.ClassPath;
|
import org.parabot.core.classpath.ClassPath;
|
||||||
@@ -13,12 +19,6 @@ import org.parabot.environment.servers.executers.LocalPublicServerExecuter;
|
|||||||
import org.parabot.environment.servers.executers.LocalServerExecuter;
|
import org.parabot.environment.servers.executers.LocalServerExecuter;
|
||||||
import org.parabot.environment.servers.loader.ServerLoader;
|
import org.parabot.environment.servers.loader.ServerLoader;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses local server providers located in the servers directory
|
* Parses local server providers located in the servers directory
|
||||||
*
|
*
|
||||||
@@ -86,17 +86,28 @@ public class LocalServers extends ServerParser {
|
|||||||
if ((bank = object.get("bank")) != null) {
|
if ((bank = object.get("bank")) != null) {
|
||||||
bankTabs = (int) bank;
|
bankTabs = (int) bank;
|
||||||
}
|
}
|
||||||
|
String uuidStr = (String) object.get("uuid"); // optional
|
||||||
|
|
||||||
|
|
||||||
JSONObject locations = (JSONObject) object.get("locations");
|
JSONObject locations = (JSONObject) object.get("locations");
|
||||||
String server = (String) locations.get("server");
|
String server = (String) locations.get("server");
|
||||||
String provider = (String) locations.get("provider");
|
String provider = (String) locations.get("provider");
|
||||||
String hooks = (String) locations.get("hooks");
|
String hooks = (String) locations.get("hooks");
|
||||||
|
String randoms = (String) locations.get("randoms");
|
||||||
|
|
||||||
|
if (randoms == null) {
|
||||||
|
randoms = Configuration.GET_RANDOMS + (Configuration.BOT_VERSION.isNightly() ? Configuration.NIGHTLY_APPEND : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
Core.verbose("[LocalServers]: Parsed server: " + name);
|
||||||
|
|
||||||
|
ServerProviderInfo serverProviderInfo = new ServerProviderInfo(server, hooks, name, clientClass, bankTabs, randoms);
|
||||||
|
|
||||||
Core.verbose("[Local server]: " + name);
|
ServerDescription desc = new ServerDescription(name, author, version);
|
||||||
ServerProviderInfo serverProviderInfo = new ServerProviderInfo(server, hooks, name, clientClass, bankTabs);
|
if (uuidStr != null && uuidStr.length() > 0) {
|
||||||
|
desc.uuid = Integer.parseInt(uuidStr);
|
||||||
|
}
|
||||||
|
|
||||||
ServerDescription desc = new ServerDescription(name,
|
|
||||||
author, version);
|
|
||||||
SERVER_CACHE.put(desc, new LocalPublicServerExecuter(name, serverProviderInfo, server, provider));
|
SERVER_CACHE.put(desc, new LocalPublicServerExecuter(name, serverProviderInfo, server, provider));
|
||||||
} catch (IOException | ParseException e) {
|
} catch (IOException | ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.parabot.core.ui;
|
package org.parabot.core.ui;
|
||||||
|
|
||||||
|
import org.parabot.core.Core;
|
||||||
import org.parabot.core.desc.ServerDescription;
|
import org.parabot.core.desc.ServerDescription;
|
||||||
import org.parabot.core.parsers.servers.ServerParser;
|
import org.parabot.core.parsers.servers.ServerParser;
|
||||||
import org.parabot.core.ui.components.ServerComponent;
|
import org.parabot.core.ui.components.ServerComponent;
|
||||||
@@ -23,7 +24,7 @@ public class ServerSelector extends JPanel {
|
|||||||
|
|
||||||
public ServerSelector() {
|
public ServerSelector() {
|
||||||
Queue<ServerComponent> widgets = getServers();
|
Queue<ServerComponent> widgets = getServers();
|
||||||
if (initServer != null) {
|
if (initServer != null || Core.getQuickLaunchByUuid() > -1) {
|
||||||
if (runServer(widgets)) {
|
if (runServer(widgets)) {
|
||||||
initServer = null;
|
initServer = null;
|
||||||
return;
|
return;
|
||||||
@@ -67,7 +68,7 @@ public class ServerSelector extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called when -server argument is given
|
* This method is called when -server argument is given, or -uuid arg is given.
|
||||||
*
|
*
|
||||||
* @param widgets
|
* @param widgets
|
||||||
*/
|
*/
|
||||||
@@ -75,12 +76,25 @@ public class ServerSelector extends JPanel {
|
|||||||
if (widgets == null || widgets.isEmpty()) {
|
if (widgets == null || widgets.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String serverName = initServer.toLowerCase();
|
if (Core.getQuickLaunchByUuid() > -1) { // match the pre-requested server config uuid to quick-launch
|
||||||
for (ServerComponent widget : widgets) {
|
for (ServerComponent widget : widgets) {
|
||||||
if (widget.desc.getServerName().toLowerCase().equals(serverName)) {
|
if (widget.desc.uuid == Core.getQuickLaunchByUuid()) {
|
||||||
Environment.load(widget.desc);
|
Environment.load(widget.desc);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
System.err.println("No server config with -uuid " + Core.getQuickLaunchByUuid() + " was found to quick launch.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (initServer != null) {
|
||||||
|
final String serverName = initServer.toLowerCase(); // match the pre-requested server name to quick-launch
|
||||||
|
for (ServerComponent widget : widgets) {
|
||||||
|
if (widget.desc.getServerName().toLowerCase().equals(serverName)) {
|
||||||
|
Environment.load(widget.desc);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.err.println("No server config with -server " + serverName + " was found to quick launch.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
package org.parabot.environment.scripts;
|
|
||||||
|
|
||||||
import org.parabot.environment.scripts.framework.AbstractFramework;
|
|
||||||
import org.parabot.environment.scripts.framework.LoopTask;
|
|
||||||
import org.parabot.environment.scripts.framework.Strategy;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds various script frameworks
|
|
||||||
*
|
|
||||||
* @author Everel
|
|
||||||
*/
|
|
||||||
public class Frameworks {
|
|
||||||
|
|
||||||
public static Looper getLooper(LoopTask loopTask) {
|
|
||||||
return new Looper(loopTask);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static StrategyWorker getStrategyWorker(Collection<Strategy> strategies) {
|
|
||||||
return new StrategyWorker(strategies);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class Looper extends AbstractFramework {
|
|
||||||
private LoopTask loopTask = null;
|
|
||||||
|
|
||||||
public Looper(LoopTask loopTask) {
|
|
||||||
this.loopTask = loopTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean execute() {
|
|
||||||
int sleepTime = loopTask.loop();
|
|
||||||
if (sleepTime < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Thread.sleep(sleepTime);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class StrategyWorker extends AbstractFramework {
|
|
||||||
private Collection<Strategy> strategies;
|
|
||||||
|
|
||||||
public StrategyWorker(Collection<Strategy> strategies) {
|
|
||||||
this.strategies = strategies;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean execute() {
|
|
||||||
for (Strategy s : strategies) {
|
|
||||||
if (s.activate()) {
|
|
||||||
s.execute();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -146,4 +146,20 @@ public abstract class ServerProvider implements Opcodes {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called in Context.setApplet before applet.init() is called. Exclusively used for manipulating the Frame attached
|
||||||
|
* to the applet of Roatpkz.
|
||||||
|
*/
|
||||||
|
public void preAppletInit() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called in Context.setApplet before after applet.start() and applet.init() are called. Exclusively used for manipulating the Frame attached
|
||||||
|
* to the applet of Roatpkz.
|
||||||
|
*/
|
||||||
|
public void postAppletStart() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user