]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blobdiff - src/main/java/com/irtimaled/bbor/install/Installer.java
Enable auto-updating for Vanilla
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / install / Installer.java
index 6d79fc540551452d52e79396a7a5515221e34445..dcec4d46b02d1649e9b55ff07ed358efcd777e22 100644 (file)
@@ -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);