Skip to content

Commit

Permalink
Add imageURL
Browse files Browse the repository at this point in the history
  • Loading branch information
The Judge committed Apr 16, 2024
1 parent 92618f7 commit e03b974
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/main/java/pojlib/api/API_V1.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/main/java/pojlib/instance/InstanceHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/pojlib/instance/MinecraftInstances.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e03b974

Please sign in to comment.