mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-02 16:49:10 +00:00
Merge pull request #253 from Shadowrs/feature/launch-by-uuid
Feature/launch by UUID
This commit is contained in:
@@ -135,6 +135,9 @@ public final class Landing {
|
||||
case "-no_validation":
|
||||
Core.disableValidation();
|
||||
break;
|
||||
case "-uuid":
|
||||
Core.setQuickLaunchByUuid(Integer.parseInt(args[++i]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ import java.security.NoSuchAlgorithmException;
|
||||
@SuppressWarnings("Duplicates")
|
||||
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 dump;
|
||||
private static boolean loadLocal; //Loads both local and public scripts/servers
|
||||
@@ -46,6 +47,14 @@ public class Core {
|
||||
return validate;
|
||||
}
|
||||
|
||||
public static int getQuickLaunchByUuid() {
|
||||
return quickLaunchByUuid;
|
||||
}
|
||||
|
||||
public static void setQuickLaunchByUuid(int quickLaunchByUuid) {
|
||||
Core.quickLaunchByUuid = quickLaunchByUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enabled loadLocal mode
|
||||
*
|
||||
|
||||
@@ -9,6 +9,7 @@ public class ServerDescription implements Comparable<ServerDescription> {
|
||||
private String serverName;
|
||||
private String author;
|
||||
private double revision;
|
||||
public int uuid;
|
||||
|
||||
public ServerDescription(final String serverName, final String author,
|
||||
final double revision) {
|
||||
|
||||
@@ -86,17 +86,24 @@ public class LocalServers extends ServerParser {
|
||||
if ((bank = object.get("bank")) != null) {
|
||||
bankTabs = (int) bank;
|
||||
}
|
||||
String uuidStr = (String) object.get("uuid"); // optional
|
||||
|
||||
|
||||
JSONObject locations = (JSONObject) object.get("locations");
|
||||
String server = (String) locations.get("server");
|
||||
String provider = (String) locations.get("provider");
|
||||
String hooks = (String) locations.get("hooks");
|
||||
|
||||
|
||||
Core.verbose("[Local server]: " + name);
|
||||
|
||||
ServerProviderInfo serverProviderInfo = new ServerProviderInfo(server, hooks, name, clientClass, bankTabs);
|
||||
|
||||
ServerDescription desc = new ServerDescription(name,
|
||||
author, version);
|
||||
ServerDescription desc = new ServerDescription(name, author, version);
|
||||
if (uuidStr != null && uuidStr.length() > 0) {
|
||||
desc.uuid = Integer.parseInt(uuidStr);
|
||||
}
|
||||
|
||||
SERVER_CACHE.put(desc, new LocalPublicServerExecuter(name, serverProviderInfo, server, provider));
|
||||
} catch (IOException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.parabot.core.ui;
|
||||
|
||||
import org.parabot.core.Core;
|
||||
import org.parabot.core.desc.ServerDescription;
|
||||
import org.parabot.core.parsers.servers.ServerParser;
|
||||
import org.parabot.core.ui.components.ServerComponent;
|
||||
@@ -23,7 +24,7 @@ public class ServerSelector extends JPanel {
|
||||
|
||||
public ServerSelector() {
|
||||
Queue<ServerComponent> widgets = getServers();
|
||||
if (initServer != null) {
|
||||
if (initServer != null || Core.getQuickLaunchByUuid() > -1) {
|
||||
if (runServer(widgets)) {
|
||||
initServer = null;
|
||||
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
|
||||
*/
|
||||
@@ -75,12 +76,25 @@ public class ServerSelector extends JPanel {
|
||||
if (widgets == null || widgets.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
final String serverName = initServer.toLowerCase();
|
||||
for (ServerComponent widget : widgets) {
|
||||
if (widget.desc.getServerName().toLowerCase().equals(serverName)) {
|
||||
Environment.load(widget.desc);
|
||||
return true;
|
||||
if (Core.getQuickLaunchByUuid() > -1) { // match the pre-requested server config uuid to quick-launch
|
||||
for (ServerComponent widget : widgets) {
|
||||
if (widget.desc.uuid == Core.getQuickLaunchByUuid()) {
|
||||
Environment.load(widget.desc);
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user