From 6366638193c62e313b3c9a6facf36fea742c1885 Mon Sep 17 00:00:00 2001 From: lax1dude Date: Sun, 10 Mar 2024 13:28:39 -0700 Subject: [PATCH] Update #27 - Fixed crash with fireballs, made offline start faster --- README.md | 2 + client_version | 2 +- .../client/audio/SoundHandler.edit.java | 5 +- .../command/CommandSpreadPlayers.edit.java | 5 +- .../command/CommandWeather.edit.java | 5 +- .../net/minecraft/entity/EntityList.edit.java | 3 +- .../projectile/EntityFireball.edit.java | 18 +++ .../lwjgl/DesktopClientConfigAdapter.java | 2 +- .../eaglercraft/v1_8/EaglercraftVersion.java | 6 +- .../v1_8/internal/IClientConfigAdapter.java | 2 +- .../v1_8/minecraft}/EntityConstructor.java | 2 +- .../v1_8/update/UpdateService.java | 45 ++++++ .../v1_8/internal/teavm/ClientMain.java | 71 ++++----- .../teavm/TeaVMClientConfigAdapter.java | 139 +++++++++++++++++- .../opts/JSEaglercraftXOptsAssetsURI.java | 29 ++++ .../JSEaglercraftXOptsAssetsURIsArray.java | 30 ++++ .../teavm/opts/JSEaglercraftXOptsRelay.java | 32 ++++ .../opts/JSEaglercraftXOptsRelaysArray.java | 30 ++++ .../teavm/opts/JSEaglercraftXOptsRoot.java | 83 +++++++++++ .../teavm/opts/JSEaglercraftXOptsServer.java | 29 ++++ .../opts/JSEaglercraftXOptsServersArray.java | 30 ++++ .../internal/ClientPlatformSingleplayer.java | 2 +- 22 files changed, 511 insertions(+), 61 deletions(-) rename sources/main/java/net/{minecraft/entity => lax1dude/eaglercraft/v1_8/minecraft}/EntityConstructor.java (95%) create mode 100644 sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsAssetsURI.java create mode 100644 sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsAssetsURIsArray.java create mode 100644 sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRelay.java create mode 100644 sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRelaysArray.java create mode 100644 sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRoot.java create mode 100644 sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsServer.java create mode 100644 sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsServersArray.java diff --git a/README.md b/README.md index cc09dcc..d532e8f 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,8 @@ The default eaglercraftXOpts values is this: - `container:` the ID of the HTML element to create the canvas in **(required)** - `assetsURI:` the URL of the assets.epk file **(required)** - `localesURI:` the URL where extra .lang files can be found +- `lang`: the default language to use for the game (like "en_US") +- `joinServer`: server address to join when the game launches - `worldsDB:` the name of the IndexedDB database to store worlds in - `resourcePacksDB:` the name of the IndexedDB database to store resource packs in - `demoMode:` whether to launch the game in java edition demo mode diff --git a/client_version b/client_version index 8dbaab6..ce6e011 100644 --- a/client_version +++ b/client_version @@ -1 +1 @@ -u26 \ No newline at end of file +u27 \ No newline at end of file diff --git a/patches/minecraft/net/minecraft/client/audio/SoundHandler.edit.java b/patches/minecraft/net/minecraft/client/audio/SoundHandler.edit.java index f93c7be..bd96d42 100644 --- a/patches/minecraft/net/minecraft/client/audio/SoundHandler.edit.java +++ b/patches/minecraft/net/minecraft/client/audio/SoundHandler.edit.java @@ -13,7 +13,7 @@ > DELETE 2 @ 2 : 3 -> CHANGE 1 : 14 @ 1 : 11 +> CHANGE 1 : 15 @ 1 : 11 ~ import java.util.Set; ~ @@ -25,6 +25,7 @@ ~ import com.google.common.collect.Lists; ~ ~ import net.lax1dude.eaglercraft.v1_8.IOUtils; +~ import net.lax1dude.eaglercraft.v1_8.ThreadLocalRandom; ~ import net.lax1dude.eaglercraft.v1_8.json.JSONTypeProvider; ~ import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; ~ import net.lax1dude.eaglercraft.v1_8.log4j.Logger; @@ -87,6 +88,6 @@ > CHANGE 6 : 7 @ 6 : 7 -~ return (SoundEventAccessorComposite) arraylist.get((new EaglercraftRandom()).nextInt(arraylist.size())); +~ return (SoundEventAccessorComposite) arraylist.get(ThreadLocalRandom.current().nextInt(arraylist.size())); > EOF diff --git a/patches/minecraft/net/minecraft/command/CommandSpreadPlayers.edit.java b/patches/minecraft/net/minecraft/command/CommandSpreadPlayers.edit.java index a1e68e5..cbdd7b3 100644 --- a/patches/minecraft/net/minecraft/command/CommandSpreadPlayers.edit.java +++ b/patches/minecraft/net/minecraft/command/CommandSpreadPlayers.edit.java @@ -5,10 +5,11 @@ # Version: 1.0 # Author: lax1dude -> CHANGE 9 : 11 @ 9 : 10 +> CHANGE 9 : 12 @ 9 : 10 ~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; ~ import net.lax1dude.eaglercraft.v1_8.HString; +~ import net.lax1dude.eaglercraft.v1_8.ThreadLocalRandom; > DELETE 1 @ 1 : 9 @@ -18,7 +19,7 @@ > CHANGE 61 : 62 @ 61 : 62 -~ EaglercraftRandom random = new EaglercraftRandom(); +~ EaglercraftRandom random = ThreadLocalRandom.current(); > CHANGE 15 : 16 @ 15 : 16 diff --git a/patches/minecraft/net/minecraft/command/CommandWeather.edit.java b/patches/minecraft/net/minecraft/command/CommandWeather.edit.java index f59410c..906ecf1 100644 --- a/patches/minecraft/net/minecraft/command/CommandWeather.edit.java +++ b/patches/minecraft/net/minecraft/command/CommandWeather.edit.java @@ -5,9 +5,10 @@ # Version: 1.0 # Author: lax1dude -> CHANGE 3 : 4 @ 3 : 8 +> CHANGE 3 : 5 @ 3 : 8 ~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; +~ import net.lax1dude.eaglercraft.v1_8.ThreadLocalRandom; > INSERT 6 : 7 @ 6 @@ -15,6 +16,6 @@ > CHANGE 14 : 15 @ 14 : 15 -~ int i = (300 + (new EaglercraftRandom()).nextInt(600)) * 20 * 2; +~ int i = (300 + ThreadLocalRandom.current().nextInt(600)) * 20 * 2; > EOF diff --git a/patches/minecraft/net/minecraft/entity/EntityList.edit.java b/patches/minecraft/net/minecraft/entity/EntityList.edit.java index bc342f9..c446c88 100644 --- a/patches/minecraft/net/minecraft/entity/EntityList.edit.java +++ b/patches/minecraft/net/minecraft/entity/EntityList.edit.java @@ -7,7 +7,7 @@ > DELETE 2 @ 2 : 4 -> CHANGE 4 : 10 @ 4 : 8 +> CHANGE 4 : 11 @ 4 : 8 ~ ~ import com.google.common.collect.Lists; @@ -15,6 +15,7 @@ ~ ~ import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; ~ import net.lax1dude.eaglercraft.v1_8.log4j.Logger; +~ import net.lax1dude.eaglercraft.v1_8.minecraft.EntityConstructor; > DELETE 66 @ 66 : 68 diff --git a/patches/minecraft/net/minecraft/entity/projectile/EntityFireball.edit.java b/patches/minecraft/net/minecraft/entity/projectile/EntityFireball.edit.java index 6d88f89..f43a7b8 100644 --- a/patches/minecraft/net/minecraft/entity/projectile/EntityFireball.edit.java +++ b/patches/minecraft/net/minecraft/entity/projectile/EntityFireball.edit.java @@ -9,4 +9,22 @@ + +> INSERT 52 : 56 @ 52 + ++ if (d0 == 0.0) { ++ this.accelerationX = this.accelerationY = this.accelerationZ = 0.0D; ++ return; ++ } + +> INSERT 16 : 20 @ 16 + ++ if (d0 == 0.0) { ++ this.accelerationX = this.accelerationY = this.accelerationZ = 0.0D; ++ return; ++ } + +> CHANGE 46 : 47 @ 46 : 47 + +~ for (int i = 0, l = list.size(); i < l; ++i) { + > EOF diff --git a/sources/lwjgl/java/net/lax1dude/eaglercraft/v1_8/internal/lwjgl/DesktopClientConfigAdapter.java b/sources/lwjgl/java/net/lax1dude/eaglercraft/v1_8/internal/lwjgl/DesktopClientConfigAdapter.java index 6813701..26b1be6 100644 --- a/sources/lwjgl/java/net/lax1dude/eaglercraft/v1_8/internal/lwjgl/DesktopClientConfigAdapter.java +++ b/sources/lwjgl/java/net/lax1dude/eaglercraft/v1_8/internal/lwjgl/DesktopClientConfigAdapter.java @@ -57,7 +57,7 @@ public class DesktopClientConfigAdapter implements IClientConfigAdapter { } @Override - public JSONObject dumpConfig() { + public JSONObject getIntegratedServerOpts() { return new JSONObject("{\"container\":null,\"worldsDB\":\"desktop\"}"); } diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java index ec48a92..3e65516 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java @@ -10,7 +10,7 @@ public class EaglercraftVersion { /// Customize these to fit your fork: public static final String projectForkName = "EaglercraftX"; - public static final String projectForkVersion = "u26"; + public static final String projectForkVersion = "u27"; public static final String projectForkVendor = "lax1dude"; public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; @@ -20,7 +20,7 @@ public class EaglercraftVersion { public static final String projectOriginName = "EaglercraftX"; public static final String projectOriginAuthor = "lax1dude"; public static final String projectOriginRevision = "1.8"; - public static final String projectOriginVersion = "u26"; + public static final String projectOriginVersion = "u27"; public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace @@ -31,7 +31,7 @@ public class EaglercraftVersion { public static final boolean enableUpdateService = true; public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client"; - public static final int updateBundlePackageVersionInt = 26; + public static final int updateBundlePackageVersionInt = 27; public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName; diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/internal/IClientConfigAdapter.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/internal/IClientConfigAdapter.java index 0a91bfe..dc519b1 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/internal/IClientConfigAdapter.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/internal/IClientConfigAdapter.java @@ -44,7 +44,7 @@ public interface IClientConfigAdapter { String getResourcePacksDB(); - JSONObject dumpConfig(); + JSONObject getIntegratedServerOpts(); List getRelays(); diff --git a/sources/main/java/net/minecraft/entity/EntityConstructor.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/minecraft/EntityConstructor.java similarity index 95% rename from sources/main/java/net/minecraft/entity/EntityConstructor.java rename to sources/main/java/net/lax1dude/eaglercraft/v1_8/minecraft/EntityConstructor.java index b5d6130..212f293 100644 --- a/sources/main/java/net/minecraft/entity/EntityConstructor.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/minecraft/EntityConstructor.java @@ -1,4 +1,4 @@ -package net.minecraft.entity; +package net.lax1dude.eaglercraft.v1_8.minecraft; import net.minecraft.world.World; diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/update/UpdateService.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/update/UpdateService.java index c9dde66..49aa9bb 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/update/UpdateService.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/update/UpdateService.java @@ -1,8 +1,10 @@ package net.lax1dude.eaglercraft.v1_8.update; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; +import java.util.List; import java.util.Set; import net.lax1dude.eaglercraft.v1_8.EagRuntime; @@ -36,8 +38,30 @@ public class UpdateService { private static UpdateCertificate latestUpdateFound = null; private static final Set availableUpdates = new HashSet(); + private static final Set fastUpdateKnownCheckSet = new HashSet(); private static final Set dismissedUpdates = new HashSet(); + private static class RawKnownCertHolder { + + private final byte[] data; + private final int hashcode; + private final long age; + + public RawKnownCertHolder(byte[] data) { + this.data = data; + this.hashcode = Arrays.hashCode(data); + this.age = System.currentTimeMillis(); + } + + public int hashCode() { + return hashcode; + } + + public boolean equals(Object o) { + return o != null && (o == this || ((o instanceof RawKnownCertHolder) && Arrays.equals(((RawKnownCertHolder)o).data, data))); + } + } + public static boolean supported() { return EaglercraftVersion.enableUpdateService && EagRuntime.getConfiguration().allowUpdateSvc() && PlatformUpdateSvc.supported(); } @@ -102,6 +126,16 @@ public class UpdateService { if (EagRuntime.getConfiguration().allowUpdateDL()) { synchronized(availableUpdates) { try { + if(certificateData.length > 32767) { + throw new CertificateInvalidException("Certificate is too large! (" + certificateData.length + " bytes)"); + } + if(!fastUpdateKnownCheckSet.add(new RawKnownCertHolder(certificateData))) { + if (EagRuntime.getConfiguration().isLogInvalidCerts()) { + logger.info("Ignoring {} byte certificate that has already been processed", certificateData.length); + } + freeMemory(); + return; + } UpdateCertificate cert = UpdateCertificate.parseAndVerifyCertificate(certificateData); if (EaglercraftVersion.updateBundlePackageName.equalsIgnoreCase(cert.bundlePackageName)) { if (myUpdateCert == null || !Arrays.equals(cert.bundleDataHash, myUpdateCert.bundleDataHash)) { @@ -140,6 +174,17 @@ public class UpdateService { } } + private static void freeMemory() { + if(fastUpdateKnownCheckSet.size() > 127) { + List lst = new ArrayList(fastUpdateKnownCheckSet); + fastUpdateKnownCheckSet.clear(); + lst.sort((c1, c2) -> { return (int)(c2.age - c1.age); }); + for(int i = 0; i < 64; ++i) { + fastUpdateKnownCheckSet.add(lst.get(i)); + } + } + } + public static void startClientUpdateFrom(UpdateCertificate clientUpdate) { PlatformUpdateSvc.startClientUpdateFrom(clientUpdate); } diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/ClientMain.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/ClientMain.java index ebc1531..c0336e9 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/ClientMain.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/ClientMain.java @@ -4,9 +4,7 @@ import java.io.PrintStream; import java.text.SimpleDateFormat; import java.util.Date; -import org.json.JSONArray; import org.json.JSONException; -import org.json.JSONObject; import org.teavm.jso.JSBody; import org.teavm.jso.JSFunctor; import org.teavm.jso.JSObject; @@ -22,6 +20,9 @@ import net.lax1dude.eaglercraft.v1_8.EagRuntime; import net.lax1dude.eaglercraft.v1_8.EaglercraftVersion; import net.lax1dude.eaglercraft.v1_8.internal.PlatformApplication; import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime; +import net.lax1dude.eaglercraft.v1_8.internal.teavm.opts.JSEaglercraftXOptsAssetsURI; +import net.lax1dude.eaglercraft.v1_8.internal.teavm.opts.JSEaglercraftXOptsAssetsURIsArray; +import net.lax1dude.eaglercraft.v1_8.internal.teavm.opts.JSEaglercraftXOptsRoot; import net.lax1dude.eaglercraft.v1_8.log4j.ILogRedirector; import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; import net.lax1dude.eaglercraft.v1_8.profile.EaglerProfile; @@ -52,8 +53,6 @@ public class ClientMain { return crashImage.substring(0); } - private static String crashScreenOptsDump = null; - @JSBody(params = {}, script = "if((typeof window.__isEaglerX188Running === \"string\") && window.__isEaglerX188Running === \"yes\") return true; window.__isEaglerX188Running = \"yes\"; return false;") private static native boolean getRunningFlag(); @@ -66,7 +65,7 @@ public class ClientMain { } try { systemOut.println("ClientMain: [INFO] eaglercraftx is starting..."); - String opts = getEaglerXOpts(); + JSObject opts = getEaglerXOpts(); if(opts == null) { systemErr.println("ClientMain: [ERROR] the \"window.eaglercraftXOpts\" variable is undefined"); @@ -76,38 +75,40 @@ public class ClientMain { } try { - JSONObject eaglercraftOpts = new JSONObject(opts); + JSEaglercraftXOptsRoot eaglercraftOpts = (JSEaglercraftXOptsRoot)opts; - configRootElementId = eaglercraftOpts.getString("container"); + configRootElementId = eaglercraftOpts.getContainer(); + if(configRootElementId == null) { + throw new JSONException("window.eaglercraftXOpts.container is undefined!"); + } configRootElement = Window.current().getDocument().getElementById(configRootElementId); - Object epkConfig = eaglercraftOpts.get("assetsURI"); - if(epkConfig instanceof JSONArray) { - JSONArray epkConfigArr = (JSONArray)epkConfig; - if(epkConfigArr.length() == 0) { + String epkSingleURL = eaglercraftOpts.getAssetsURI(); + if(epkSingleURL != null) { + configEPKFiles = new EPKFileEntry[] { new EPKFileEntry(epkSingleURL, "") }; + }else { + JSEaglercraftXOptsAssetsURIsArray epkURLs = eaglercraftOpts.getAssetsURIArray(); + int len = epkURLs.getLength(); + if(len == 0) { throw new JSONException("assetsURI array cannot be empty!"); } - configEPKFiles = new EPKFileEntry[epkConfigArr.length()]; - for(int i = 0, l = configEPKFiles.length; i < l; ++i) { - configEPKFiles[i] = parseEntry(epkConfigArr.getJSONObject(i)); - } - }else if(epkConfig instanceof JSONObject) { - configEPKFiles = new EPKFileEntry[] { parseEntry((JSONObject)epkConfig) }; - }else if(epkConfig instanceof String) { - String epkConfigStr = (String)epkConfig; - configEPKFiles = new EPKFileEntry[] { new EPKFileEntry(epkConfigStr, "") }; - if(epkConfigStr.length() > 128) { - eaglercraftOpts.put("assetsURI", epkConfigStr.substring(0, 128) + " ... "); + configEPKFiles = new EPKFileEntry[len]; + for(int i = 0; i < len; ++i) { + JSEaglercraftXOptsAssetsURI etr = epkURLs.get(i); + String url = etr.getURL(); + if(url == null) { + throw new JSONException("assetsURI is missing a url!"); + } + configEPKFiles[i] = new EPKFileEntry(url, etr.getPath("")); } } - configLocalesFolder = eaglercraftOpts.optString("localesURI", "lang"); + configLocalesFolder = eaglercraftOpts.getLocalesURI("lang"); if(configLocalesFolder.endsWith("/")) { configLocalesFolder = configLocalesFolder.substring(0, configLocalesFolder.length() - 1); } - ((TeaVMClientConfigAdapter)TeaVMClientConfigAdapter.instance).loadJSON(eaglercraftOpts); - crashScreenOptsDump = eaglercraftOpts.toString(); + ((TeaVMClientConfigAdapter)TeaVMClientConfigAdapter.instance).loadNative(eaglercraftOpts); systemOut.println("ClientMain: [INFO] configuration was successful"); }catch(Throwable t) { @@ -192,9 +193,9 @@ public class ClientMain { } @JSBody(params = {}, script = "if(typeof window.eaglercraftXOpts === \"undefined\") {return null;}" - + "else if(typeof window.eaglercraftXOpts === \"string\") {return window.eaglercraftXOpts;}" - + "else {return JSON.stringify(window.eaglercraftXOpts);}") - private static native String getEaglerXOpts(); + + "else if(typeof window.eaglercraftXOpts === \"string\") {return JSON.parse(window.eaglercraftXOpts);}" + + "else {return window.eaglercraftXOpts;}") + private static native JSObject getEaglerXOpts(); public static class EPKFileEntry { @@ -207,18 +208,6 @@ public class ClientMain { } } - private static EPKFileEntry parseEntry(JSONObject obj) { - String url = obj.getString("url"); - String path = obj.optString("path", ""); - if(url.length() > 128) { - obj.put("url", url.substring(0, 128) + " ... "); - } - if(path == null) { - path = ""; - } - return new EPKFileEntry(url, path); - } - public static String configRootElementId = null; public static HTMLElement configRootElement = null; public static EPKFileEntry[] configEPKFiles = null; @@ -269,7 +258,7 @@ public class ClientMain { str.append(addWebGLToCrash()); str.append('\n'); str.append("window.eaglercraftXOpts = "); - str.append(crashScreenOptsDump).append('\n'); + str.append(TeaVMClientConfigAdapter.instance.toString()).append('\n'); str.append('\n'); str.append("currentTime = "); str.append(EagRuntime.fixDateFormat(new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z")).format(new Date())).append('\n'); diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMClientConfigAdapter.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMClientConfigAdapter.java index 5c8ca5c..b581bd8 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMClientConfigAdapter.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/TeaVMClientConfigAdapter.java @@ -10,8 +10,15 @@ import net.lax1dude.eaglercraft.v1_8.ThreadLocalRandom; import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayManager; import org.json.JSONArray; import org.json.JSONObject; +import org.teavm.jso.JSBody; +import org.teavm.jso.JSObject; import net.lax1dude.eaglercraft.v1_8.internal.IClientConfigAdapter; +import net.lax1dude.eaglercraft.v1_8.internal.teavm.opts.JSEaglercraftXOptsRelay; +import net.lax1dude.eaglercraft.v1_8.internal.teavm.opts.JSEaglercraftXOptsRelaysArray; +import net.lax1dude.eaglercraft.v1_8.internal.teavm.opts.JSEaglercraftXOptsRoot; +import net.lax1dude.eaglercraft.v1_8.internal.teavm.opts.JSEaglercraftXOptsServer; +import net.lax1dude.eaglercraft.v1_8.internal.teavm.opts.JSEaglercraftXOptsServersArray; import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayEntry; /** @@ -39,7 +46,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter { private String serverToJoin = null; private String worldsDB = "worlds"; private String resourcePacksDB = "resourcePacks"; - private JSONObject originalEaglercraftOpts; + private JSONObject integratedServerOpts; private boolean checkShaderGLErrors = false; private boolean demoMode = EaglercraftVersion.forceDemoMode; private boolean isAllowUpdateSvc = EaglercraftVersion.enableUpdateService; @@ -51,8 +58,92 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter { private boolean checkRelaysForUpdates = false; private boolean enableSignatureBadge = false; + public void loadNative(JSObject jsObject) { + integratedServerOpts = new JSONObject(); + JSEaglercraftXOptsRoot eaglercraftXOpts = (JSEaglercraftXOptsRoot)jsObject; + + defaultLocale = eaglercraftXOpts.getLang("en_US"); + serverToJoin = eaglercraftXOpts.getJoinServer(null); + worldsDB = eaglercraftXOpts.getWorldsDB("worlds"); + resourcePacksDB = eaglercraftXOpts.getResourcePacksDB("resourcePacks"); + checkShaderGLErrors = eaglercraftXOpts.getCheckShaderGLErrors(false); + demoMode = EaglercraftVersion.forceDemoMode || eaglercraftXOpts.getDemoMode(false); + isAllowUpdateSvc = EaglercraftVersion.enableUpdateService && !demoMode && eaglercraftXOpts.getAllowUpdateSvc(true); + isAllowUpdateDL = EaglercraftVersion.enableUpdateService && !demoMode && eaglercraftXOpts.getAllowUpdateDL(true); + isEnableDownloadOfflineButton = eaglercraftXOpts.getEnableDownloadOfflineButton(true); + downloadOfflineButtonLink = eaglercraftXOpts.getDownloadOfflineButtonLink(null); + useSpecialCursors = eaglercraftXOpts.getHtml5CursorSupport(false); + logInvalidCerts = EaglercraftVersion.enableUpdateService && !demoMode && eaglercraftXOpts.getLogInvalidCerts(false); + enableSignatureBadge = eaglercraftXOpts.getEnableSignatureBadge(false); + + integratedServerOpts.put("worldsDB", worldsDB); + integratedServerOpts.put("demoMode", demoMode); + integratedServerOpts.put("lang", defaultLocale); + integratedServerOpts.put("allowUpdateSvc", isAllowUpdateSvc); + integratedServerOpts.put("allowUpdateDL", isAllowUpdateDL); + + JSEaglercraftXOptsServersArray serversArray = eaglercraftXOpts.getServers(); + if(serversArray != null) { + for(int i = 0, l = serversArray.getLength(); i < l; ++i) { + JSEaglercraftXOptsServer serverEntry = serversArray.get(i); + String serverAddr = serverEntry.getAddr(); + if(serverAddr != null) { + String serverName = serverEntry.getName("Default Server #" + i); + defaultServers.add(new DefaultServer(serverName, serverAddr)); + } + } + } + + JSEaglercraftXOptsRelaysArray relaysArray = eaglercraftXOpts.getRelays(); + if(relaysArray != null) { + boolean gotAPrimary = false; + for(int i = 0, l = relaysArray.getLength(); i < l; ++i) { + JSEaglercraftXOptsRelay relay = relaysArray.get(i); + String addr = relay.getAddr(); + if(addr != null) { + boolean p = relay.getPrimary(); + if(p) { + if(gotAPrimary) { + p = false; + }else { + gotAPrimary = true; + } + } + relays.add(new RelayEntry(relay.getAddr(), relay.getComment("Default Relay #" + i), p)); + } + } + } + + boolean officialUpdates = !demoMode && EaglercraftVersion.updateBundlePackageName.equals("net.lax1dude.eaglercraft.v1_8.client"); + if (relays.size() <= 0) { + int choice = ThreadLocalRandom.current().nextInt(3); + relays.add(new RelayEntry("wss://relay.deev.is/", "lax1dude relay #1", choice == 0)); + relays.add(new RelayEntry("wss://relay.lax1dude.net/", "lax1dude relay #2", choice == 1)); + relays.add(new RelayEntry("wss://relay.shhnowisnottheti.me/", "ayunami relay #1", choice == 2)); + checkRelaysForUpdates = !demoMode && eaglercraftXOpts.getCheckRelaysForUpdates(officialUpdates); + }else { + if(officialUpdates) { + for(int i = 0, l = relays.size(); i < l; ++i) { + String addr = relays.get(i).address; + if(!addr.contains("deev.is") && !addr.contains("lax1dude.net") && !addr.contains("shhnowisnottheti.me")) { + officialUpdates = false; + break; + } + } + } + checkRelaysForUpdates = !demoMode && eaglercraftXOpts.getCheckRelaysForUpdates(officialUpdates); + } + + RelayManager.relayManager.load(EagRuntime.getStorage("r")); + + if (RelayManager.relayManager.count() <= 0) { + RelayManager.relayManager.loadDefaults(); + RelayManager.relayManager.save(); + } + } + public void loadJSON(JSONObject eaglercraftOpts) { - originalEaglercraftOpts = eaglercraftOpts; + integratedServerOpts = eaglercraftOpts; defaultLocale = eaglercraftOpts.optString("lang", "en_US"); serverToJoin = eaglercraftOpts.optString("joinServer", null); worldsDB = eaglercraftOpts.optString("worldsDB", "worlds"); @@ -67,7 +158,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter { isEnableDownloadOfflineButton = eaglercraftOpts.optBoolean("enableDownloadOfflineButton", true); downloadOfflineButtonLink = eaglercraftOpts.optString("downloadOfflineButtonLink", null); useSpecialCursors = eaglercraftOpts.optBoolean("html5CursorSupport", false); - logInvalidCerts = !demoMode && eaglercraftOpts.optBoolean("logInvalidCerts", false); + logInvalidCerts = EaglercraftVersion.enableUpdateService && !demoMode && eaglercraftOpts.optBoolean("logInvalidCerts", false); enableSignatureBadge = eaglercraftOpts.optBoolean("enableSignatureBadge", false); JSONArray serversArray = eaglercraftOpts.optJSONArray("servers"); if(serversArray != null) { @@ -152,8 +243,8 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter { } @Override - public JSONObject dumpConfig() { - return originalEaglercraftOpts; + public JSONObject getIntegratedServerOpts() { + return integratedServerOpts; } @Override @@ -211,4 +302,42 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter { return enableSignatureBadge; } + @Override + public String toString() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("lang", defaultLocale); + jsonObject.put("joinServer", serverToJoin); + jsonObject.put("worldsDB", worldsDB); + jsonObject.put("resourcePacksDB", resourcePacksDB); + jsonObject.put("checkShaderGLErrors", checkShaderGLErrors); + jsonObject.put("demoMode", demoMode); + jsonObject.put("allowUpdateSvc", isAllowUpdateSvc); + jsonObject.put("allowUpdateDL", isAllowUpdateDL); + jsonObject.put("enableDownloadOfflineButton", isEnableDownloadOfflineButton); + jsonObject.put("downloadOfflineButtonLink", downloadOfflineButtonLink); + jsonObject.put("html5CursorSupport", useSpecialCursors); + jsonObject.put("logInvalidCerts", logInvalidCerts); + jsonObject.put("checkRelaysForUpdates", checkRelaysForUpdates); + jsonObject.put("enableSignatureBadge", enableSignatureBadge); + JSONArray serversArr = new JSONArray(); + for(int i = 0, l = defaultServers.size(); i < l; ++i) { + DefaultServer srv = defaultServers.get(i); + JSONObject obj = new JSONObject(); + obj.put("addr", srv.addr); + obj.put("name", srv.name); + serversArr.put(obj); + } + jsonObject.put("servers", serversArr); + JSONArray relaysArr = new JSONArray(); + for(int i = 0, l = relays.size(); i < l; ++i) { + RelayEntry rl = relays.get(i); + JSONObject obj = new JSONObject(); + obj.put("addr", rl.address); + obj.put("comment", rl.comment); + obj.put("primary", rl.primary); + relaysArr.put(obj); + } + jsonObject.put("relays", relaysArr); + return jsonObject.toString(); + } } diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsAssetsURI.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsAssetsURI.java new file mode 100644 index 0000000..e26301c --- /dev/null +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsAssetsURI.java @@ -0,0 +1,29 @@ +package net.lax1dude.eaglercraft.v1_8.internal.teavm.opts; + +import org.teavm.jso.JSBody; +import org.teavm.jso.JSObject; + +/** + * Copyright (c) 2024 lax1dude. All Rights Reserved. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +public abstract class JSEaglercraftXOptsAssetsURI implements JSObject { + + @JSBody(script = "return (typeof this.url === \"string\") ? this.url : null;") + public native String getURL(); + + @JSBody(params = { "def" }, script = "return (typeof this.path === \"string\") ? this.path : def;") + public native String getPath(String defaultValue); + +} diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsAssetsURIsArray.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsAssetsURIsArray.java new file mode 100644 index 0000000..de08a40 --- /dev/null +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsAssetsURIsArray.java @@ -0,0 +1,30 @@ +package net.lax1dude.eaglercraft.v1_8.internal.teavm.opts; + +import org.teavm.jso.JSIndexer; +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; + +/** + * Copyright (c) 2024 lax1dude. All Rights Reserved. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +public interface JSEaglercraftXOptsAssetsURIsArray extends JSObject { + + @JSIndexer + JSEaglercraftXOptsAssetsURI get(int idx); + + @JSProperty + int getLength(); + +} diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRelay.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRelay.java new file mode 100644 index 0000000..dc4f9df --- /dev/null +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRelay.java @@ -0,0 +1,32 @@ +package net.lax1dude.eaglercraft.v1_8.internal.teavm.opts; + +import org.teavm.jso.JSBody; +import org.teavm.jso.JSObject; + +/** + * Copyright (c) 2024 lax1dude. All Rights Reserved. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +public abstract class JSEaglercraftXOptsRelay implements JSObject { + + @JSBody(script = "return (typeof this.addr === \"string\") ? this.addr : null;") + public native String getAddr(); + + @JSBody(params = { "def" }, script = "return (typeof this.comment === \"string\") ? this.comment : def;") + public native String getComment(String defaultValue); + + @JSBody(script = "return (typeof this.primary === \"boolean\") ? this.primary : false;") + public native boolean getPrimary(); + +} diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRelaysArray.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRelaysArray.java new file mode 100644 index 0000000..c120824 --- /dev/null +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRelaysArray.java @@ -0,0 +1,30 @@ +package net.lax1dude.eaglercraft.v1_8.internal.teavm.opts; + +import org.teavm.jso.JSIndexer; +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; + +/** + * Copyright (c) 2024 lax1dude. All Rights Reserved. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +public interface JSEaglercraftXOptsRelaysArray extends JSObject { + + @JSIndexer + JSEaglercraftXOptsRelay get(int idx); + + @JSProperty + int getLength(); + +} diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRoot.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRoot.java new file mode 100644 index 0000000..7449bd8 --- /dev/null +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsRoot.java @@ -0,0 +1,83 @@ +package net.lax1dude.eaglercraft.v1_8.internal.teavm.opts; + +import org.teavm.jso.JSBody; +import org.teavm.jso.JSObject; + +/** + * Copyright (c) 2024 lax1dude. All Rights Reserved. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +public abstract class JSEaglercraftXOptsRoot implements JSObject { + + @JSBody(script = "return (typeof this.container === \"string\") ? this.container : null;") + public native String getContainer(); + + @JSBody(script = "return (typeof this.assetsURI === \"string\") ? this.assetsURI : null;") + public native String getAssetsURI(); + + @JSBody(script = "return (typeof this.assetsURI === \"object\") ? this.assetsURI : null;") + public native JSEaglercraftXOptsAssetsURIsArray getAssetsURIArray(); + + @JSBody(params = { "def" }, script = "return (typeof this.lang === \"string\") ? this.lang : def;") + public native String getLang(String defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.joinServer === \"string\") ? this.joinServer : def;") + public native String getJoinServer(String defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.localesURI === \"string\") ? this.localesURI : def;") + public native String getLocalesURI(String defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.worldsDB === \"string\") ? this.worldsDB : def;") + public native String getWorldsDB(String defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.resourcePacksDB === \"string\") ? this.resourcePacksDB : def;") + public native String getResourcePacksDB(String defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.demoMode === \"boolean\") ? this.demoMode : def;") + public native boolean getDemoMode(boolean defaultValue); + + @JSBody(script = "return (typeof this.servers === \"object\") ? this.servers : null;") + public native JSEaglercraftXOptsServersArray getServers(); + + @JSBody(script = "return (typeof this.relays === \"object\") ? this.relays : null;") + public native JSEaglercraftXOptsRelaysArray getRelays(); + + @JSBody(params = { "def" }, script = "return (typeof this.checkShaderGLErrors === \"boolean\") ? this.checkShaderGLErrors : def;") + public native boolean getCheckShaderGLErrors(boolean defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.enableDownloadOfflineButton === \"boolean\") ? this.enableDownloadOfflineButton : def;") + public native boolean getEnableDownloadOfflineButton(boolean defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.downloadOfflineButtonLink === \"string\") ? this.downloadOfflineButtonLink : def;") + public native String getDownloadOfflineButtonLink(String defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.html5CursorSupport === \"boolean\") ? this.html5CursorSupport : def;") + public native boolean getHtml5CursorSupport(boolean defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.allowUpdateSvc === \"boolean\") ? this.allowUpdateSvc : def;") + public native boolean getAllowUpdateSvc(boolean defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.allowUpdateDL === \"boolean\") ? this.allowUpdateDL : def;") + public native boolean getAllowUpdateDL(boolean defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.logInvalidCerts === \"boolean\") ? this.logInvalidCerts : def;") + public native boolean getLogInvalidCerts(boolean defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.enableSignatureBadge === \"boolean\") ? this.enableSignatureBadge : def;") + public native boolean getEnableSignatureBadge(boolean defaultValue); + + @JSBody(params = { "def" }, script = "return (typeof this.checkRelaysForUpdates === \"boolean\") ? this.checkRelaysForUpdates : def;") + public native boolean getCheckRelaysForUpdates(boolean defaultValue); + +} diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsServer.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsServer.java new file mode 100644 index 0000000..8ff7e6c --- /dev/null +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsServer.java @@ -0,0 +1,29 @@ +package net.lax1dude.eaglercraft.v1_8.internal.teavm.opts; + +import org.teavm.jso.JSBody; +import org.teavm.jso.JSObject; + +/** + * Copyright (c) 2024 lax1dude. All Rights Reserved. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +public abstract class JSEaglercraftXOptsServer implements JSObject { + + @JSBody(script = "return (typeof this.addr === \"string\") ? this.addr : null;") + public native String getAddr(); + + @JSBody(params = { "def" }, script = "return (typeof this.name === \"string\") ? this.name : def;") + public native String getName(String defaultValue); + +} diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsServersArray.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsServersArray.java new file mode 100644 index 0000000..3299302 --- /dev/null +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/internal/teavm/opts/JSEaglercraftXOptsServersArray.java @@ -0,0 +1,30 @@ +package net.lax1dude.eaglercraft.v1_8.internal.teavm.opts; + +import org.teavm.jso.JSIndexer; +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; + +/** + * Copyright (c) 2024 lax1dude. All Rights Reserved. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +public interface JSEaglercraftXOptsServersArray extends JSObject { + + @JSIndexer + JSEaglercraftXOptsServer get(int idx); + + @JSProperty + int getLength(); + +} diff --git a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/internal/ClientPlatformSingleplayer.java b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/internal/ClientPlatformSingleplayer.java index 166c109..d05992b 100644 --- a/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/internal/ClientPlatformSingleplayer.java +++ b/sources/teavm/java/net/lax1dude/eaglercraft/v1_8/sp/internal/ClientPlatformSingleplayer.java @@ -191,7 +191,7 @@ public class ClientPlatformSingleplayer { } }); registerPacketHandler(workerObj, new WorkerBinaryPacketHandlerImpl()); - sendWorkerStartPacket(workerObj, PlatformRuntime.getClientConfigAdapter().dumpConfig().toString()); + sendWorkerStartPacket(workerObj, PlatformRuntime.getClientConfigAdapter().getIntegratedServerOpts().toString()); }