Skip to content

Commit 8b46b83

Browse files
committed
fix: update backup manager to restore specific files and increment version to 3.2.3
1 parent a3bb656 commit 8b46b83

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- fix: skyblocker configs being reset on startup.
1+
- fix: backup manager restores specific files, letting you select specific sup files inside the config folder.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ org.gradle.configuration-cache=false
66
# Mod properties
77
mod.name=PackCore
88
mod.id=packcore
9-
mod.version=3.2.2
9+
mod.version=3.2.3
1010
mod.group=com.github.kd_gaming1
1111

1212
# Global dependencies

src/main/java/com/github/kd_gaming1/packcore/ui/screen/configmanager/SelectiveFileApplicationScreen.java

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,26 @@ private void buildFileTree() {
345345
rootNode.setExpanded(true);
346346
rootNode.setChildrenLoaded(true);
347347

348+
// Create a set of all directory paths for quick lookup
349+
Set<String> directoryPaths = new HashSet<>();
350+
for (SelectableFile file : allFiles) {
351+
String path = file.path();
352+
String[] parts = path.split("[/\\\\]");
353+
354+
// Add all parent directories
355+
StringBuilder currentPath = new StringBuilder();
356+
for (int i = 0; i < parts.length - 1; i++) {
357+
if (currentPath.length() > 0) {
358+
currentPath.append("/");
359+
}
360+
currentPath.append(parts[i]);
361+
directoryPaths.add(currentPath.toString());
362+
}
363+
}
364+
348365
// Build tree from files
349366
for (SelectableFile file : allFiles) {
350-
addFileToTree(file);
367+
addFileToTree(file, directoryPaths);
351368
}
352369

353370
// Render root's children
@@ -358,18 +375,30 @@ private void buildFileTree() {
358375
updateSelectionInfo();
359376
}
360377

361-
private void addFileToTree(SelectableFile file) {
378+
private void addFileToTree(SelectableFile file, Set<String> directoryPaths) {
362379
String[] pathParts = file.path().split("[/\\\\]");
363380
FileTreeNode currentNode = rootNode;
364381

365382
for (int i = 0; i < pathParts.length; i++) {
366383
String part = pathParts[i];
367-
boolean isLast = (i == pathParts.length - 1);
384+
385+
// Build the full path up to this point
386+
StringBuilder pathBuilder = new StringBuilder();
387+
for (int j = 0; j <= i; j++) {
388+
if (pathBuilder.length() > 0) {
389+
pathBuilder.append("/");
390+
}
391+
pathBuilder.append(pathParts[j]);
392+
}
393+
String fullPath = pathBuilder.toString();
394+
395+
// Determine if this is a directory
396+
boolean isDirectory = directoryPaths.contains(fullPath);
368397

369398
FileTreeNode childNode = findChild(currentNode, part);
370399
if (childNode == null) {
371400
Path nodePath = currentNode.getPath().resolve(part);
372-
childNode = new FileTreeNode(nodePath, part, !isLast);
401+
childNode = new FileTreeNode(nodePath, part, isDirectory);
373402
childNode.setChildrenLoaded(true);
374403
currentNode.addChild(childNode);
375404
}

0 commit comments

Comments
 (0)