Skip to content

Commit

Permalink
Installer
Browse files Browse the repository at this point in the history
This is much better.
  • Loading branch information
afkvido committed Mar 11, 2022
1 parent b6dc353 commit 4b83463
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 81 deletions.
10 changes: 10 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ _______
1. Prerequisites: You need [git](https://git-scm.com/downloads), [Forge](https://files.minecraftforge.net/net/minecraftforge/forge/), and [Java 17](https://www.oracle.com/java/technologies/downloads).
2. Download [the Installer](https://github.com/NecroClient/Installer/releases)
3. **Warning**: Running the jar will delete all your current mods and replace them with the Necro Client mods.
4. **Warning**: It will also delete your current mod config and replace it with the Necro Client mod config.
5. If you want to save your mods and configs, make backups of those folders.
6. Run the jar file from the command line: `java -jar NecroInstaller.jar`.
7. Done! Necro Client is now installed.
8. To run Necro Client, run your Forge installation through the Minecraft Launcher.
4. Don't worry. If you forgot to back up your mods folder: Go to this directory: `(.minecraft)/NecroBackups`. You'll find backups of your mod and config folders there.
5. Run the jar file from the command line: `java -jar NecroInstaller.jar`.
6. Done! Necro Client is now installed.
7. To run Necro Client, run your Forge installation through the Minecraft Launcher.


## Common Errors
Expand Down
Binary file modified build/NecroInstaller.jar
Binary file not shown.
146 changes: 70 additions & 76 deletions src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public final class Main {

/** Version of Installer */
final static String Version = "0.1.3";
final static String Version = "0.2.0";

/** Result if URLreader failed. */
final static String fail = "URLreader failed";
Expand Down Expand Up @@ -68,7 +68,7 @@ static void MacOS () {
String random = String.valueOf(r.nextInt(1, 999));

// Move the directory
boolean mdMoved = modsDir.renameTo(new File(System.getenv("HOME") + "/Library/Application Support/minecraft/NecroBackups/mods_" + random));
boolean mdMoved = modsDir.renameTo(new File(backupDir + "/mods_" + random));
if (mdMoved) {
System.out.println("[NecroInstaller] Moved the mods directory");
} else {
Expand All @@ -81,8 +81,8 @@ static void MacOS () {
// Config directory path
File configDir = new File(System.getenv("HOME") + "/Library/Application Support/minecraft/config");

// Deleting all the files in the config directory
boolean cdMoved = configDir.renameTo(new File(System.getenv("HOME") + "/Library/Application Support/minecraft/NecroBackups/config_" + random));
// Moving the config directory
boolean cdMoved = configDir.renameTo(new File(backupDir + "/config_" + random));
if (cdMoved) {
System.out.println("[NecroInstaller] Moved the config directory");
} else {
Expand Down Expand Up @@ -120,6 +120,7 @@ static void MacOS () {



System.out.println("[NecroInstaller] Your mods folder backup number: " + random);

System.out.println("[NecroInstaller] Done!");

Expand All @@ -133,57 +134,52 @@ static void Windows () {
Process process;


// Mods directory
File modsDir = new File(System.getenv("APPDATA") + "\\.minecraft\\mods");

// Deleting all the files in the mods directory
try {

String[] entries = modsDir.list();
for (String s : entries) {
File currentFile = new File(modsDir.getPath(), s);
currentFile.delete();
}
} catch (Exception ignored) {

}
// Mods backups directory path
File backupDir = new File(System.getenv("APPDATA") + "\\.minecraft\\NecroBackups");

// Deleting the mods directory
boolean bl = modsDir.delete();
if (bl) {
System.out.println("[NecroInstaller] Deleted the mods directory");
// Create the backup directory
if (backupDir.mkdir()) {
System.out.println("[NecroInstaller] Created the NecroBackups directory");
} else {
System.out.println("[NecroInstaller] Could not delete the the mods directory, it might not exist.");
System.out.println("[NecroInstaller] Couldn't create the NecroBackups directory, it probably already exists.");
}

// -------------------------------


// Mods directory path
File modsDir = new File(System.getenv("APPDATA") + "\\.minecraft\\mods");

// New random
Random r = new Random();

// Random number, from 1 to 999
String random = String.valueOf(r.nextInt(1, 999));

// Config directory
File configDir = new File(System.getenv("APPDATA") + "\\.minecraft\\config");
// Move the directory
boolean mdMoved = modsDir.renameTo(new File(backupDir + "\\mods_" + random));
if (mdMoved) {
System.out.println("[NecroInstaller] Moved the mods directory");
} else {
System.out.println("[NecroInstaller] Couldn't move the mods directory");
}

// Deleting all the files in the config directory
try {
// -------------------------------

String[] entries = configDir.list();
for (String s : entries) {
File currentFile = new File(configDir.getPath(), s);
currentFile.delete();
}
} catch (Exception ignored) {

}
// Config directory path
File configDir = new File(System.getenv("APPDATA") + "\\.minecraft\\config");

// Deleting the config directory
boolean bl2 = configDir.delete();
if (bl2) {
System.out.println("[NecroInstaller] Deleted the config directory");
// Deleting all the files in the config directory
boolean cdMoved = configDir.renameTo(new File( backupDir + "\\config_" + random));
if (cdMoved) {
System.out.println("[NecroInstaller] Moved the config directory");
} else {
System.out.println("[NecroInstaller] Could not delete the the config directory, it might not exist.");
System.out.println("[NecroInstaller] Couldn't move the config directory");
}

// -------------------------------



System.out.println("[NecroInstaller] Cloning the mods repository...");
Expand Down Expand Up @@ -214,6 +210,7 @@ static void Windows () {



System.out.println("[NecroInstaller] Your mods folder backup number: " + random);

System.out.println("[NecroInstaller] Done!");

Expand All @@ -227,60 +224,52 @@ static void Linux () {
Process process;


// Mods directory
File modsDir = new File(System.getenv("HOME") + "/.minecraft/mods");


// Deleting all the files in the mods directory
try {
// Mods backups directory path
File backupDir = new File(System.getenv("HOME") + "/.minecraft/NecroBackups");

String[] entries = modsDir.list();
for (String s : entries) {
File currentFile = new File(modsDir.getPath(), s);
currentFile.delete();
}
} catch (Exception ignored) {
System.out.println("[NecroInstaller] There was an error during the deletion of the files in the mods directory, perhaps it was empty?");
// Create the backup directory
if (backupDir.mkdir()) {
System.out.println("[NecroInstaller] Created the NecroBackups directory");
} else {
System.out.println("[NecroInstaller] Couldn't create the NecroBackups directory, it probably already exists.");
}

// -------------------------------

// Deleting the mods directory
boolean bl = modsDir.delete();
if (bl) {
System.out.println("[NecroInstaller] Deleted the mods directory");
} else {
System.out.println("[NecroInstaller] Could not delete the the mods directory, it might not exist.");
}

// Mods directory path
File modsDir = new File(System.getenv("HOME") + "/.minecraft/mods");

// New random
Random r = new Random();

// Random number, from 1 to 999
String random = String.valueOf(r.nextInt(1, 999));

// Move the directory
boolean mdMoved = modsDir.renameTo(new File(backupDir + "/mods_" + random));
if (mdMoved) {
System.out.println("[NecroInstaller] Moved the mods directory");
} else {
System.out.println("[NecroInstaller] Couldn't move the mods directory");
}

// -------------------------------


// Config directory
File configDir = new File(System.getenv("HOME") + "/.minecraft/config");

// Deleting all the files in the config directory
try {

String[] entries = configDir.list();
for (String s : entries) {
File currentFile = new File(configDir.getPath(), s);
currentFile.delete();
}
} catch (Exception ignored) {
System.out.println("[NecroInstaller] There was an error during the deletion of the files in the config directory, perhaps it was empty?");
}


// Deleting the config directory
boolean bl2 = configDir.delete();
if (bl2) {
System.out.println("[NecroInstaller] Deleted the config directory");
boolean cdMoved = configDir.renameTo(new File( backupDir + "/config_" + random));
if (cdMoved) {
System.out.println("[NecroInstaller] Moved the config directory");
} else {
System.out.println("[NecroInstaller] Could not delete the the config directory, it might not exist.");
System.out.println("[NecroInstaller] Couldn't move the config directory");
}

// -------------------------------



System.out.println("[NecroInstaller] Cloning the mods repository...");
Expand Down Expand Up @@ -312,6 +301,8 @@ static void Linux () {



System.out.println("[NecroInstaller] Your mods folder backup number: " + random);

System.out.println("[NecroInstaller] Done!");


Expand Down Expand Up @@ -347,6 +338,9 @@ static void version () {

String latestVersion = check("https://raw.githubusercontent.com/NecroClient/api/main/Installer.yml").replace("\n", "");

System.out.println("[NecroInstaller] Current version: " + Version);
System.out.println("[NecroInstaller] Latest version: " + latestVersion);

if (latestVersion.equals(fail)) {
System.out.println("[NecroInstaller] Cannot connect to the Necro Client API.\nMake sure you have actual internet.\nOr, you might just have an old version. Download a new version here: https://github.com/NecroClient/Installer/releases");
wait.nextLine();
Expand Down

0 comments on commit 4b83463

Please sign in to comment.