From: Irtimaled Date: Thu, 4 Jun 2020 22:26:38 +0000 (-0700) Subject: Enable auto-updating for Vanilla X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=95c2bc83b079017a9608f418a0feb7ea3e313082;p=BoundingBoxOutlineReloaded.git Enable auto-updating for Vanilla --- diff --git a/src/main/java/com/irtimaled/bbor/install/Installer.java b/src/main/java/com/irtimaled/bbor/install/Installer.java index 6d79fc5..dcec4d4 100644 --- a/src/main/java/com/irtimaled/bbor/install/Installer.java +++ b/src/main/java/com/irtimaled/bbor/install/Installer.java @@ -15,8 +15,6 @@ import java.util.Locale; public class Installer { public static void install() { - String version = Versions.build; - String mcVersion = Versions.minecraft; try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Throwable t) { @@ -26,16 +24,17 @@ public class Installer { try { String osName = getOsName(); File minecraftFolder = getMinecraftFolder(osName); - File versionFolder = new File(minecraftFolder, "versions/BBOR-" + version + "/"); + String version = "BBOR-" + Versions.minecraft; + File versionFolder = new File(minecraftFolder, "versions/" + version + "/"); versionFolder.mkdirs(); - File versionJson = new File(versionFolder, "BBOR-" + version + ".json"); + File versionJson = new File(versionFolder, version + ".json"); Files.copy(Installer.class.getResourceAsStream("/profile.json"), versionJson.toPath(), StandardCopyOption.REPLACE_EXISTING); try { File profilesJson = new File(minecraftFolder, "launcher_profiles.json"); if (profilesJson.exists()) { - String identifier = "\"bbor-" + mcVersion + "\""; + String identifier = "\"" + version.toLowerCase() + "\""; String contents = new String(Files.readAllBytes(profilesJson.toPath())); if (contents.contains(identifier)) { contents = contents.replaceAll(",\n?\\s*" + identifier + "\\s*:\\s*\\{[^}]*},", ","); @@ -50,7 +49,7 @@ public class Installer { " \"type\": \"custom\",\n" + " \"created\": \"" + date + "T00:00:00.000Z\",\n" + " \"lastUsed\": \"2100-01-01T00:00:00.000Z\",\n" + - " \"lastVersionId\": \"BBOR-" + version + "\"\n" + + " \"lastVersionId\": \"" + version + "\"\n" + " },\n"); Files.write(profilesJson.toPath(), contents.getBytes()); @@ -64,7 +63,7 @@ public class Installer { if (source.startsWith("/") && osName.contains("win")) { source = source.substring(1); } - File mainJar = new File(minecraftFolder, "libraries/com/irtimaled/bbor/" + version + "/bbor-" + version + ".jar"); + File mainJar = new File(minecraftFolder, "libraries/com/irtimaled/bbor/" + Versions.minecraft + "/" + version.toLowerCase() + ".jar"); mainJar.getParentFile().mkdirs(); Files.copy(Paths.get(source), mainJar.toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (Throwable t) { @@ -72,7 +71,7 @@ public class Installer { } JOptionPane.showMessageDialog(null, - "Bounding Box Outline Reloaded " + version + " has been successfully installed!\n" + + "Bounding Box Outline Reloaded " + Versions.build + " for " + Versions.minecraft + " has been successfully installed!\n" + "\n" + "Re-open the Minecraft Launcher to see it in the dropdown.", "Bounding Box Outline Reloaded Installer", JOptionPane.INFORMATION_MESSAGE); diff --git a/src/main/resources/profile.json b/src/main/resources/profile.json index 3b2afab..536f1e9 100644 --- a/src/main/resources/profile.json +++ b/src/main/resources/profile.json @@ -1,6 +1,6 @@ { "inheritsFrom": "${mcVersion}", - "id": "BBOR-${version}", + "id": "BBOR-${mcVersion}", "jar": "${mcVersion}", "time": "${formattedTime}", "type": "release", @@ -13,7 +13,7 @@ "mainClass": "net.minecraft.launchwrapper.Launch", "libraries": [ { - "name": "com.irtimaled:bbor:${version}", + "name": "com.irtimaled:bbor:${mcVersion}", "url": "https://github.com/irtimaled/maven/releases/download/" }, {