Skip to content
This repository was archived by the owner on Sep 9, 2023. It is now read-only.

Commit 6afcf27

Browse files
Accept parent version option
1 parent 6e9a15d commit 6afcf27

6 files changed

Lines changed: 28 additions & 6 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ Written in Java. Designed for all platform and portable use.
2929
- `mod` Commands for mods.
3030
- `search <keywords>` Search for mods with keywords. Will also export results to file for easier adding to profile.
3131

32+
### Configuration
33+
You can configure CurseForge CLI by editing `cf.json`. The file should be generated once the JAR file has run once.
34+
These are the options you can edit:
35+
- `directory` The directory where modpacks and profiles are stored. Default: `./curseforge-cli`
36+
- `acceptParent` Whether mods with only the parent version of a profile is accepted. For example, you can install a 1.18 mod into a 1.18.1 profile. Default: `true`
37+
3238
### Other Features
3339
If you put the JAR file together with a zip of the exported profile, CurseForge CLI will automatically install that profile to the current directory.
3440
This has 1 limitation, which is you should not put multiple zip files in the same directory.

src/ml/northwestwind/Config.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
public class Config {
1414
public static File directory, modpackDir, profileDir, exportDir, tempDir;
15+
public static boolean acceptParentVersionMod;
1516

1617
public static void run(String[] args) {
1718
if (args.length < 3) {
@@ -51,6 +52,7 @@ public static void load() {
5152
profileDir = new File(directory.getPath() + File.separator + "profile");
5253
exportDir = new File(directory.getPath() + File.separator + "exported");
5354
tempDir = new File(directory.getPath() + File.separator + "tmp");
55+
acceptParentVersionMod = (boolean) json.getOrDefault("acceptParent", true);
5456
} catch(Exception e) {
5557
e.printStackTrace();
5658
}

src/ml/northwestwind/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class Constants {
44
public static final String CURSEFORGE_API = "https://addons-ecs.forgesvc.net/api/v2/addon/";
5-
public static final String VERSION = "1.2.0";
5+
public static final String VERSION = "1.2.1";
66
private static final String OS = System.getProperty("os.name").toLowerCase();
77
public static final boolean IS_WINDOWS = (OS.contains("win"));
88
public static final boolean IS_MAC = (OS.contains("mac"));

src/ml/northwestwind/Profile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private static void create() {
4646
name = null;
4747
}
4848
}
49-
System.out.print(Ansi.ansi().fg(Ansi.Color.YELLOW).a("Minecraft version: ").reset());
49+
System.out.print(Ansi.ansi().fg(Ansi.Color.YELLOW).a("Minecraft version [1.x.x/1.x.x-Snapshot]: ").reset());
5050
String mcVer = null;
5151
while (mcVer == null) {
5252
mcVer = scanner.nextLine();

src/ml/northwestwind/Utils.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,25 @@ public static String getOppositeLauncher(String launcher) {
232232

233233
public static boolean checkVersion(JSONArray versions, JSONObject config) {
234234
String requiredVer = (String) config.get("mcVer");
235-
String oppoLauncher = getOppositeLauncher((String) config.get("launcher"));
235+
String launcher = (String) config.get("launcher");
236+
String oppoLauncher = getOppositeLauncher(launcher);
236237
boolean launcherMatch = false, versionMatch = false;
237-
if (oppoLauncher == null || !versions.contains(oppoLauncher)) launcherMatch = true;
238+
if (oppoLauncher == null || !versions.contains(oppoLauncher) || (versions.contains(oppoLauncher) && versions.contains(launcher))) launcherMatch = true;
238239
if (!versions.contains(requiredVer)) {
239-
if (versions.stream().filter(ver -> isMCVersionValid((String) ver)).count() <= 0) versionMatch = true;
240+
if (Config.acceptParentVersionMod && !versions.contains(parentVersion(requiredVer))) {
241+
if (versions.stream().noneMatch(ver -> isMCVersionValid((String) ver))) versionMatch = true;
242+
} else versionMatch = true;
240243
} else versionMatch = true;
241244
return versionMatch && launcherMatch;
242245
}
243246

247+
private static String parentVersion(String version) {
248+
if (!isMCVersionValid(version)) return null;
249+
String[] splitted = version.replace("-Snapshot", "").split("\\.");
250+
if (splitted.length != 3) return version;
251+
return splitted[0] + "." + splitted[1];
252+
}
253+
244254
public static void readUpdate() {
245255
Object received = readJsonFromUrl(UPDATE_URL, false);
246256
if (received == null) return;

update.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
2+
"1.2.1": {
3+
"title": "Added acceptParent option",
4+
"description": "acceptParent allows user to install mods supporting only the parent version of a profile. Refer to the README in the repository for more details."
5+
},
26
"1.2.0": {
37
"title": "Update Checker & Profile Generator"
48
},
5-
"latest": "1.2.0"
9+
"latest": "1.2.1"
610
}

0 commit comments

Comments
 (0)