mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-27 18:38:14 -05:00
Update #37 - Touch support without userscript, many other feats
This commit is contained in:
Binary file not shown.
@ -1,8 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html style="width:100%;height:100%;background-color:black;">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
|
||||
<meta name="description" content="Play minecraft 1.8 in your browser" />
|
||||
<meta name="keywords" content="eaglercraft, eaglercraftx, minecraft, 1.8, 1.8.8" />
|
||||
<title>EaglercraftX 1.8</title>
|
||||
@ -15,8 +15,8 @@
|
||||
<script type="text/javascript" src="classes.js"></script>
|
||||
<script type="text/javascript">
|
||||
"use strict";
|
||||
window.addEventListener("load", () => {
|
||||
if(document.location.href.startsWith("file:")) {
|
||||
window.addEventListener("load", function() {
|
||||
if(window.location.href.indexOf("file:") === 0) {
|
||||
alert("HTTP please, do not open this file locally, run a local HTTP server and load it via HTTP");
|
||||
}else {
|
||||
var opts = window.eaglercraftXOpts;
|
||||
@ -31,10 +31,10 @@
|
||||
|
||||
if(!opts.joinServer) {
|
||||
var q = window.location.search;
|
||||
if(typeof q === "string" && q.startsWith("?")) {
|
||||
q = new URLSearchParams(q);
|
||||
if((typeof q === "string") && q[0] === "?" && (typeof window.URLSearchParams !== "undefined")) {
|
||||
q = new window.URLSearchParams(q);
|
||||
var s = q.get("server");
|
||||
if(s) opts.joinServer = s;
|
||||
if(s) window.eaglercraftXOpts.joinServer = s;
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +43,6 @@
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body style="margin:0px;width:100vw;height:100vh;overflow:hidden;" id="game_frame">
|
||||
<body style="margin:0px;width:100%;height:100%;overflow:hidden;background-color:black;" id="game_frame">
|
||||
</body>
|
||||
</html>
|
@ -1,8 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html style="width:100%;height:100%;background-color:black;">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
|
||||
<meta name="description" content="Play minecraft 1.8 in your browser" />
|
||||
<meta name="keywords" content="eaglercraft, eaglercraftx, minecraft, 1.8, 1.8.8" />
|
||||
<title>EaglercraftX 1.8</title>
|
||||
@ -15,14 +15,14 @@
|
||||
<script type="text/javascript" src="classes.js"></script>
|
||||
<script type="text/javascript">
|
||||
"use strict";
|
||||
window.addEventListener("load", () => {
|
||||
if(document.location.href.startsWith("file:")) {
|
||||
window.addEventListener("load", function() {
|
||||
if(window.location.href.indexOf("file:") === 0) {
|
||||
alert("HTTP please, do not open this file locally, run a local HTTP server and load it via HTTP");
|
||||
}else {
|
||||
|
||||
// %%%%%%%%% launch options %%%%%%%%%%%%
|
||||
|
||||
const relayId = Math.floor(Math.random() * 3);
|
||||
var relayId = Math.floor(Math.random() * 3);
|
||||
window.eaglercraftXOpts = {
|
||||
demoMode: false,
|
||||
container: "game_frame",
|
||||
@ -42,8 +42,8 @@
|
||||
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
var q = window.location.search;
|
||||
if(typeof q === "string" && q.startsWith("?")) {
|
||||
q = new URLSearchParams(q);
|
||||
if((typeof q === "string") && q[0] === "?" && (typeof window.URLSearchParams !== "undefined")) {
|
||||
q = new window.URLSearchParams(q);
|
||||
var s = q.get("server");
|
||||
if(s) window.eaglercraftXOpts.joinServer = s;
|
||||
}
|
||||
@ -54,6 +54,6 @@
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body style="margin:0px;width:100vw;height:100vh;overflow:hidden;" id="game_frame">
|
||||
<body style="margin:0px;width:100%;height:100%;overflow:hidden;background-color:black;" id="game_frame">
|
||||
</body>
|
||||
</html>
|
@ -251,7 +251,11 @@ public class CompileLatestClientGUI {
|
||||
try {
|
||||
compileResultCode = JavaC.runJavaC(new File(minecraftSrcTmp, "minecraft_src_javadoc.jar"),
|
||||
compiledResultClasses, temporaryDirectory, TeaVMBinaries.getTeaVMRuntimeClasspath(),
|
||||
new File(repositoryFolder, "sources/main/java"), new File(repositoryFolder, "sources/teavm/java"));
|
||||
new File(repositoryFolder, "sources/main/java"),
|
||||
new File(repositoryFolder, "sources/protocol-game/java"),
|
||||
new File(repositoryFolder, "sources/protocol-relay/java"),
|
||||
new File(repositoryFolder, "sources/teavm/java"),
|
||||
new File(repositoryFolder, "sources/teavm-boot-menu/java"));
|
||||
}catch(IOException ex) {
|
||||
throw new CompileFailureException("failed to run javac compiler! " + ex.toString(), ex);
|
||||
}
|
||||
@ -292,10 +296,12 @@ public class CompileLatestClientGUI {
|
||||
teavmClassPath.addAll(Arrays.asList(TeaVMBinaries.getTeaVMRuntimeClasspath()));
|
||||
teavmArgs.put("classPathEntries", teavmClassPath);
|
||||
|
||||
teavmArgs.put("compileClassPathEntries", Arrays.asList((new File(repositoryFolder, "sources/teavmc-classpath/resources")).getAbsolutePath()));
|
||||
|
||||
teavmArgs.put("entryPointName", "main");
|
||||
teavmArgs.put("mainClass", "net.lax1dude.eaglercraft.v1_8.internal.teavm.MainClass");
|
||||
teavmArgs.put("minifying", true);
|
||||
teavmArgs.put("optimizationLevel", "ADVANCED");
|
||||
teavmArgs.put("optimizationLevel", "FULL");
|
||||
teavmArgs.put("targetDirectory", outputDirectory.getAbsolutePath());
|
||||
teavmArgs.put("generateSourceMaps", true);
|
||||
teavmArgs.put("targetFileName", "classes.js");
|
||||
@ -315,6 +321,15 @@ public class CompileLatestClientGUI {
|
||||
frame.finishCompiling(true, "TeaVM reported problems, check the log");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
System.out.println("Patching classes.js with ES6 shim...");
|
||||
|
||||
File classesJS = new File(outputDirectory, "classes.js");
|
||||
|
||||
if(!ES6Compat.patchClassesJS(classesJS, new File(repositoryFolder, "sources/setup/workspace_template/javascript/ES6ShimScript.txt"))) {
|
||||
System.err.println("Error: could not inject shim, continuing anyway because it is not required");
|
||||
}
|
||||
|
||||
File epkCompiler = new File(repositoryFolder, "sources/setup/workspace_template/desktopRuntime/CompileEPK.jar");
|
||||
|
||||
@ -374,8 +389,7 @@ public class CompileLatestClientGUI {
|
||||
File offlineDownloadGenerator = new File(repositoryFolder, "sources/setup/workspace_template/desktopRuntime/MakeOfflineDownload.jar");
|
||||
MakeOfflineDownload.compilerMain(offlineDownloadGenerator, new String[] {
|
||||
(new File(repositoryFolder, "sources/setup/workspace_template/javascript/OfflineDownloadTemplate.txt")).getAbsolutePath(),
|
||||
(new File(outputDirectory, "classes.js")).getAbsolutePath(),
|
||||
(new File(outputDirectory, "assets.epk")).getAbsolutePath(),
|
||||
classesJS.getAbsolutePath(), (new File(outputDirectory, "assets.epk")).getAbsolutePath(),
|
||||
(new File(outputDirectory, "EaglercraftX_1.8_Offline_en_US.html")).getAbsolutePath(),
|
||||
(new File(outputDirectory, "EaglercraftX_1.8_Offline_International.html")).getAbsolutePath(),
|
||||
(new File(outputDirectory, "build/languages.epk")).getAbsolutePath()
|
||||
|
@ -0,0 +1,43 @@
|
||||
package net.lax1dude.eaglercraft.v1_8.buildtools.gui;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
/**
|
||||
* 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 class ES6Compat {
|
||||
|
||||
/**
|
||||
* TODO: remove this when we update TeaVM to 0.10+ (ES6 is impossible)
|
||||
*/
|
||||
public static boolean patchClassesJS(File classesJS, File shimJS) {
|
||||
try {
|
||||
String dest = FileUtils.readFileToString(classesJS, StandardCharsets.UTF_8);
|
||||
int i = dest.substring(0, dest.indexOf("=$rt_globals.Symbol('jsoClass');")).lastIndexOf("let ");
|
||||
dest = dest.substring(0, i) + "var" + dest.substring(i + 3);
|
||||
int j = dest.indexOf("function($rt_globals,$rt_exports){");
|
||||
dest = dest.substring(0, j + 34) + "\n" + FileUtils.readFileToString(shimJS, StandardCharsets.UTF_8) + "\n" + dest.substring(j + 34);
|
||||
FileUtils.writeStringToFile(classesJS, dest, StandardCharsets.UTF_8);
|
||||
return true;
|
||||
}catch(Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -214,7 +214,7 @@ public class TeaVMBinaries {
|
||||
teavmClasslib.file.getAbsolutePath(), teavmInterop.file.getAbsolutePath(), teavmJSO.file.getAbsolutePath(),
|
||||
teavmJSOApis.file.getAbsolutePath(), teavmJSOImpl.file.getAbsolutePath(),
|
||||
teavmMetaprogrammingAPI.file.getAbsolutePath(), teavmMetaprogrammingImpl.file.getAbsolutePath(),
|
||||
teavmPlatform.file.getAbsolutePath() };
|
||||
teavmPlatform.file.getAbsolutePath(), teavmCore.file.getAbsolutePath() };
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import org.json.JSONObject;
|
||||
import net.lax1dude.eaglercraft.v1_8.buildtools.EaglerBuildTools;
|
||||
import net.lax1dude.eaglercraft.v1_8.buildtools.LicensePrompt;
|
||||
import net.lax1dude.eaglercraft.v1_8.buildtools.gui.EPKCompiler;
|
||||
import net.lax1dude.eaglercraft.v1_8.buildtools.gui.ES6Compat;
|
||||
import net.lax1dude.eaglercraft.v1_8.buildtools.gui.JavaC;
|
||||
import net.lax1dude.eaglercraft.v1_8.buildtools.gui.MakeOfflineDownload;
|
||||
import net.lax1dude.eaglercraft.v1_8.buildtools.gui.TeaVMBinaries;
|
||||
@ -60,7 +61,7 @@ public class CompileLatestClientHeadless {
|
||||
|
||||
System.out.println();
|
||||
System.out.println("Launching client compiler...");
|
||||
System.out.println("Copyright (c) 2022-2023 lax1dude");
|
||||
System.out.println("Copyright (c) 2022-2024 lax1dude");
|
||||
System.out.println();
|
||||
|
||||
boolean yes = false;
|
||||
@ -321,7 +322,11 @@ public class CompileLatestClientHeadless {
|
||||
try {
|
||||
compileResultCode = JavaC.runJavaC(new File(minecraftSrcTmp, "minecraft_src_javadoc.jar"),
|
||||
compiledResultClasses, temporaryDirectory, TeaVMBinaries.getTeaVMRuntimeClasspath(),
|
||||
new File(repositoryFolder, "sources/main/java"), new File(repositoryFolder, "sources/teavm/java"));
|
||||
new File(repositoryFolder, "sources/main/java"),
|
||||
new File(repositoryFolder, "sources/protocol-game/java"),
|
||||
new File(repositoryFolder, "sources/protocol-relay/java"),
|
||||
new File(repositoryFolder, "sources/teavm/java"),
|
||||
new File(repositoryFolder, "sources/teavm-boot-menu/java"));
|
||||
}catch(IOException ex) {
|
||||
throw new CompileFailureException("failed to run javac compiler! " + ex.toString(), ex);
|
||||
}
|
||||
@ -362,10 +367,12 @@ public class CompileLatestClientHeadless {
|
||||
teavmClassPath.addAll(Arrays.asList(TeaVMBinaries.getTeaVMRuntimeClasspath()));
|
||||
teavmArgs.put("classPathEntries", teavmClassPath);
|
||||
|
||||
teavmArgs.put("compileClassPathEntries", Arrays.asList((new File(repositoryFolder, "sources/teavmc-classpath/resources")).getAbsolutePath()));
|
||||
|
||||
teavmArgs.put("entryPointName", "main");
|
||||
teavmArgs.put("mainClass", "net.lax1dude.eaglercraft.v1_8.internal.teavm.MainClass");
|
||||
teavmArgs.put("minifying", minifying);
|
||||
teavmArgs.put("optimizationLevel", "ADVANCED");
|
||||
teavmArgs.put("optimizationLevel", "FULL");
|
||||
teavmArgs.put("targetDirectory", outputDirectory.getAbsolutePath());
|
||||
teavmArgs.put("generateSourceMaps", writeSourceMap);
|
||||
teavmArgs.put("targetFileName", "classes.js");
|
||||
@ -388,6 +395,15 @@ public class CompileLatestClientHeadless {
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
System.out.println("Patching classes.js with ES6 shim...");
|
||||
|
||||
File classesJS = new File(outputDirectory, "classes.js");
|
||||
|
||||
if(!ES6Compat.patchClassesJS(classesJS, new File(repositoryFolder, "sources/setup/workspace_template/javascript/ES6ShimScript.txt"))) {
|
||||
System.err.println("Error: could not inject shim, continuing anyway because it is not required");
|
||||
}
|
||||
|
||||
File epkCompiler = new File(repositoryFolder, "sources/setup/workspace_template/desktopRuntime/CompileEPK.jar");
|
||||
|
||||
if(!epkCompiler.exists()) {
|
||||
@ -569,8 +585,7 @@ public class CompileLatestClientHeadless {
|
||||
File offlineDownloadGenerator = new File(repositoryFolder, "sources/setup/workspace_template/desktopRuntime/MakeOfflineDownload.jar");
|
||||
MakeOfflineDownload.compilerMain(offlineDownloadGenerator, new String[] {
|
||||
offlineTemplateArg.getAbsolutePath(),
|
||||
(new File(outputDirectory, "classes.js")).getAbsolutePath(),
|
||||
(new File(outputDirectory, "assets.epk")).getAbsolutePath(),
|
||||
classesJS.getAbsolutePath(), (new File(outputDirectory, "assets.epk")).getAbsolutePath(),
|
||||
(new File(outputDirectory, "EaglercraftX_1.8_Offline_en_US.html")).getAbsolutePath(),
|
||||
(new File(outputDirectory, "EaglercraftX_1.8_Offline_International.html")).getAbsolutePath(),
|
||||
(new File(temporaryDirectory, "languages.epk")).getAbsolutePath()
|
||||
|
@ -10,6 +10,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -65,13 +66,22 @@ public class PullRequestTask {
|
||||
File originalSourceMainJar = new File(EaglerBuildToolsConfig.getTemporaryDirectory(), "MinecraftSrc/minecraft_src_patch.jar");
|
||||
File minecraftJavadocTmp = new File(EaglerBuildToolsConfig.getTemporaryDirectory(), "MinecraftSrc/minecraft_src_javadoc.jar");
|
||||
File originalSourceMain = new File(EaglerBuildTools.repositoryRoot, "sources/main/java");
|
||||
File originalSourceProtoGame = new File(EaglerBuildTools.repositoryRoot, "sources/protocol-game/java");
|
||||
File originalSourceProtoRelay = new File(EaglerBuildTools.repositoryRoot, "sources/protocol-relay/java");
|
||||
File originalSourceTeaVM = new File(EaglerBuildTools.repositoryRoot, "sources/teavm/java");
|
||||
File originalSourceTeaVMC = new File(EaglerBuildTools.repositoryRoot, "sources/teavmc-classpath/resources");
|
||||
File originalSourceBootMenu = new File(EaglerBuildTools.repositoryRoot, "sources/teavm-boot-menu/java");
|
||||
File originalSourceLWJGL = new File(EaglerBuildTools.repositoryRoot, "sources/lwjgl/java");
|
||||
File originalUnpatchedSourceResourcesJar = new File(EaglerBuildToolsConfig.getTemporaryDirectory(), "MinecraftSrc/minecraft_res.jar");
|
||||
File originalSourceResourcesJar = new File(EaglerBuildToolsConfig.getTemporaryDirectory(), "MinecraftSrc/minecraft_res_patch.jar");
|
||||
File originalSourceResources = new File(EaglerBuildTools.repositoryRoot, "sources/resources");
|
||||
File diffFromMain = new File(EaglerBuildToolsConfig.getWorkspaceDirectory(), "src/main/java");
|
||||
File diffFromGame = new File(EaglerBuildToolsConfig.getWorkspaceDirectory(), "src/game/java");
|
||||
File diffFromProtoGame = new File(EaglerBuildToolsConfig.getWorkspaceDirectory(), "src/protocol-game/java");
|
||||
File diffFromProtoRelay = new File(EaglerBuildToolsConfig.getWorkspaceDirectory(), "src/protocol-relay/java");
|
||||
File diffFromTeaVM = new File(EaglerBuildToolsConfig.getWorkspaceDirectory(), "src/teavm/java");
|
||||
File diffFromBootMenu = new File(EaglerBuildToolsConfig.getWorkspaceDirectory(), "src/teavm-boot-menu/java");
|
||||
File diffFromTeaVMC = new File(EaglerBuildToolsConfig.getWorkspaceDirectory(), "src/teavmc-classpath/resources");
|
||||
File diffFromLWJGL = new File(EaglerBuildToolsConfig.getWorkspaceDirectory(), "src/lwjgl/java");
|
||||
File diffFromResources = new File(EaglerBuildToolsConfig.getWorkspaceDirectory(), "desktopRuntime/resources");
|
||||
File pullRequestTo = new File(EaglerBuildTools.repositoryRoot, "pullrequest");
|
||||
@ -111,24 +121,54 @@ public class PullRequestTask {
|
||||
File pullRequestToResources = new File(pullRequestTo, "resources");
|
||||
|
||||
boolean flag = false;
|
||||
int i = copyAllModified(diffFromTeaVM, originalSourceTeaVM);
|
||||
int i = copyAllModified(diffFromMain, originalSourceMain);
|
||||
if(i > 0) {
|
||||
flag = true;
|
||||
}
|
||||
System.out.println("Found " + i + " changed files in /src/main/java/");
|
||||
|
||||
i = copyAllModified(diffFromProtoGame, originalSourceProtoGame);
|
||||
if(i > 0) {
|
||||
flag = true;
|
||||
}
|
||||
System.out.println("Found " + i + " changed files in /src/protocol-game/java/");
|
||||
|
||||
i = copyAllModified(diffFromProtoRelay, originalSourceProtoRelay);
|
||||
if(i > 0) {
|
||||
flag = true;
|
||||
}
|
||||
System.out.println("Found " + i + " changed files in /src/protocol-relay/java/");
|
||||
|
||||
i = copyAllModified(diffFromTeaVM, originalSourceTeaVM);
|
||||
if(i > 0) {
|
||||
flag = true;
|
||||
}
|
||||
System.out.println("Found " + i + " changed files in /src/teavm/java/");
|
||||
|
||||
i = copyAllModified(diffFromBootMenu, originalSourceBootMenu);
|
||||
if(i > 0) {
|
||||
flag = true;
|
||||
}
|
||||
System.out.println("Found " + i + " changed files in /src/teavm-boot-menu/java/");
|
||||
|
||||
i = copyAllModified(diffFromTeaVMC, originalSourceTeaVMC);
|
||||
if(i > 0) {
|
||||
flag = true;
|
||||
}
|
||||
System.out.println("Found " + i + " changed files in /src/teavmc-classpath/resources/");
|
||||
|
||||
i = copyAllModified(diffFromLWJGL, originalSourceLWJGL);
|
||||
if(i > 0) {
|
||||
flag = true;
|
||||
}
|
||||
System.out.println("Found " + i + " changed files in /src/lwjgl/java/");
|
||||
|
||||
i = createDiffFiles(originalSourceMain, minecraftJavadocTmp, originalUnpatchedSourceMainJar,
|
||||
originalSourceMainJar, diffFromMain, pullRequestToMain, true);
|
||||
i = createDiffFiles(null, minecraftJavadocTmp, originalUnpatchedSourceMainJar,
|
||||
originalSourceMainJar, diffFromGame, pullRequestToMain, true);
|
||||
if(i > 0) {
|
||||
flag = true;
|
||||
}
|
||||
System.out.println("Found " + i + " changed files in /src/main/java/");
|
||||
System.out.println("Found " + i + " changed files in /src/game/java/");
|
||||
|
||||
i = createDiffFiles(originalSourceResources, originalSourceResourcesJar, originalUnpatchedSourceResourcesJar,
|
||||
null, diffFromResources, pullRequestToResources, false);
|
||||
@ -197,9 +237,9 @@ public class PullRequestTask {
|
||||
if(newPath.startsWith("/")) {
|
||||
newPath = newPath.substring(1);
|
||||
}
|
||||
File orig = new File(folderOriginal, newPath);
|
||||
File orig = folderOriginal != null ? new File(folderOriginal, newPath) : null;
|
||||
byte[] jarData = null;
|
||||
boolean replacedFileExists = orig.exists();
|
||||
boolean replacedFileExists = orig != null && orig.exists();
|
||||
if(replacedFileExists) {
|
||||
filesReplaced.add(newPath);
|
||||
if(copyFileIfChanged(wf, orig)) {
|
||||
@ -253,9 +293,13 @@ public class PullRequestTask {
|
||||
++cnt;
|
||||
}
|
||||
}else {
|
||||
filesReplaced.add(newPath);
|
||||
FileUtils.copyFile(wf, orig);
|
||||
++cnt;
|
||||
if(folderOriginal == null) {
|
||||
System.err.println("Detected a new file in src/game/java, it will be ignored! Do not created new files! (" + newPath + ")");
|
||||
}else {
|
||||
filesReplaced.add(newPath);
|
||||
FileUtils.copyFile(wf, orig);
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -278,6 +322,10 @@ public class PullRequestTask {
|
||||
}
|
||||
}
|
||||
|
||||
if(folderOriginal != null) {
|
||||
cnt += removeAllDeleted(folderEdited, folderOriginal);
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@ -344,6 +392,33 @@ public class PullRequestTask {
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
cnt += removeAllDeleted(inDir, outDir);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
private static int removeAllDeleted(File inDir, File outDir) throws IOException {
|
||||
if(!inDir.isDirectory()) {
|
||||
return 0;
|
||||
}
|
||||
int cnt = 0;
|
||||
Collection<File> existingFiles = FileUtils.listFiles(outDir, null, true);
|
||||
String existingPrefix = outDir.getAbsolutePath();
|
||||
for(File wf : existingFiles) {
|
||||
String editedPath = wf.getAbsolutePath().replace(existingPrefix, "");
|
||||
if(editedPath.indexOf('\\') != -1) {
|
||||
editedPath = editedPath.replace('\\', '/');
|
||||
}
|
||||
if(editedPath.startsWith("/")) {
|
||||
editedPath = editedPath.substring(1);
|
||||
}
|
||||
File edited = new File(inDir, editedPath);
|
||||
if(!edited.isFile()) {
|
||||
if(!wf.delete()) {
|
||||
throw new IOException("Could not delete file: " + wf.getAbsolutePath());
|
||||
}
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
@ -392,15 +467,6 @@ public class PullRequestTask {
|
||||
return hex32(crc.getValue());
|
||||
}
|
||||
|
||||
private static boolean checkCRC32(File in1, File in2) throws IOException {
|
||||
CRC32 crc = new CRC32();
|
||||
crc.update(FileUtils.readFileToByteArray(in1));
|
||||
long v1 = crc.getValue();
|
||||
crc.reset();
|
||||
crc.update(FileUtils.readFileToByteArray(in2));
|
||||
return v1 != crc.getValue();
|
||||
}
|
||||
|
||||
private static boolean copyFileIfChanged(File in1, File in2) throws IOException {
|
||||
if(!in2.exists()) {
|
||||
FileUtils.copyFile(in1, in2);
|
||||
@ -409,20 +475,14 @@ public class PullRequestTask {
|
||||
if(in1.lastModified() == in2.lastModified()) {
|
||||
return false;
|
||||
}
|
||||
CRC32 crc = new CRC32();
|
||||
byte[] f1 = FileUtils.readFileToByteArray(in1);
|
||||
crc.update(f1);
|
||||
long v1 = crc.getValue();
|
||||
crc.reset();
|
||||
byte[] f2 = FileUtils.readFileToByteArray(in2);
|
||||
crc.update(f2);
|
||||
if(v1 != crc.getValue()) {
|
||||
//System.out.println("changed: " + in1.getAbsolutePath());
|
||||
if(!Arrays.equals(f1, f2)) {
|
||||
FileUtils.writeByteArrayToFile(in2, f1);
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -122,13 +122,22 @@ public class SetupWorkspace {
|
||||
|
||||
File repoSources = new File("./sources");
|
||||
File repoSourcesSetup = new File(repoSources, "setup/workspace_template");
|
||||
File repoSourcesGame = new File(repoSources, "main/java");
|
||||
File repoSourcesMain = new File(repoSources, "main/java");
|
||||
File repoSourcesTeaVM = new File(repoSources, "teavm/java");
|
||||
File repoSourcesLWJGL = new File(repoSources, "lwjgl/java");
|
||||
File repoSourcesProtoGame = new File(repoSources, "protocol-game/java");
|
||||
File repoSourcesProtoRelay = new File(repoSources, "protocol-relay/java");
|
||||
File repoSourcesBootMenu = new File(repoSources, "teavm-boot-menu/java");
|
||||
File repoSourcesTeavmCRes = new File(repoSources, "teavmc-classpath/resources");
|
||||
File repoSourcesResources = new File(repoSources, "resources");
|
||||
File srcMainJava = new File(workspaceDirectory, "src/main/java");
|
||||
File srcGameJava = new File(workspaceDirectory, "src/game/java");
|
||||
File srcLWJGLJava = new File(workspaceDirectory, "src/lwjgl/java");
|
||||
File srcTeaVMJava = new File(workspaceDirectory, "src/teavm/java");
|
||||
File srcProtoGame = new File(workspaceDirectory, "src/protocol-game/java");
|
||||
File srcProtoRelay = new File(workspaceDirectory, "src/protocol-relay/java");
|
||||
File srcBootMenu = new File(workspaceDirectory, "src/teavm-boot-menu/java");
|
||||
File srcTeavmCRes = new File(workspaceDirectory, "src/teavmc-classpath/resources");
|
||||
File resourcesExtractTo = new File(workspaceDirectory, "desktopRuntime/resources");
|
||||
File mcLanguagesZip = new File(mcTmpDirectory, "minecraft_languages.zip");
|
||||
File mcLanguagesExtractTo = new File(workspaceDirectory, "javascript/lang");
|
||||
@ -174,11 +183,55 @@ public class SetupWorkspace {
|
||||
System.out.println("Copying files from \"/sources/main/java/\" to workspace...");
|
||||
|
||||
try {
|
||||
FileUtils.copyDirectory(repoSourcesGame, srcMainJava);
|
||||
FileUtils.copyDirectory(repoSourcesMain, srcMainJava);
|
||||
}catch(IOException ex) {
|
||||
System.err.println("ERROR: could not copy \"/sources/main/java/\" to \"" + srcMainJava.getAbsolutePath() + "\"!");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
if(repoSourcesProtoGame.isDirectory()) {
|
||||
System.out.println("Copying files from \"/sources/protocol-game/java/\" to workspace...");
|
||||
|
||||
try {
|
||||
FileUtils.copyDirectory(repoSourcesProtoGame, srcProtoGame);
|
||||
}catch(IOException ex) {
|
||||
System.err.println("ERROR: could not copy \"/sources/protocol-game/java/\" to \"" + srcProtoGame.getAbsolutePath() + "\"!");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
if(repoSourcesProtoRelay.isDirectory()) {
|
||||
System.out.println("Copying files from \"/sources/protocol-relay/java/\" to workspace...");
|
||||
|
||||
try {
|
||||
FileUtils.copyDirectory(repoSourcesProtoRelay, srcProtoRelay);
|
||||
}catch(IOException ex) {
|
||||
System.err.println("ERROR: could not copy \"/sources/protocol-relay/java/\" to \"" + srcProtoRelay.getAbsolutePath() + "\"!");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
if(repoSourcesTeavmCRes.isDirectory()) {
|
||||
System.out.println("Copying files from \"/sources/teavmc-classpath/resources/\" to workspace...");
|
||||
|
||||
try {
|
||||
FileUtils.copyDirectory(repoSourcesTeavmCRes, srcTeavmCRes);
|
||||
}catch(IOException ex) {
|
||||
System.err.println("ERROR: could not copy \"/sources/teavmc-classpath/resources/\" to \"" + srcTeavmCRes.getAbsolutePath() + "\"!");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
if(repoSourcesBootMenu.isDirectory()) {
|
||||
System.out.println("Copying files from \"/sources/teavm-boot-menu/java/\" to workspace...");
|
||||
|
||||
try {
|
||||
FileUtils.copyDirectory(repoSourcesBootMenu, srcBootMenu);
|
||||
}catch(IOException ex) {
|
||||
System.err.println("ERROR: could not copy \"/sources/teavm-boot-menu/java/\" to \"" + srcBootMenu.getAbsolutePath() + "\"!");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
if(repoSourcesLWJGL.isDirectory()) {
|
||||
System.out.println("Copying files from \"/sources/lwjgl/java/\" to workspace...");
|
||||
@ -255,18 +308,18 @@ public class SetupWorkspace {
|
||||
minecraftResJar = tmpPatchedPatchResOut;
|
||||
|
||||
}else {
|
||||
System.out.println("Extracting files from \"minecraft_src_javadoc.jar\" to \"/src/main/java/\"...");
|
||||
System.out.println("Extracting files from \"minecraft_src_javadoc.jar\" to \"/src/game/java/\"...");
|
||||
}
|
||||
|
||||
try {
|
||||
if(!srcMainJava.isDirectory() && !srcMainJava.mkdirs()) {
|
||||
if(!srcGameJava.isDirectory() && !srcGameJava.mkdirs()) {
|
||||
System.err.println("ERROR: Could not create destination directory!");
|
||||
return false;
|
||||
}
|
||||
extractJarTo(minecraftJavadocTmp, srcMainJava);
|
||||
extractJarTo(minecraftJavadocTmp, srcGameJava);
|
||||
}catch(IOException ex) {
|
||||
System.err.println("ERROR: could not extract \"" + minecraftJavadocTmp.getName() + ".jar\" to \"" +
|
||||
srcMainJava.getAbsolutePath() + "\"!");
|
||||
srcGameJava.getAbsolutePath() + "\"!");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
@ -364,8 +417,11 @@ public class SetupWorkspace {
|
||||
dotClasspathFile = dotClasspathFile.replace("${LIBRARY_CLASSPATH}", String.join(System.lineSeparator(), classpathEntries));
|
||||
FileUtils.writeStringToFile(new File(desktopRuntimeProjectDir, ".classpath"), dotClasspathFile, "UTF-8");
|
||||
|
||||
dotProjectFile = dotProjectFile.replace("${LWJGL_SRC_FOLDER}", bsToS((new File(workspaceDirectory, "src/lwjgl/java")).getAbsolutePath()));
|
||||
dotProjectFile = dotProjectFile.replace("${MAIN_SRC_FOLDER}", bsToS((new File(workspaceDirectory, "src/main/java")).getAbsolutePath()));
|
||||
dotProjectFile = dotProjectFile.replace("${GAME_SRC_FOLDER}", bsToS((new File(workspaceDirectory, "src/game/java")).getAbsolutePath()));
|
||||
dotProjectFile = dotProjectFile.replace("${PROTO_GAME_SRC_FOLDER}", bsToS((new File(workspaceDirectory, "src/protocol-game/java")).getAbsolutePath()));
|
||||
dotProjectFile = dotProjectFile.replace("${PROTO_RELAY_SRC_FOLDER}", bsToS((new File(workspaceDirectory, "src/protocol-relay/java")).getAbsolutePath()));
|
||||
dotProjectFile = dotProjectFile.replace("${LWJGL_SRC_FOLDER}", bsToS((new File(workspaceDirectory, "src/lwjgl/java")).getAbsolutePath()));
|
||||
FileUtils.writeStringToFile(new File(desktopRuntimeProjectDir, ".project"), dotProjectFile, "UTF-8");
|
||||
|
||||
debugRuntimeLaunchConfig = debugRuntimeLaunchConfig.replace("${MAIN_CLASS_FILE}", mainClassConfFile);
|
||||
|
@ -7,6 +7,9 @@ import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.buildtools.gui.TeaVMBinaries;
|
||||
@ -33,6 +36,7 @@ public class TeaVMBridge {
|
||||
/**
|
||||
* <h3>List of required options:</h3>
|
||||
* <table>
|
||||
* <tr><td><b>compileClassPathEntries</b></td><td>-> Additional compiler class path entries</td></tr>
|
||||
* <tr><td><b>classPathEntries</b></td><td>-> BuildStrategy.setClassPathEntries(List<String>)</td></tr>
|
||||
* <tr><td><b>entryPointName</b></td><td>-> BuildStrategy.setEntryPointName(String)</td></tr>
|
||||
* <tr><td><b>mainClass</b></td><td>-> BuildStrategy.setMainClass(String)</td></tr>
|
||||
@ -45,14 +49,20 @@ public class TeaVMBridge {
|
||||
* <br>
|
||||
*/
|
||||
public static boolean compileTeaVM(Map<String, Object> options) throws TeaVMClassLoadException, TeaVMRuntimeException {
|
||||
File[] cp = TeaVMBinaries.getTeaVMCompilerClasspath();
|
||||
URL[] urls = new URL[cp.length];
|
||||
List<File> philes = new ArrayList<>();
|
||||
List<String> things = (List<String>)options.get("compileClassPathEntries");
|
||||
for(int i = 0, l = things.size(); i < l; ++i) {
|
||||
philes.add(new File(things.get(i)));
|
||||
}
|
||||
philes.addAll(Arrays.asList(TeaVMBinaries.getTeaVMCompilerClasspath()));
|
||||
|
||||
for(int i = 0; i < cp.length; ++i) {
|
||||
URL[] urls = new URL[philes.size()];
|
||||
|
||||
for(int i = 0; i < urls.length; ++i) {
|
||||
try {
|
||||
urls[i] = cp[i].toURI().toURL();
|
||||
urls[i] = philes.get(i).toURI().toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
throw new TeaVMClassLoadException("Could not resolve URL for: " + cp[i].getAbsolutePath(), e);
|
||||
throw new TeaVMClassLoadException("Could not resolve URL for: " + philes.get(i).getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user