summaryrefslogtreecommitdiff
path: root/NET/worlds/network/ServerURL.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/network/ServerURL.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/network/ServerURL.java')
-rw-r--r--NET/worlds/network/ServerURL.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/NET/worlds/network/ServerURL.java b/NET/worlds/network/ServerURL.java
new file mode 100644
index 0000000..9461ee5
--- /dev/null
+++ b/NET/worlds/network/ServerURL.java
@@ -0,0 +1,59 @@
+package NET.worlds.network;
+
+public class ServerURL {
+ private String _serverType = null;
+ private String _serverHost = null;
+ private String _serverOptions = null;
+
+ public String getHost() {
+ return this._serverHost;
+ }
+
+ public String getType() {
+ return this._serverType;
+ }
+
+ public ServerURL(String serverURL) throws InvalidServerURLException {
+ String origServerURL = serverURL;
+ int txtPos = serverURL.indexOf("://");
+ if (txtPos >= 0) {
+ String protocol = serverURL.substring(0, txtPos);
+
+ assert protocol.equals("worldserver");
+
+ serverURL = serverURL.substring(txtPos + 3);
+ }
+
+ int typePos = serverURL.indexOf(47);
+ if (typePos >= 0) {
+ this._serverHost = serverURL.substring(0, typePos);
+ serverURL = serverURL.substring(typePos + 1);
+ } else {
+ this._serverHost = serverURL;
+ serverURL = "AutoServer";
+ }
+
+ int optPos = serverURL.indexOf(47);
+ if (optPos >= 0) {
+ this._serverType = serverURL.substring(0, optPos);
+ serverURL = serverURL.substring(optPos + 1);
+ } else {
+ this._serverType = serverURL;
+ serverURL = "";
+ }
+
+ this._serverOptions = serverURL;
+ if (this._serverHost.length() == 0) {
+ throw new InvalidServerURLException("Invalid server URL: " + origServerURL);
+ } else {
+ if (this._serverType.length() == 0) {
+ this._serverType = "AutoServer";
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "worldserver://" + this._serverHost + "/" + this._serverType + "/" + this._serverOptions;
+ }
+}