This commit is contained in:
parent
ae5e9fe74c
commit
2020b895b9
@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
**1.0.2**
|
||||||
|
* Fix 32-Bit OpenJDk Installation
|
||||||
|
|
||||||
**1.0.1**
|
**1.0.1**
|
||||||
* Add Wrapping To Conflict Dialog
|
* Add Wrapping To Conflict Dialog
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
|
|||||||
fabric_loader_version = 0.9.0+build.204
|
fabric_loader_version = 0.9.0+build.204
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.0.1
|
mod_version = 1.0.2
|
||||||
maven_group = com.thebrokenrail
|
maven_group = com.thebrokenrail
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
@ -44,8 +44,7 @@ public class FreshCoffee implements PreLaunchEntrypoint {
|
|||||||
File dir = Util.getJavaDir(jdk.version.semver);
|
File dir = Util.getJavaDir(jdk.version.semver);
|
||||||
|
|
||||||
if (dir.exists()) {
|
if (dir.exists()) {
|
||||||
Util.getLogger().info("Removing Invalid Java Installation: " + dir.getAbsolutePath());
|
Util.removeInvalidJDK(dir);
|
||||||
Util.deleteDirectory(dir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtractUtil.extract(url, dir);
|
ExtractUtil.extract(url, dir);
|
||||||
|
@ -16,6 +16,7 @@ public final class HardcodedConfig {
|
|||||||
public static final String LIMIT_TEXT = "version %s required by %s";
|
public static final String LIMIT_TEXT = "version %s required by %s";
|
||||||
|
|
||||||
public static final String JAVA_IMPLEMENTATION = "hotspot";
|
public static final String JAVA_IMPLEMENTATION = "hotspot";
|
||||||
|
public static final String HEAP_SIZE = "normal";
|
||||||
|
|
||||||
public static final String OUTDATED_JAVA_MESSAGE = "An installed mod requires a newer version of Java (%s).";
|
public static final String OUTDATED_JAVA_MESSAGE = "An installed mod requires a newer version of Java (%s).";
|
||||||
public static final String OUTDATED_JAVA_WITH_OFFER_MESSAGE = OUTDATED_JAVA_MESSAGE + " Would you like to install it?\n%s will be downloaded.";
|
public static final String OUTDATED_JAVA_WITH_OFFER_MESSAGE = OUTDATED_JAVA_MESSAGE + " Would you like to install it?\n%s will be downloaded.";
|
||||||
|
@ -31,7 +31,7 @@ public final class AdoptOpenJDK {
|
|||||||
private String project;
|
private String project;
|
||||||
|
|
||||||
private boolean isValid() {
|
private boolean isValid() {
|
||||||
return heap_size.equals("normal") && image_type.equals("jre") && project.equals("jdk") && (packageObj.link.endsWith(".zip") || packageObj.link.endsWith(".tar.gz"));
|
return heap_size.equals(HardcodedConfig.HEAP_SIZE) && image_type.equals("jre") && project.equals("jdk") && (packageObj.link.endsWith(".zip") || packageObj.link.endsWith(".tar.gz"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ public final class AdoptOpenJDK {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] PLATFORM_TYPES = new String[]{"linux", "win", "macosx"};
|
private static final String[] PLATFORM_TYPES = new String[]{"linux", "win", "macosx"};
|
||||||
private static final String[] ARCHITECTURE_TYPES = new String[]{"x64", "i686", "aarch64", "arm32"};
|
private static final String[] ARCHITECTURE_TYPES = new String[]{"x64", "x32", "aarch64", "arm"};
|
||||||
|
|
||||||
private static final Platform[] PLATFORMS;
|
private static final Platform[] PLATFORMS;
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@ public final class PlatformUtil {
|
|||||||
case "x86":
|
case "x86":
|
||||||
case "i386":
|
case "i386":
|
||||||
case "i686": {
|
case "i686": {
|
||||||
return "i686";
|
return "x32";
|
||||||
}
|
}
|
||||||
case "amd64": {
|
case "amd64": {
|
||||||
return "x64";
|
return "x64";
|
||||||
}
|
}
|
||||||
case "arm": {
|
case "arm": {
|
||||||
return "arm32";
|
return "arm";
|
||||||
}
|
}
|
||||||
case "aarch64_be":
|
case "aarch64_be":
|
||||||
case "armv8b":
|
case "armv8b":
|
||||||
|
@ -110,6 +110,23 @@ public final class ReLaunchUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean testJavaBinary(String javaBinary) {
|
||||||
|
Process process;
|
||||||
|
try {
|
||||||
|
process = new ProcessBuilder(javaBinary, "-version").start();
|
||||||
|
} catch (IOException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
int status = process.waitFor();
|
||||||
|
return status == 0;
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
process.destroy();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void reLaunch() {
|
public static void reLaunch() {
|
||||||
File[] files = HardcodedConfig.INSTALL_DIR.listFiles();
|
File[] files = HardcodedConfig.INSTALL_DIR.listFiles();
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
@ -123,10 +140,13 @@ public final class ReLaunchUtil {
|
|||||||
String newestVersion = JavaVersionUtil.getNewest(list.toArray(new String[0]));
|
String newestVersion = JavaVersionUtil.getNewest(list.toArray(new String[0]));
|
||||||
|
|
||||||
if (newestVersion != null) {
|
if (newestVersion != null) {
|
||||||
File javaBinary = new File(new File(Util.getJavaDir(newestVersion), "bin"), "java" + PlatformUtil.getExecutableExtension());
|
File javaDir = Util.getJavaDir(newestVersion);
|
||||||
if (javaBinary.exists() && javaBinary.canExecute()) {
|
File javaBinary = new File(new File(javaDir, "bin"), "java" + PlatformUtil.getExecutableExtension());
|
||||||
|
if (javaBinary.exists() && javaBinary.canExecute() && testJavaBinary(javaBinary.getAbsolutePath())) {
|
||||||
Util.getLogger().info("Using Java Executable: " + javaBinary.getAbsolutePath());
|
Util.getLogger().info("Using Java Executable: " + javaBinary.getAbsolutePath());
|
||||||
reLaunch(javaBinary.getAbsolutePath());
|
reLaunch(javaBinary.getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
Util.removeInvalidJDK(javaDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public final class Util {
|
|||||||
return new File(HardcodedConfig.INSTALL_DIR, version);
|
return new File(HardcodedConfig.INSTALL_DIR, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteDirectory(File directoryToBeDeleted) {
|
private static void deleteDirectory(File directoryToBeDeleted) {
|
||||||
File[] allContents = directoryToBeDeleted.listFiles();
|
File[] allContents = directoryToBeDeleted.listFiles();
|
||||||
if (allContents != null) {
|
if (allContents != null) {
|
||||||
for (File file : allContents) {
|
for (File file : allContents) {
|
||||||
@ -66,4 +66,9 @@ public final class Util {
|
|||||||
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
|
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
|
||||||
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
|
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeInvalidJDK(File dir) {
|
||||||
|
Util.getLogger().info("Removing Invalid Java Installation: " + dir.getAbsolutePath());
|
||||||
|
Util.deleteDirectory(dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user