mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-28 02:48:14 -05:00
Update #36 - Fix incorrect use of arithmetic shift, more capes
This commit is contained in:
@ -309,4 +309,7 @@ public class PlatformApplication {
|
||||
public static boolean isShowingDebugConsole() {
|
||||
return DebugConsoleWindow.isShowingDebugConsole();
|
||||
}
|
||||
|
||||
@JSBody(params = { "str" }, script = "window.minecraftServer = str;")
|
||||
public static native void setMCServerWindowGlobal(String str);
|
||||
}
|
||||
|
@ -605,6 +605,10 @@ public class PlatformInput {
|
||||
Window.clearTimeout(mouseUngrabTimeout);
|
||||
mouseUngrabTimeout = -1;
|
||||
}
|
||||
try {
|
||||
win.getDocument().exitPointerLock();
|
||||
}catch(Throwable t) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void pressAnyKeyScreen() {
|
||||
|
@ -87,6 +87,7 @@ public class PlatformRuntime {
|
||||
win = Window.current();
|
||||
doc = win.getDocument();
|
||||
DebugConsoleWindow.initialize(win);
|
||||
PlatformApplication.setMCServerWindowGlobal(null);
|
||||
|
||||
logger.info("Creating main game canvas");
|
||||
|
||||
|
@ -348,11 +348,11 @@ public class EaglerArrayByteBuffer implements ByteBuffer {
|
||||
@Override
|
||||
public ByteBuffer putLong(long value) {
|
||||
if(position + 8 > limit) throw new ArrayIndexOutOfBoundsException(position);
|
||||
dataView.setUint32(position, (int) (value & 0xFFFFFFFF), true);
|
||||
dataView.setUint8(position + 4, (short) ((value >> 32) & 0xFF));
|
||||
dataView.setUint8(position + 5, (short) ((value >> 40) & 0xFF));
|
||||
dataView.setUint8(position + 6, (short) ((value >> 48) & 0xFF));
|
||||
dataView.setUint8(position + 7, (short) ((value >> 56) & 0xFF));
|
||||
dataView.setUint32(position, (int) (value & 0xFFFFFFFFl), true);
|
||||
dataView.setUint8(position + 4, (short) ((value >>> 32l) & 0xFFl));
|
||||
dataView.setUint8(position + 5, (short) ((value >>> 40l) & 0xFFl));
|
||||
dataView.setUint8(position + 6, (short) ((value >>> 48l) & 0xFFl));
|
||||
dataView.setUint8(position + 7, (short) ((value >>> 56l) & 0xFFl));
|
||||
position += 8;
|
||||
return this;
|
||||
}
|
||||
@ -368,11 +368,11 @@ public class EaglerArrayByteBuffer implements ByteBuffer {
|
||||
@Override
|
||||
public ByteBuffer putLong(int index, long value) {
|
||||
if(index + 8 > limit) throw new ArrayIndexOutOfBoundsException(index);
|
||||
dataView.setUint32(index, (int) (value & 0xFFFFFFFF), true);
|
||||
dataView.setUint8(index + 4, (short) ((value >> 32) & 0xFF));
|
||||
dataView.setUint8(index + 5, (short) ((value >> 40) & 0xFF));
|
||||
dataView.setUint8(index + 6, (short) ((value >> 48) & 0xFF));
|
||||
dataView.setUint8(index + 7, (short) ((value >> 56) & 0xFF));
|
||||
dataView.setUint32(index, (int) (value & 0xFFFFFFFFl), true);
|
||||
dataView.setUint8(index + 4, (short) ((value >>> 32l) & 0xFFl));
|
||||
dataView.setUint8(index + 5, (short) ((value >>> 40l) & 0xFFl));
|
||||
dataView.setUint8(index + 6, (short) ((value >>> 48l) & 0xFFl));
|
||||
dataView.setUint8(index + 7, (short) ((value >>> 56l) & 0xFFl));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@ package net.lax1dude.eaglercraft.v1_8.internal.teavm;
|
||||
import java.io.PrintStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.teavm.jso.JSBody;
|
||||
@ -76,6 +78,7 @@ public class ClientMain {
|
||||
|
||||
try {
|
||||
JSEaglercraftXOptsRoot eaglercraftOpts = (JSEaglercraftXOptsRoot)opts;
|
||||
crashOnUncaughtExceptions = eaglercraftOpts.getCrashOnUncaughtExceptions(false);
|
||||
|
||||
configRootElementId = eaglercraftOpts.getContainer();
|
||||
if(configRootElementId == null) {
|
||||
@ -119,36 +122,38 @@ public class ClientMain {
|
||||
return;
|
||||
}
|
||||
|
||||
systemOut.println("ClientMain: [INFO] registering crash handlers");
|
||||
|
||||
setWindowErrorHandler(new WindowErrorHandler() {
|
||||
|
||||
@Override
|
||||
public void call(String message, String file, int line, int col, JSError error) {
|
||||
StringBuilder str = new StringBuilder();
|
||||
|
||||
str.append("Native Browser Exception\n");
|
||||
str.append("----------------------------------\n");
|
||||
str.append(" Line: ").append((file == null ? "unknown" : file) + ":" + line + ":" + col).append('\n');
|
||||
str.append(" Type: ").append(error == null ? "generic" : error.getName()).append('\n');
|
||||
|
||||
if(error != null) {
|
||||
str.append(" Desc: ").append(error.getMessage() == null ? "null" : error.getMessage()).append('\n');
|
||||
}
|
||||
|
||||
if(message != null) {
|
||||
if(error == null || error.getMessage() == null || !message.endsWith(error.getMessage())) {
|
||||
str.append(" Desc: ").append(message).append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
str.append("----------------------------------\n\n");
|
||||
str.append(error.getStack() == null ? "No stack trace is available" : error.getStack()).append('\n');
|
||||
|
||||
showCrashScreen(str.toString());
|
||||
}
|
||||
if(crashOnUncaughtExceptions) {
|
||||
systemOut.println("ClientMain: [INFO] registering crash handlers");
|
||||
|
||||
});
|
||||
setWindowErrorHandler(new WindowErrorHandler() {
|
||||
|
||||
@Override
|
||||
public void call(String message, String file, int line, int col, JSError error) {
|
||||
StringBuilder str = new StringBuilder();
|
||||
|
||||
str.append("Native Browser Exception\n");
|
||||
str.append("----------------------------------\n");
|
||||
str.append(" Line: ").append((file == null ? "unknown" : file) + ":" + line + ":" + col).append('\n');
|
||||
str.append(" Type: ").append(error == null ? "generic" : error.getName()).append('\n');
|
||||
|
||||
if(error != null) {
|
||||
str.append(" Desc: ").append(error.getMessage() == null ? "null" : error.getMessage()).append('\n');
|
||||
}
|
||||
|
||||
if(message != null) {
|
||||
if(error == null || error.getMessage() == null || !message.endsWith(error.getMessage())) {
|
||||
str.append(" Desc: ").append(message).append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
str.append("----------------------------------\n\n");
|
||||
str.append(error.getStack() == null ? "No stack trace is available" : error.getStack()).append('\n');
|
||||
|
||||
showCrashScreen(str.toString());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
systemOut.println("ClientMain: [INFO] initializing eaglercraftx runtime");
|
||||
|
||||
@ -212,6 +217,7 @@ public class ClientMain {
|
||||
public static HTMLElement configRootElement = null;
|
||||
public static EPKFileEntry[] configEPKFiles = null;
|
||||
public static String configLocalesFolder = null;
|
||||
public static boolean crashOnUncaughtExceptions = false;
|
||||
|
||||
@JSFunctor
|
||||
private static interface WindowErrorHandler extends JSObject {
|
||||
@ -236,61 +242,97 @@ public class ClientMain {
|
||||
private static boolean isCrashed = false;
|
||||
|
||||
public static void showCrashScreen(String t) {
|
||||
StringBuilder strBeforeBuilder = new StringBuilder();
|
||||
strBeforeBuilder.append("Game Crashed! I have fallen and I can't get up!\n\n");
|
||||
strBeforeBuilder.append(t);
|
||||
strBeforeBuilder.append('\n').append('\n');
|
||||
String strBefore = strBeforeBuilder.toString();
|
||||
|
||||
HTMLDocument doc = Window.current().getDocument();
|
||||
if(configRootElement == null) {
|
||||
configRootElement = doc.getElementById(configRootElementId);
|
||||
}
|
||||
|
||||
HTMLElement el = configRootElement;
|
||||
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append("eaglercraft.version = \"").append(EaglercraftVersion.projectForkVersion).append("\"\n");
|
||||
str.append("eaglercraft.minecraft = \"1.8.8\"\n");
|
||||
str.append("eaglercraft.brand = \"" + EaglercraftVersion.projectForkVendor + "\"\n");
|
||||
str.append("eaglercraft.username = \"").append(EaglerProfile.getName()).append("\"\n");
|
||||
str.append('\n');
|
||||
str.append(addWebGLToCrash());
|
||||
str.append('\n');
|
||||
str.append("window.eaglercraftXOpts = ");
|
||||
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');
|
||||
str.append('\n');
|
||||
addDebugNav(str, "userAgent");
|
||||
addDebugNav(str, "vendor");
|
||||
addDebugNav(str, "language");
|
||||
addDebugNav(str, "hardwareConcurrency");
|
||||
addDebugNav(str, "deviceMemory");
|
||||
addDebugNav(str, "platform");
|
||||
addDebugNav(str, "product");
|
||||
addDebugNavPlugins(str);
|
||||
str.append('\n');
|
||||
addDebug(str, "localStorage");
|
||||
addDebug(str, "sessionStorage");
|
||||
addDebug(str, "indexedDB");
|
||||
str.append('\n');
|
||||
str.append("rootElement.clientWidth = ").append(el == null ? "undefined" : el.getClientWidth()).append('\n');
|
||||
str.append("rootElement.clientHeight = ").append(el == null ? "undefined" : el.getClientHeight()).append('\n');
|
||||
addDebug(str, "innerWidth");
|
||||
addDebug(str, "innerHeight");
|
||||
addDebug(str, "outerWidth");
|
||||
addDebug(str, "outerHeight");
|
||||
addDebug(str, "devicePixelRatio");
|
||||
addDebugScreen(str, "availWidth");
|
||||
addDebugScreen(str, "availHeight");
|
||||
addDebugScreen(str, "colorDepth");
|
||||
addDebugScreen(str, "pixelDepth");
|
||||
str.append('\n');
|
||||
addDebug(str, "minecraftServer");
|
||||
str.append('\n');
|
||||
addDebugLocation(str, "href");
|
||||
str.append('\n');
|
||||
String strAfter = str.toString();
|
||||
|
||||
String strFinal = strBefore + strAfter;
|
||||
List<String> additionalInfo = new LinkedList();
|
||||
try {
|
||||
TeaVMClientConfigAdapter.instance.getHooks().callCrashReportHook(strFinal, additionalInfo::add);
|
||||
}catch(Throwable tt) {
|
||||
System.err.println("Uncaught exception invoking crash report hook!");
|
||||
EagRuntime.debugPrintStackTraceToSTDERR(tt);
|
||||
}
|
||||
|
||||
if(!isCrashed) {
|
||||
isCrashed = true;
|
||||
|
||||
HTMLDocument doc = Window.current().getDocument();
|
||||
if(configRootElement == null) {
|
||||
configRootElement = doc.getElementById(configRootElementId);
|
||||
if(additionalInfo.size() > 0) {
|
||||
try {
|
||||
StringBuilder builderFinal = new StringBuilder();
|
||||
builderFinal.append(strBefore);
|
||||
builderFinal.append("Got the following messages from the crash report hook registered in eaglercraftXOpts:\n\n");
|
||||
for(String str2 : additionalInfo) {
|
||||
builderFinal.append("----------[ CRASH HOOK ]----------\n");
|
||||
builderFinal.append(str2).append('\n');
|
||||
builderFinal.append("----------------------------------\n\n");
|
||||
}
|
||||
builderFinal.append(strAfter);
|
||||
strFinal = builderFinal.toString();
|
||||
}catch(Throwable tt) {
|
||||
System.err.println("Uncaught exception concatenating crash report hook messages!");
|
||||
EagRuntime.debugPrintStackTraceToSTDERR(tt);
|
||||
}
|
||||
}
|
||||
|
||||
HTMLElement el = configRootElement;
|
||||
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append("Game Crashed! I have fallen and I can't get up!\n\n");
|
||||
str.append(t);
|
||||
str.append('\n').append('\n');
|
||||
str.append("eaglercraft.version = \"").append(EaglercraftVersion.projectForkVersion).append("\"\n");
|
||||
str.append("eaglercraft.minecraft = \"1.8.8\"\n");
|
||||
str.append("eaglercraft.brand = \"" + EaglercraftVersion.projectForkVendor + "\"\n");
|
||||
str.append("eaglercraft.username = \"").append(EaglerProfile.getName()).append("\"\n");
|
||||
str.append('\n');
|
||||
str.append(addWebGLToCrash());
|
||||
str.append('\n');
|
||||
str.append("window.eaglercraftXOpts = ");
|
||||
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');
|
||||
str.append('\n');
|
||||
addDebugNav(str, "userAgent");
|
||||
addDebugNav(str, "vendor");
|
||||
addDebugNav(str, "language");
|
||||
addDebugNav(str, "hardwareConcurrency");
|
||||
addDebugNav(str, "deviceMemory");
|
||||
addDebugNav(str, "platform");
|
||||
addDebugNav(str, "product");
|
||||
str.append('\n');
|
||||
str.append("rootElement.clientWidth = ").append(el == null ? "undefined" : el.getClientWidth()).append('\n');
|
||||
str.append("rootElement.clientHeight = ").append(el == null ? "undefined" : el.getClientHeight()).append('\n');
|
||||
addDebug(str, "innerWidth");
|
||||
addDebug(str, "innerHeight");
|
||||
addDebug(str, "outerWidth");
|
||||
addDebug(str, "outerHeight");
|
||||
addDebug(str, "devicePixelRatio");
|
||||
addDebugScreen(str, "availWidth");
|
||||
addDebugScreen(str, "availHeight");
|
||||
addDebugScreen(str, "colorDepth");
|
||||
addDebugScreen(str, "pixelDepth");
|
||||
str.append('\n');
|
||||
addDebug(str, "currentContext");
|
||||
str.append('\n');
|
||||
addDebugLocation(str, "href");
|
||||
str.append('\n');
|
||||
|
||||
if(el == null) {
|
||||
Window.alert("Root element not found, crash report was printed to console");
|
||||
System.err.println(str.toString());
|
||||
System.err.println(strFinal);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -303,7 +345,7 @@ public class ClientMain {
|
||||
div.setAttribute("style", "z-index:100;position:absolute;top:135px;left:10%;right:10%;bottom:50px;background-color:white;border:1px solid #cccccc;overflow-x:hidden;overflow-y:scroll;overflow-wrap:break-word;white-space:pre-wrap;font: 14px monospace;padding:10px;");
|
||||
el.appendChild(img);
|
||||
el.appendChild(div);
|
||||
div.appendChild(doc.createTextNode(str.toString()));
|
||||
div.appendChild(doc.createTextNode(strFinal));
|
||||
|
||||
PlatformRuntime.removeEventHandlers();
|
||||
|
||||
@ -314,10 +356,29 @@ public class ClientMain {
|
||||
for(int i = 0; i < s.length; ++i) {
|
||||
System.err.println(" " + s[i]);
|
||||
}
|
||||
if(additionalInfo.size() > 0) {
|
||||
for(String str2 : additionalInfo) {
|
||||
if(str2 != null) {
|
||||
System.err.println();
|
||||
System.err.println(" ----------[ CRASH HOOK ]----------");
|
||||
s = str2.split("[\\r\\n]+");
|
||||
for(int i = 0; i < s.length; ++i) {
|
||||
System.err.println(" " + s[i]);
|
||||
}
|
||||
System.err.println(" ----------------------------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String webGLCrashStringCache = null;
|
||||
|
||||
private static String addWebGLToCrash() {
|
||||
if(webGLCrashStringCache != null) {
|
||||
return webGLCrashStringCache;
|
||||
}
|
||||
|
||||
StringBuilder ret = new StringBuilder();
|
||||
|
||||
WebGLRenderingContext ctx = PlatformRuntime.webgl;
|
||||
@ -328,7 +389,11 @@ public class ClientMain {
|
||||
cvs.setWidth(64);
|
||||
cvs.setHeight(64);
|
||||
|
||||
ctx = (WebGLRenderingContext)cvs.getContext("webgl");
|
||||
ctx = (WebGLRenderingContext)cvs.getContext("webgl2");
|
||||
|
||||
if(ctx == null) {
|
||||
ctx = (WebGLRenderingContext)cvs.getContext("webgl");
|
||||
}
|
||||
}
|
||||
|
||||
if(ctx != null) {
|
||||
@ -345,12 +410,13 @@ public class ClientMain {
|
||||
//ret.append('\n').append("\nwebgl.anisotropicGlitch = ").append(DetectAnisotropicGlitch.hasGlitch()).append('\n'); //TODO
|
||||
ret.append('\n').append("webgl.ext.HDR16f = ").append(ctx.getExtension("EXT_color_buffer_half_float") != null).append('\n');
|
||||
ret.append("webgl.ext.HDR32f = ").append(ctx.getExtension("EXT_color_buffer_float") != null).append('\n');
|
||||
ret.append("webgl.ext.HDR32f_linear = ").append(ctx.getExtension("OES_texture_float_linear") != null).append('\n');
|
||||
|
||||
}else {
|
||||
ret.append("Failed to query GPU info!\n");
|
||||
}
|
||||
|
||||
return ret.toString();
|
||||
return webGLCrashStringCache = ret.toString();
|
||||
}
|
||||
|
||||
public static void showIncompatibleScreen(String t) {
|
||||
@ -486,6 +552,13 @@ public class ClientMain {
|
||||
@JSBody(params = { "v" }, script = "try { return \"\"+window.location[v]; } catch(e) { return \"<error>\"; }")
|
||||
private static native String getStringLocation(String var);
|
||||
|
||||
@JSBody(params = { }, script = "try { var retObj = new Array; if(typeof window.navigator.plugins === \"object\")"
|
||||
+ "{ var len = window.navigator.plugins.length; if(len > 0) { for(var idx = 0; idx < len; ++idx) {"
|
||||
+ "var thePlugin = window.navigator.plugins[idx]; retObj.push({ name: thePlugin.name,"
|
||||
+ "filename: thePlugin.filename, desc: thePlugin.description }); } } } return JSON.stringify(retObj);"
|
||||
+ "} catch(e) { return \"<error>\"; }")
|
||||
private static native String getStringNavPlugins();
|
||||
|
||||
private static void addDebug(StringBuilder str, String var) {
|
||||
str.append("window.").append(var).append(" = ").append(getString(var)).append('\n');
|
||||
}
|
||||
@ -494,6 +567,10 @@ public class ClientMain {
|
||||
str.append("window.navigator.").append(var).append(" = ").append(getStringNav(var)).append('\n');
|
||||
}
|
||||
|
||||
private static void addDebugNavPlugins(StringBuilder str) {
|
||||
str.append("window.navigator.plugins = ").append(getStringNavPlugins()).append('\n');
|
||||
}
|
||||
|
||||
private static void addDebugScreen(StringBuilder str, String var) {
|
||||
str.append("window.screen.").append(var).append(" = ").append(getStringScreen(var)).append('\n');
|
||||
}
|
||||
|
@ -64,13 +64,15 @@ public class DebugConsoleWindow {
|
||||
destroyWindow();
|
||||
}
|
||||
});
|
||||
if("true".equals(parent.getLocalStorage().getItem(PlatformRuntime.getClientConfigAdapter().getLocalStorageNamespace() + ".showDebugConsole"))) {
|
||||
if(parent.getLocalStorage() != null && "true".equals(parent.getLocalStorage().getItem(PlatformRuntime.getClientConfigAdapter().getLocalStorageNamespace() + ".showDebugConsole"))) {
|
||||
showDebugConsole0();
|
||||
}
|
||||
}
|
||||
|
||||
public static void showDebugConsole() {
|
||||
parent.getLocalStorage().setItem(PlatformRuntime.getClientConfigAdapter().getLocalStorageNamespace() + ".showDebugConsole", "true");
|
||||
if(parent.getLocalStorage() != null) {
|
||||
parent.getLocalStorage().setItem(PlatformRuntime.getClientConfigAdapter().getLocalStorageNamespace() + ".showDebugConsole", "true");
|
||||
}
|
||||
showDebugConsole0();
|
||||
}
|
||||
|
||||
@ -108,7 +110,9 @@ public class DebugConsoleWindow {
|
||||
public void handleEvent(Event evt) {
|
||||
if(logger != null) {
|
||||
logger = null;
|
||||
parent.getLocalStorage().setItem("_eaglercraftX.showDebugConsole", "false");
|
||||
if(parent.getLocalStorage() != null) {
|
||||
parent.getLocalStorage().setItem(PlatformRuntime.getClientConfigAdapter().getLocalStorageNamespace() + ".showDebugConsole", "false");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -61,6 +61,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
||||
private String localStorageNamespace = "_eaglercraftX";
|
||||
private final TeaVMClientConfigAdapterHooks hooks = new TeaVMClientConfigAdapterHooks();
|
||||
private boolean enableMinceraft = true;
|
||||
private boolean crashOnUncaughtExceptions = false;
|
||||
|
||||
public void loadNative(JSObject jsObject) {
|
||||
integratedServerOpts = new JSONObject();
|
||||
@ -83,6 +84,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
||||
allowFNAWSkins = !demoMode && eaglercraftXOpts.getAllowFNAWSkins(true);
|
||||
localStorageNamespace = eaglercraftXOpts.getLocalStorageNamespace(EaglercraftVersion.localStorageNamespace);
|
||||
enableMinceraft = eaglercraftXOpts.getEnableMinceraft(true);
|
||||
crashOnUncaughtExceptions = eaglercraftXOpts.getCrashOnUncaughtExceptions(false);
|
||||
JSEaglercraftXOptsHooks hooksObj = eaglercraftXOpts.getHooks();
|
||||
if(hooksObj != null) {
|
||||
hooks.loadHooks(hooksObj);
|
||||
@ -95,6 +97,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
||||
integratedServerOpts.put("allowUpdateDL", isAllowUpdateDL);
|
||||
integratedServerOpts.put("allowVoiceClient", allowVoiceClient);
|
||||
integratedServerOpts.put("allowFNAWSkins", allowFNAWSkins);
|
||||
integratedServerOpts.put("crashOnUncaughtExceptions", crashOnUncaughtExceptions);
|
||||
|
||||
JSArrayReader<JSEaglercraftXOptsServer> serversArray = eaglercraftXOpts.getServers();
|
||||
if(serversArray != null) {
|
||||
@ -178,6 +181,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
||||
allowFNAWSkins = eaglercraftOpts.optBoolean("allowFNAWSkins", true);
|
||||
localStorageNamespace = eaglercraftOpts.optString("localStorageNamespace", EaglercraftVersion.localStorageNamespace);
|
||||
enableMinceraft = eaglercraftOpts.optBoolean("enableMinceraft", true);
|
||||
crashOnUncaughtExceptions = eaglercraftOpts.optBoolean("crashOnUncaughtExceptions", false);
|
||||
JSONArray serversArray = eaglercraftOpts.optJSONArray("servers");
|
||||
if(serversArray != null) {
|
||||
for(int i = 0, l = serversArray.length(); i < l; ++i) {
|
||||
@ -366,6 +370,7 @@ public class TeaVMClientConfigAdapter implements IClientConfigAdapter {
|
||||
jsonObject.put("allowFNAWSkins", allowFNAWSkins);
|
||||
jsonObject.put("localStorageNamespace", localStorageNamespace);
|
||||
jsonObject.put("enableMinceraft", enableMinceraft);
|
||||
jsonObject.put("crashOnUncaughtExceptions", crashOnUncaughtExceptions);
|
||||
JSONArray serversArr = new JSONArray();
|
||||
for(int i = 0, l = defaultServers.size(); i < l; ++i) {
|
||||
DefaultServer srv = defaultServers.get(i);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.internal.teavm;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.teavm.interop.Async;
|
||||
@ -34,6 +35,7 @@ public class TeaVMClientConfigAdapterHooks implements IClientConfigAdapterHooks
|
||||
|
||||
private LocalStorageSaveHook saveHook = null;
|
||||
private LocalStorageLoadHook loadHook = null;
|
||||
private CrashReportHook crashHook = null;
|
||||
|
||||
@JSFunctor
|
||||
private static interface LocalStorageSaveHook extends JSObject {
|
||||
@ -65,6 +67,25 @@ public class TeaVMClientConfigAdapterHooks implements IClientConfigAdapterHooks
|
||||
}
|
||||
}
|
||||
|
||||
@JSFunctor
|
||||
private static interface CrashReportHook extends JSObject {
|
||||
void call(String crashReport, CustomMessageCB customMessageCB);
|
||||
}
|
||||
|
||||
@JSFunctor
|
||||
private static interface CustomMessageCB extends JSObject {
|
||||
void call(String msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callCrashReportHook(String crashReport, Consumer<String> customMessageCB) {
|
||||
if(crashHook != null) {
|
||||
callHookSafeSync("crashReportShow", () -> {
|
||||
crashHook.call(crashReport, (msg) -> customMessageCB.accept(msg));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static void callHookSafe(String identifer, Runnable hooker) {
|
||||
Window.setTimeout(() -> {
|
||||
try {
|
||||
@ -76,6 +97,22 @@ public class TeaVMClientConfigAdapterHooks implements IClientConfigAdapterHooks
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@Async
|
||||
private static native void callHookSafeSync(String identifer, Runnable hooker);
|
||||
|
||||
private static void callHookSafeSync(String identifer, Runnable hooker, final AsyncCallback<Void> cb) {
|
||||
Window.setTimeout(() -> {
|
||||
try {
|
||||
hooker.run();
|
||||
}catch(Throwable t) {
|
||||
logger.error("Caught exception while invoking eaglercraftXOpts \"{}\" hook!", identifer);
|
||||
logger.error(t);
|
||||
}finally {
|
||||
cb.complete(null);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@Async
|
||||
private static native Object callHookSafeWithReturn(String identifer, Supplier<Object> hooker);
|
||||
|
||||
@ -96,5 +133,6 @@ public class TeaVMClientConfigAdapterHooks implements IClientConfigAdapterHooks
|
||||
public void loadHooks(JSEaglercraftXOptsHooks hooks) {
|
||||
saveHook = (LocalStorageSaveHook)hooks.getLocalStorageSavedHook();
|
||||
loadHook = (LocalStorageLoadHook)hooks.getLocalStorageLoadedHook();
|
||||
crashHook = (CrashReportHook)hooks.getCrashReportHook();
|
||||
}
|
||||
}
|
||||
|
@ -26,4 +26,7 @@ public abstract class JSEaglercraftXOptsHooks implements JSObject {
|
||||
@JSBody(script = "return (typeof this.localStorageLoaded === \"function\") ? this.localStorageLoaded : null;")
|
||||
public native JSObject getLocalStorageLoadedHook();
|
||||
|
||||
@JSBody(script = "return (typeof this.crashReportShow === \"function\") ? this.crashReportShow : null;")
|
||||
public native JSObject getCrashReportHook();
|
||||
|
||||
}
|
||||
|
@ -96,4 +96,7 @@ public abstract class JSEaglercraftXOptsRoot implements JSObject {
|
||||
@JSBody(params = { "def" }, script = "return (typeof this.enableMinceraft === \"boolean\") ? this.enableMinceraft : def;")
|
||||
public native boolean getEnableMinceraft(boolean defaultValue);
|
||||
|
||||
@JSBody(params = { "def" }, script = "return (typeof this.crashOnUncaughtExceptions === \"boolean\") ? this.crashOnUncaughtExceptions : def;")
|
||||
public native boolean getCrashOnUncaughtExceptions(boolean defaultValue);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user