This is not yet finished, there are 3 main things left - Make sure everything works - (Assets) download old structure - Cleanup What are implemented? - Downloading file is handled with AFNetworking - SHA1 validation, can be turned off in Preferences - inheritsFrom support (need testing) - Downloading assets with 20 jobs parallel Known issue - Assets SHA1 validating freezes the UI Additional things - [Custom controls] Dynamic position error is now handled instead of just crashes - [Custom controls] The editor animation is now changed to fade in/out (for now, later might change) - VGPU renderer is now made hidden, since it's too limited on iOS, removal planned - [Code cleanup] Use NSDictionary instead of a set of fields for renderer list; Fix wrong field name. - Some more stuff...
93 lines
3.5 KiB
Java
93 lines
3.5 KiB
Java
package net.kdt.pojavlaunch;
|
|
|
|
import java.io.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.*;
|
|
|
|
import org.lwjgl.glfw.CallbackBridge;
|
|
|
|
import net.kdt.pojavlaunch.uikit.*;
|
|
import net.kdt.pojavlaunch.utils.*;
|
|
import net.kdt.pojavlaunch.value.*;
|
|
|
|
public class PLaunchApp {
|
|
private static float currProgress, maxProgress;
|
|
|
|
public static volatile JMinecraftVersionList.Version mVersion;
|
|
public static boolean mIsAssetsProcessing = false;
|
|
|
|
public static void main(String[] args) throws Throwable {
|
|
try {
|
|
sun.font.FontUtilities.isLinux = true;
|
|
} catch (Throwable th) {
|
|
// Not on JRE8, ignore exception
|
|
}
|
|
|
|
// User might remove the minecraft folder, this can cause crashes, safety re-create it
|
|
try {
|
|
File mcDir = new File(Tools.DIR_GAME_NEW);
|
|
mcDir.mkdirs();
|
|
new File(Tools.DIR_ACCOUNT_NEW).mkdirs();
|
|
if (!new File(mcDir.getAbsolutePath() + "/launcher_profiles.json").exists()) {
|
|
Tools.write(mcDir.getAbsolutePath() + "/launcher_profiles.json",
|
|
Tools.read(Tools.DIR_BUNDLE + "/launcher_profiles.json"));
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
System.out.println("We are on java now! Starting UI...");
|
|
UIKit.launchUI();
|
|
}
|
|
|
|
public static String getSelectedVersion() {
|
|
try {
|
|
String plistContent = Tools.read(Tools.DIR_APP_DATA + "/launcher_preferences.plist");
|
|
plistContent = plistContent.substring(plistContent.indexOf("<key>selected_version</key>") + 27);
|
|
return plistContent.substring(
|
|
plistContent.indexOf("<string>") + 8,
|
|
plistContent.indexOf("</string>"));
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// Called from SurfaceViewController
|
|
public static void launchMinecraft() {
|
|
try {
|
|
if (AccountJNI.CURRENT_ACCOUNT == null) {
|
|
AccountJNI.CURRENT_ACCOUNT = MinecraftAccount.load(System.getProperty("pojav.selectedAccount"));
|
|
}
|
|
mVersion = Tools.getVersionInfo(getSelectedVersion());
|
|
System.out.println("Launching Minecraft " + mVersion.id);
|
|
String configPath;
|
|
if (mVersion.logging != null) {
|
|
if (mVersion.logging.client.file.id.equals("client-1.12.xml")) {
|
|
configPath = Tools.DIR_BUNDLE + "/log4j-rce-patch-1.12.xml";
|
|
} else if (mVersion.logging.client.file.id.equals("client-1.7.xml")) {
|
|
configPath = Tools.DIR_BUNDLE + "/log4j-rce-patch-1.7.xml";
|
|
} else {
|
|
configPath = Tools.DIR_GAME_NEW + "/" + mVersion.logging.client.file.id;
|
|
}
|
|
System.setProperty("log4j.configurationFile", configPath);
|
|
}
|
|
Tools.launchMinecraft(AccountJNI.CURRENT_ACCOUNT, mVersion);
|
|
} catch (Throwable th) {
|
|
Tools.showError(th);
|
|
}
|
|
}
|
|
|
|
// TODO
|
|
/*
|
|
public static void downloadAssetMapped(String assetName, JAssetInfo asset, File resDir) throws IOException {
|
|
String assetPath = asset.hash.substring(0, 2) + "/" + asset.hash;
|
|
File outFile = new File(resDir,"/"+assetName);
|
|
if (!outFile.exists()) {
|
|
UIKit.updateProgressSafe(currProgress / maxProgress, "Downloading " + assetName);
|
|
DownloadUtils.downloadFile(MINECRAFT_RES + assetPath, outFile);
|
|
}
|
|
}
|
|
*/
|
|
}
|