From e03b9748b8599b85e84c16750355cf90755c8697 Mon Sep 17 00:00:00 2001 From: The Judge Date: Mon, 15 Apr 2024 18:51:48 -0700 Subject: [PATCH] Add imageURL --- src/main/java/pojlib/api/API_V1.java | 7 ++++--- src/main/java/pojlib/instance/InstanceHandler.java | 8 ++------ src/main/java/pojlib/instance/MinecraftInstances.java | 1 + 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/pojlib/api/API_V1.java b/src/main/java/pojlib/api/API_V1.java index f722460f..387e8cbe 100644 --- a/src/main/java/pojlib/api/API_V1.java +++ b/src/main/java/pojlib/api/API_V1.java @@ -132,17 +132,18 @@ public static boolean deleteInstance(MinecraftInstances instances, MinecraftInst * @param home The base directory where minecraft should be setup * @param useDefaultMods Use QC's default mods for the version (Core mods are automatically included) * @param minecraftVersion The version of minecraft to install + * @param imageURL Modpack image url, nullable * @return A minecraft instance object * @throws IOException Throws if download of library or asset fails */ - public static MinecraftInstances.Instance createNewInstance(Activity activity, MinecraftInstances instances, String instanceName, String home, boolean useDefaultMods, String minecraftVersion, String modsFolderName) throws IOException { + public static MinecraftInstances.Instance createNewInstance(Activity activity, MinecraftInstances instances, String instanceName, String home, boolean useDefaultMods, String minecraftVersion, String modsFolderName, String imageURL) throws IOException { if(ignoreInstanceName) { - return InstanceHandler.create(activity, instances, instanceName, home, useDefaultMods, minecraftVersion, InstanceHandler.ModLoader.Fabric, modsFolderName); + return InstanceHandler.create(activity, instances, instanceName, home, useDefaultMods, minecraftVersion, InstanceHandler.ModLoader.Fabric, modsFolderName, imageURL); } else if (instanceName.contains("/") || instanceName.contains("!")) { throw new IOException("You cannot use special characters (!, /, ., etc) when creating instances."); } else { - return InstanceHandler.create(activity, instances, instanceName, home, useDefaultMods, minecraftVersion, InstanceHandler.ModLoader.Fabric, modsFolderName); + return InstanceHandler.create(activity, instances, instanceName, home, useDefaultMods, minecraftVersion, InstanceHandler.ModLoader.Fabric, modsFolderName, imageURL); } } diff --git a/src/main/java/pojlib/instance/InstanceHandler.java b/src/main/java/pojlib/instance/InstanceHandler.java index 228f922d..c857083b 100644 --- a/src/main/java/pojlib/instance/InstanceHandler.java +++ b/src/main/java/pojlib/instance/InstanceHandler.java @@ -3,13 +3,10 @@ import android.app.Activity; import com.google.common.collect.Lists; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import pojlib.account.MinecraftAccount; import pojlib.api.API_V1; @@ -20,8 +17,6 @@ import pojlib.install.VersionInfo; import pojlib.util.Constants; import pojlib.util.ModInfo; -import pojlib.util.ModsJson; -import pojlib.util.DownloadUtils; import pojlib.util.GsonUtils; import pojlib.util.JREUtils; import pojlib.util.Logger; @@ -45,7 +40,7 @@ public enum ModLoader { } //creates a new instance of a minecraft version, install game + mod loader, stores non login related launch info to json - public static MinecraftInstances.Instance create(Activity activity, MinecraftInstances instances, String instanceName, String gameDir, boolean useDefaultMods, String minecraftVersion, ModLoader modLoader, String modsFolderName) { + public static MinecraftInstances.Instance create(Activity activity, MinecraftInstances instances, String instanceName, String gameDir, boolean useDefaultMods, String minecraftVersion, ModLoader modLoader, String modsFolderName, String imageURL) { File instancesFile = new File(gameDir + "/instances.json"); if (instancesFile.exists()) { for (MinecraftInstances.Instance instance : instances.instances) { @@ -60,6 +55,7 @@ public static MinecraftInstances.Instance create(Activity activity, MinecraftIns MinecraftInstances.Instance instance = new MinecraftInstances.Instance(); instance.instanceName = instanceName; + instance.instanceImageURL = imageURL; instance.versionName = minecraftVersion; instance.gameDir = new File(gameDir).getAbsolutePath(); instance.defaultMods = useDefaultMods; diff --git a/src/main/java/pojlib/instance/MinecraftInstances.java b/src/main/java/pojlib/instance/MinecraftInstances.java index 8b4189e7..28185c24 100644 --- a/src/main/java/pojlib/instance/MinecraftInstances.java +++ b/src/main/java/pojlib/instance/MinecraftInstances.java @@ -35,6 +35,7 @@ public Instance[] toArray() { public static class Instance { public String instanceName; + public String instanceImageURL; public String versionName; public String modsDirName; public String versionType;