Skip to content

Commit

Permalink
Add support for new clear_directories field on editions
Browse files Browse the repository at this point in the history
  • Loading branch information
Justsnoopy30 committed Feb 1, 2022
1 parent a29015d commit e9341bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
org.gradle.jvmargs=-Xmx1G

# Version and packaging info
version=1.3.0
version=1.3.1
maven_group=net.hypercubemc
archives_base_name=Universe-Installer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -415,6 +416,7 @@ public boolean installFromPack(File pack) {
return false;
}

deleteDirectories(selectedEdition.clearDirectories);
installFiles(files);
return true;
} catch (IOException e) {
Expand Down Expand Up @@ -443,6 +445,12 @@ private void installFiles(File[] files) throws IOException {
}
}

private void deleteDirectories(List<String> pathNames) {
for (String pathName : pathNames) {
deleteDirectory(getInstallDir().resolve(pathName.replace("/", File.separator)).toFile());
}
}

public boolean repositoryExists(File directory) {
FileRepositoryBuilder repositoryBuilder = new FileRepositoryBuilder();
repositoryBuilder.findGitDir(directory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static class Edition {
String displayName;
String defaultInstallDir;
List<String> compatibleVersions = new ArrayList<>();
List<String> clearDirectories = new ArrayList<>();

public Edition(JSONObject jsonObject) {
this.name = jsonObject.getString("name");
Expand All @@ -64,6 +65,9 @@ public Edition(JSONObject jsonObject) {
compatibleVersions.add(jsonObject.getJSONArray("compatible_versions").toList().get(i).toString());
}

for (int i = 0; i < jsonObject.getJSONArray("clear_directories").toList().size(); i++){
clearDirectories.add(jsonObject.getJSONArray("clear_directories").toList().get(i).toString());
}
}
}
}

0 comments on commit e9341bc

Please sign in to comment.