From 75777f78b3036f22df020cead2ec8807f30ef9d1 Mon Sep 17 00:00:00 2001 From: Pierce Thompson Date: Sat, 24 Dec 2022 22:11:52 -0500 Subject: [PATCH] Validate loader branch syntax --- src/main/java/cam72cam/universalmodcore/Setup.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/cam72cam/universalmodcore/Setup.java b/src/main/java/cam72cam/universalmodcore/Setup.java index f2cdbe4..feb7a10 100644 --- a/src/main/java/cam72cam/universalmodcore/Setup.java +++ b/src/main/java/cam72cam/universalmodcore/Setup.java @@ -23,7 +23,18 @@ public static void main(String[] args) throws IOException, GitAPIException { Files.readAllBytes(Paths.get("umc.json")) )) ).getAsJsonObject(); + + if (args.length == 0) { + System.err.println("No loader branch specified! Available branches can be found in the UniversalModCore GitHub repository."); + return; + } String loaderBranch = args[0]; + String[] split = loaderBranch.split("-"); + if (split.length < 2 || !split[0].matches("1\\.\\d*\\.\\d*") || !split[1].matches("[\\w-]+")) { + System.err.println("Invalid loader branch! It should be in the format '-'. For example, '1.12.2-forge'."); + return; + } + Config config = new Config(configObj, loaderBranch); ZipInputStream zip = new ZipInputStream(config.openJarStream());