mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 08:39:12 +00:00
Add -uuid flag as an alternative to -server quicklaunch arg
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.quickLaunchByUuid = Integer.parseInt(args[++i]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
public class Core {
|
public class Core {
|
||||||
|
|
||||||
private static boolean debug;
|
public static int quickLaunchByUuid; // 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
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -86,17 +86,24 @@ 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");
|
||||||
|
|
||||||
|
|
||||||
Core.verbose("[Local server]: " + name);
|
Core.verbose("[Local server]: " + name);
|
||||||
|
|
||||||
ServerProviderInfo serverProviderInfo = new ServerProviderInfo(server, hooks, name, clientClass, bankTabs);
|
ServerProviderInfo serverProviderInfo = new ServerProviderInfo(server, hooks, name, clientClass, bankTabs);
|
||||||
|
|
||||||
ServerDescription desc = new ServerDescription(name,
|
ServerDescription desc = new ServerDescription(name, author, version);
|
||||||
author, version);
|
if (uuidStr != null && uuidStr.length() > 0) {
|
||||||
|
desc.uuid = Integer.parseInt(uuidStr);
|
||||||
|
}
|
||||||
|
|
||||||
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.quickLaunchByUuid > 0) {
|
||||||
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,7 +76,16 @@ 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.quickLaunchByUuid > 0) { // match the pre-requested server config uuid to quick-launch
|
||||||
|
for (ServerComponent widget : widgets) {
|
||||||
|
if (widget.desc.uuid == Core.quickLaunchByUuid) {
|
||||||
|
Environment.load(widget.desc);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final String serverName = initServer.toLowerCase(); // match the pre-requested server name to quick-launch
|
||||||
for (ServerComponent widget : widgets) {
|
for (ServerComponent widget : widgets) {
|
||||||
if (widget.desc.getServerName().toLowerCase().equals(serverName)) {
|
if (widget.desc.getServerName().toLowerCase().equals(serverName)) {
|
||||||
Environment.load(widget.desc);
|
Environment.load(widget.desc);
|
||||||
|
|||||||
Reference in New Issue
Block a user