Skip to content

Commit

Permalink
chore: update incorrect comment in ModrinthLauncherDataSource
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellet committed Jun 22, 2024
1 parent 39fe1b1 commit f19e1d9
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,35 @@ import java.nio.file.Paths
class ModrinthLauncherDataSource : LauncherDataSource {
companion object {
/**
* ATLauncher will create a file in the instance directory containing all the info for the instance
* Modrinth Launcher will create a file in the instance directory containing all the info for the instance
* */
const val INSTANCE_FILE_NAME = "profile.json"
}

private fun getInstance(launcherInstanceDirectory: File): Result<ModrinthLauncherInstance> {
return try {
private fun getInstance(launcherInstanceDirectory: File): Result<ModrinthLauncherInstance> =
try {
val instanceFile = Paths.get(launcherInstanceDirectory.path, INSTANCE_FILE_NAME).toFile()
val modrinthLauncherInstance = JsonIgnoreUnknownKeys.decodeFromString<ModrinthLauncherInstance>(instanceFile.readText())
Result.success(modrinthLauncherInstance)
} catch (e: Exception) {
Result.failure(e)
}
}

override suspend fun isValidInstanceDirectory(launcherInstanceDirectory: File): Result<Unit> {
return try {
override suspend fun isValidInstanceDirectory(launcherInstanceDirectory: File): Result<Unit> =
try {
getInstance(launcherInstanceDirectory = launcherInstanceDirectory).getOrThrow()
Result.success(Unit)
} catch (e: Exception) {
Result.failure(e)
}
}

override suspend fun isCurseForgeApiRequestNeeded(launcherInstanceDirectory: File): Result<Boolean> {
return Result.success(false)
}
override suspend fun isCurseForgeApiRequestNeeded(launcherInstanceDirectory: File): Result<Boolean> = Result.success(false)

override suspend fun getMods(
launcherInstanceDirectory: File,
overrideCurseForgeApiKey: String?,
): Result<List<Mod>> {
return try {
): Result<List<Mod>> =
try {
val instance = getInstance(launcherInstanceDirectory = launcherInstanceDirectory).getOrThrow()
val mods =
instance.projects.map { (_, project) ->
Expand All @@ -61,5 +57,4 @@ class ModrinthLauncherDataSource : LauncherDataSource {
} catch (e: Exception) {
Result.failure(e)
}
}
}

0 comments on commit f19e1d9

Please sign in to comment.