Skip to content

Commit fd0b2aa

Browse files
authored
Merge pull request #2 from Insprill/feature/loader-branch-validation
Validate loader branch syntax
2 parents 73c707d + 75777f7 commit fd0b2aa

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/main/java/cam72cam/universalmodcore/Setup.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ public static void main(String[] args) throws IOException, GitAPIException {
2323
Files.readAllBytes(Paths.get("umc.json"))
2424
))
2525
).getAsJsonObject();
26+
27+
if (args.length == 0) {
28+
System.err.println("No loader branch specified! Available branches can be found in the UniversalModCore GitHub repository.");
29+
return;
30+
}
2631
String loaderBranch = args[0];
32+
String[] split = loaderBranch.split("-");
33+
if (split.length < 2 || !split[0].matches("1\\.\\d*\\.\\d*") || !split[1].matches("[\\w-]+")) {
34+
System.err.println("Invalid loader branch! It should be in the format '<minecraft-version>-<loader>'. For example, '1.12.2-forge'.");
35+
return;
36+
}
37+
2738
Config config = new Config(configObj, loaderBranch);
2839

2940
ZipInputStream zip = new ZipInputStream(config.openJarStream());

0 commit comments

Comments
 (0)