diff --git a/src/main/java/pojlib/API.java b/src/main/java/pojlib/API.java index 9d09fc7e..c7c5eaa8 100644 --- a/src/main/java/pojlib/API.java +++ b/src/main/java/pojlib/API.java @@ -7,17 +7,13 @@ import androidx.annotation.Nullable; -import com.google.gson.JsonObject; - import pojlib.account.MinecraftAccount; -import pojlib.account.Msa; import pojlib.util.Logger; import pojlib.util.json.MinecraftInstances; import pojlib.util.Constants; import pojlib.account.LoginHelper; import java.io.IOException; -import java.util.Date; /** * This class is the only class used by the launcher to communicate and talk to pojlib. This keeps pojlib and launcher separate. @@ -28,25 +24,17 @@ public class API { public static String msaMessage = ""; public static String model = "Quest"; - private static boolean hasQueried = false; - private static JsonObject initialResponse; public static boolean finishedDownloading = true; public static boolean ignoreInstanceName; - public static boolean customRAMValue = false; public static double downloadStatus = 0; public static String currentDownload = ""; public static String profileImage; public static String profileName; public static String profileUUID; - public static String memoryValue = "1800"; - public static boolean developerMods; public static MinecraftAccount currentAcc; public static boolean isDemoMode; public static MinecraftInstances.Instance currentInstance; - public static boolean advancedDebugger; - - /** * Add a mod to an instance * diff --git a/src/main/java/pojlib/util/ConfigUtil.java b/src/main/java/pojlib/util/ConfigUtil.java new file mode 100644 index 00000000..8322b882 --- /dev/null +++ b/src/main/java/pojlib/util/ConfigUtil.java @@ -0,0 +1,39 @@ +package pojlib.util; + +import java.io.File; +import java.util.ArrayList; + +public class ConfigUtil { + + public static Config config; + public static File configFile = new File(Constants.CONFIG_PATH); + + public static void LoadConfig() { + if (configFile.exists()) { + config = GsonUtils.jsonFileToObject(configFile.getAbsolutePath(), Config.class); + } else { + config = new Config(); + GsonUtils.objectToJsonFile(configFile.getAbsolutePath(), config); + } + } + + public static void SaveConfig() { + GsonUtils.objectToJsonFile(configFile.getAbsolutePath(), config); + LoadConfig(); + } + + public static class Config { + public boolean acceptedLegal = false; + public boolean setDevMods = false; + public boolean setCustomRAM = false; + public String customRAMValue = "2048"; + public int lastSelectedInstance = 0; + public int lastSelectedAccount = 0; + public ArrayList accounts = new ArrayList<>(); + } + + public static class Accounts { + public String username; + public String uuid; + } +} \ No newline at end of file diff --git a/src/main/java/pojlib/util/Constants.java b/src/main/java/pojlib/util/Constants.java index 45a4ad27..3e4a6d00 100644 --- a/src/main/java/pojlib/util/Constants.java +++ b/src/main/java/pojlib/util/Constants.java @@ -29,4 +29,5 @@ public class Constants { public static String MINOTAR_URL = "https://minotar.net"; public static String USER_HOME = new File(Environment.getExternalStorageDirectory(),"Android/data/com.qcxr.qcxr/files").getAbsolutePath(); + public static String CONFIG_PATH = USER_HOME + "/config.json"; } \ No newline at end of file diff --git a/src/main/java/pojlib/util/JREUtils.java b/src/main/java/pojlib/util/JREUtils.java index 8307986a..e4dcc2d8 100644 --- a/src/main/java/pojlib/util/JREUtils.java +++ b/src/main/java/pojlib/util/JREUtils.java @@ -181,9 +181,10 @@ public static int launchJavaVM(final Activity activity, final List JVMAr //Add automatically generated args - if (API.customRAMValue) { - userArgs.add("-Xms" + API.memoryValue + "M"); - userArgs.add("-Xmx" + API.memoryValue + "M"); + // TODO: Let user set Xmx AND Xms + if (ConfigUtil.config.setCustomRAM) { + userArgs.add("-Xms" + ConfigUtil.config.customRAMValue + "M"); + userArgs.add("-Xmx" + ConfigUtil.config.customRAMValue + "M"); } else { if (API.model.equals("Meta Quest Pro") || API.model.equals("Oculus Headset1")) { userArgs.add("-Xms" + 2048 + "M"); diff --git a/src/main/java/pojlib/util/json/MinecraftInstances.java b/src/main/java/pojlib/util/json/MinecraftInstances.java index 5f1d2844..62533d31 100644 --- a/src/main/java/pojlib/util/json/MinecraftInstances.java +++ b/src/main/java/pojlib/util/json/MinecraftInstances.java @@ -10,6 +10,7 @@ import pojlib.account.MinecraftAccount; import pojlib.API; import pojlib.InstanceHandler; +import pojlib.util.ConfigUtil; import pojlib.util.Constants; import pojlib.util.download.DownloadManager; import pojlib.util.download.DownloadUtils; @@ -77,7 +78,7 @@ private ModsJson parseModsJson(String jsonPath) { private ModsJson downloadCurrentModsJson(String userHome) throws Exception { File mods = new File(userHome + "/new_mods.json"); - if(API.developerMods) { + if(ConfigUtil.config.setDevMods) { DownloadUtils.downloadFile(InstanceHandler.DEV_MODS, mods, new DownloadManager(1)); } else { DownloadUtils.downloadFile(InstanceHandler.MODS, mods, new DownloadManager(1));