made a JSON version of minecraftOpts

This commit is contained in:
LAX1DUDE 2022-07-31 02:03:22 -07:00
parent 876e8b1a35
commit 722166ee9f
12 changed files with 23141 additions and 23029 deletions

View File

@ -1,2 +0,0 @@
importScripts("classes_server.js");
main();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -10,16 +10,19 @@ if(document.location.href.startsWith("file:")) {
alert("You're not supposed to 'open' this file in your browser. Please upload this folder to your HTTP(s) server and access it via the internet. This is not a bug, please read the documentation");
}else {
window.addEventListener("load", function(){
window.minecraftOpts = [
"game_frame","assets.epk",
"CgAACQAHc2VydmVycwoAAAABCAAEbmFtZQAMbG9jYWwgc2VydmVyCAACaXAAD2xvY2FsaG9zdDoyNTU2NQEAC2hpZGVBZGRyZXNzAAAKAAhtYWluTWVudQkACHNwbGFzaGVzCAAAAAoACkRhcnZpZ2xldCEADkRhcnZpZ2xvcGhpbGUhAAtZb3UgRWFnbGVyIQALWWVlZWVlZWVlZSEAC1lvdSBZZWVsZXIhAA1FRUVFRUVFRUVFRUUhAAtZb3UgRGFydmlnIQAJWW91IFZpZ2chAAI6PgACfD4AAA=="
];
window.eaglercraftOpts = {
container: "game_frame", assetsURI: "assets.epk", serverWorkerURI: "worker_bootstrap.js", worldsFolder: "TEST",
servers: [ { serverName: "Local Test Server", serverAddress: "localhost:25565", hideAddress: false } ],
mainMenu: { splashes: [
"Darviglet!", "eaglerenophile!", "You Eagler!", "Yeeeeeee!", "yeee",
"EEEEEEEEE!", "You Darvig!", "You Vigg!", ":>", "|>", "You Yumpster!"
]}};
(function(){
var q = window.location.search;
if(typeof q === 'string' && q.startsWith("?")) {
q = new URLSearchParams(q);
var s = q.get("server");
if(s) window.minecraftOpts.push(s);
if(s) window.eaglercraftOpts.joinServer = s;
}
})();
main();

View File

@ -0,0 +1,5 @@
onmessage = function(o) {
importScripts("classes_server.js");
eaglercraftServerOpts = o.data;
main();
};

View File

@ -1,40 +1,19 @@
package net.lax1dude.eaglercraft.sp;
import org.teavm.jso.JSBody;
import net.lax1dude.eaglercraft.sp.VirtualFilesystem.VFSHandle;
public class SYS {
//public static final boolean PERSIST;
public static final VirtualFilesystem VFS;
/*
@JSFunctor
private interface PromiseHandler extends JSObject {
void complete(JSObject result);
}
@Async
private static native BooleanResult requestPersist();
private static void requestPersist(AsyncCallback<BooleanResult> callback) {
requestPersist0(res -> callback.complete(BooleanResult._new(res != null)));
}
@JSBody(params = { "callback" }, script = "if(navigator.storage && navigator.storage.persist){"
+ "navigator.storage.persist().then(function(persistent) {callback(persistent ? {p:true} : null);});"
+ "}else{callback(null);}")
private static native void requestPersist0(PromiseHandler callback);
*/
@JSBody(params = { }, script = "return eaglercraftServerOpts.worldDatabaseName;")
private static native String getWorldDatabaseName();
static {
//PERSIST = requestPersist().bool;
//if(!PERSIST) {
// Window.alert("PERSISTENT STORAGE NOT AVAILABLE, YOUR BROWSER MAY DELETE YOUR WORLDS!");
//}
VFSHandle vh = VirtualFilesystem.openVFS("_net_lax1dude_eaglercraft_sp_VirtualFilesystem_1_5_2");
VFSHandle vh = VirtualFilesystem.openVFS("_net_lax1dude_eaglercraft_sp_VirtualFilesystem_1_5_2_" + getWorldDatabaseName());
if(vh.vfs == null) {
System.err.println("Could not init filesystem!");

View File

@ -22,5 +22,7 @@ public class ConfigConstants {
public static String mainMenuItemLink = null;
public static List<String> splashTexts = null;
public static boolean eaglercraftTitleLogo = false;
}

View File

@ -2,11 +2,15 @@ package net.minecraft.src;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONObject;
import net.lax1dude.eaglercraft.*;
import net.lax1dude.eaglercraft.ServerQuery.QueryResponse;
import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.RateLimit;
@ -64,6 +68,52 @@ public class ServerList {
e.printStackTrace();
}
}
public static void loadDefaultServers(JSONObject json) {
ConfigConstants.profanity = json.optBoolean("profanity", ConfigConstants.profanity);
hideDownDefaultServers = json.optBoolean("hideDownServers", hideDownDefaultServers);
ConfigConstants.ayonullTitle = json.optString("serverListTitle", ConfigConstants.ayonullTitle);
ConfigConstants.ayonullLink = json.optString("serverListLink", ConfigConstants.ayonullLink);
JSONObject mainMenu = json.optJSONObject("mainMenu", null);
if(mainMenu != null) {
ConfigConstants.mainMenuItemLink = mainMenu.optString("itemLink", ConfigConstants.mainMenuItemLink);
if(ConfigConstants.mainMenuItemLink != null) {
ConfigConstants.mainMenuItemLine0 = mainMenu.optString("itemLine0", ConfigConstants.mainMenuItemLine0);
ConfigConstants.mainMenuItemLine1 = mainMenu.optString("itemLine1", ConfigConstants.mainMenuItemLine1);
ConfigConstants.mainMenuItemLine2 = mainMenu.optString("itemLine2", ConfigConstants.mainMenuItemLine2);
}
ConfigConstants.eaglercraftTitleLogo = mainMenu.optBoolean("eaglerLogo", ConfigConstants.eaglercraftTitleLogo);
JSONArray splashes = mainMenu.optJSONArray("splashes");
if(splashes != null) {
ConfigConstants.splashTexts = new ArrayList();
for(int i = 0, l = splashes.length(); i < l; ++i) {
ConfigConstants.splashTexts.add(splashes.getString(i));
}
}
}
JSONArray servers = json.optJSONArray("servers");
if(servers != null) {
forcedServers.clear();
for(int i = 0, l = servers.length(); i < l; ++i) {
JSONObject serverJSON = servers.getJSONObject(i);
ServerData newServer = new ServerData(serverJSON.getString("serverName"),
serverJSON.getString("serverAddress"), true);
newServer.setHideAddress(serverJSON.optBoolean("hideAddress", false));
forcedServers.add(newServer);
}
}
}
/**
* Loads a list of servers from servers.dat, by running

File diff suppressed because one or more lines are too long

View File

@ -196,6 +196,7 @@ public class EaglerAdapterImpl2 {
private static EventListener keypress = null;
private static EventListener wheel = null;
private static String[] identifier = new String[0];
private static String integratedServerScript = "worker_bootstrap.js";
public static final String[] getIdentifier() {
return identifier;
@ -219,12 +220,13 @@ public class EaglerAdapterImpl2 {
@JSBody(params = { "e" }, script = "return e.which;")
private static native int getWhich(KeyboardEvent e);
public static final void initializeContext(HTMLElement rootElement, String assetPackageURI) {
public static final void initializeContext(HTMLElement rootElement, String assetPackageURI, String serverWorkerURI) {
parent = rootElement;
String s = parent.getAttribute("style");
parent.setAttribute("style", (s == null ? "" : s)+"overflow-x:hidden;overflow-y:hidden;");
win = Window.current();
doc = win.getDocument();
integratedServerScript = serverWorkerURI;
canvas = (HTMLCanvasElement)doc.createElement("canvas");
canvas.setWidth(parent.getClientWidth());
canvas.setHeight(parent.getClientHeight());
@ -2764,25 +2766,35 @@ public class EaglerAdapterImpl2 {
@JSBody(params = { "w", "wb" }, script = "w.onmessage = function(o) { wb(o.data.ch, o.data.dat); };")
private static native void registerPacketHandler(Worker w, WorkerBinaryPacketHandler wb);
@JSBody(params = { "w", "ch", "dat" }, script = "w.postMessage({ ch: ch, dat : dat });")
private static native void sendWorkerPacket(Worker w, String channel, ArrayBuffer arr);
@JSBody(params = { "w", "dbName" }, script = "w.postMessage({ worldDatabaseName : dbName });")
private static native void sendWorkerStartPacket(Worker w, String dbName);
private static String worldDatabaseName = "MAIN";
public static final void beginLoadingIntegratedServer() {
if(server != null) {
server.terminate();
}
workerMessageQueue.put("IPC", new LinkedList<PKT>());
server = Worker.create("bootstrap.js");
server = Worker.create(integratedServerScript);
server.onError(new EventListener<ErrorEvent>() {
@Override
public void handleEvent(ErrorEvent evt) {
System.err.println("Worker Error: " + evt.getError());
}
});
sendWorkerStartPacket(server, worldDatabaseName);
registerPacketHandler(server, new WorkerBinaryPacketHandlerImpl());
}
public static final void setWorldDatabaseName(String name) {
worldDatabaseName = name;
}
public static final boolean isIntegratedServerAlive() {
return serverAlive && server != null;
}