Skip to content

Commit

Permalink
fix: Fix the previous fix of only considering JARs in the mods-direct…
Browse files Browse the repository at this point in the history
…ory and nothing else
  • Loading branch information
Griefed committed Sep 16, 2023
1 parent 4a0c066 commit 4d2c382
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ expect fun File.regexWalk(
expect fun File.filteredWalk(
filters: List<String>,
filterType: FilterType = FilterType.CONTAINS,
direction: FileWalkDirection = FileWalkDirection.TOP_DOWN
direction: FileWalkDirection = FileWalkDirection.TOP_DOWN,
recursive: Boolean = true
): MutableList<File>

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ actual class ServerPackHandler actual constructor(
modloader: String
): List<File> {
log.info("Preparing a list of mods to include in server pack...")
val filesInModsDir: Collection<File> = File(modsDir).list().filter { entry -> modFileEndings.any { entry.endsWith(it) } }.map { File(it) }
val filesInModsDir: Collection<File> = File(modsDir).filteredWalk(modFileEndings, FilterType.ENDS_WITH, FileWalkDirection.TOP_DOWN, recursive = false)
val modsInModpack = TreeSet(filesInModsDir)
val autodiscoveredClientMods: MutableList<File> = ArrayList(100)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,19 +460,32 @@ actual fun File.regexWalk(filters: List<Regex>, direction: FileWalkDirection): M
actual fun File.filteredWalk(
filters: List<String>,
filterType: FilterType,
direction: FileWalkDirection
direction: FileWalkDirection,
recursive: Boolean
): MutableList<File> =
when (filterType) {
FilterType.CONTAINS -> {
this.walk(direction).asStream().filter { filters.contains(it.name) }.toList()
if (recursive) {
this.walk(direction).asStream().filter { filters.contains(it.name) }.toList()
} else {
this.walk(direction).maxDepth(1).asStream().filter { filters.contains(it.name) }.toList()
}
}

FilterType.ENDS_WITH -> {
this.walk(direction).asStream().filter { filters.endsWith(it.name) }.toList()
if (recursive) {
this.walk(direction).asStream().filter { filters.endsWith(it.name) }.toList()
} else {
this.walk(direction).maxDepth(1).asStream().filter { filters.endsWith(it.name) }.toList()
}
}

FilterType.STARTS_WITH -> {
this.walk(direction).asStream().filter { filters.startsWith(it.name) }.toList()
if (recursive) {
this.walk(direction).asStream().filter { filters.startsWith(it.name) }.toList()
} else {
this.walk(direction).maxDepth(1).asStream().filter { filters.endsWith(it.name) }.toList()
}
}
}

Expand Down

0 comments on commit 4d2c382

Please sign in to comment.