Skip to content
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Commit cd774f5

Browse files
committed
Fix compatibility with Essential
Move the try-catch into the for loop Closes #84 Signed-off-by: DeathsGun <deathsgun@protonmail.com>
1 parent 265093a commit cd774f5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/kotlin/xyz/deathsgun/modmanager/update/UpdateManager.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,23 +322,24 @@ class UpdateManager {
322322

323323
private val json = Json {
324324
ignoreUnknownKeys = true
325+
encodeDefaults = true
325326
}
326327

327328
@OptIn(ExperimentalSerializationApi::class)
328329
fun findJarByModContainer(container: ModMetadata): Path? {
329330
val jars =
330331
FileUtils.listFiles(FabricLoader.getInstance().gameDir.resolve("mods").toFile(), arrayOf("jar"), true)
331-
return try {
332-
for (jar in jars) {
332+
for (jar in jars) {
333+
try {
333334
val meta = openFabricMeta(jar)
334335
if (meta.id == container.id) {
335336
return jar.toPath()
336337
}
338+
} catch (e: Exception) {
339+
continue
337340
}
338-
null
339-
} catch (e: Exception) {
340-
null
341341
}
342+
return null
342343
}
343344

344345
private fun findJarByMod(mod: Mod): Path? {

0 commit comments

Comments
 (0)