Skip to content

Commit 23180e6

Browse files
committed
Fix config loading
1 parent 53c26d8 commit 23180e6

File tree

3 files changed

+11
-28
lines changed

3 files changed

+11
-28
lines changed

src/main/kotlin/com/lambda/config/Configuration.kt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,6 @@ abstract class Configuration : Jsonable {
6363
get() = File("${primary.parent}/${primary.nameWithoutExtension}-backup.${primary.extension}")
6464

6565
init {
66-
// We need to implement a dependency graph of loadables and add functions to run before
67-
// and/or after a given Loadable children class is initialized
68-
//
69-
// class Load1(
70-
// override val priority = 1000,
71-
// override val before = Load2,
72-
// ) : Loadable {}
73-
//
74-
// class Load2(
75-
// override val priority = 1000,
76-
// ) : Loadable {}
77-
//
78-
// class Load3(
79-
// override val priority = 1000,
80-
// override val after = Load2,
81-
// ) : Loadable {}
82-
//
83-
// clientLifecycle<Load2>(shift = Pre) { event -> } // Will run before Load2
84-
// clientLifecycle<Load2>(shift = Post) { event -> } // Will run after Load2
85-
listenUnsafe<ClientEvent.Startup> { tryLoad() }
8666
listenUnsafe<ClientEvent.Shutdown>(Int.MIN_VALUE) { trySave() }
8767

8868
register()

src/main/kotlin/com/lambda/config/configurations/UserConfig.kt renamed to src/main/kotlin/com/lambda/config/configurations/ConfigLoader.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818
package com.lambda.config.configurations
1919

2020
import com.lambda.config.Configuration
21-
import com.lambda.util.FolderRegister
22-
import java.io.File
21+
import com.lambda.core.Loadable
2322

24-
object UserConfig : Configuration() {
25-
override val configName get() = "preferences"
26-
override val primary: File = FolderRegister.config.resolve("$configName.json").toFile()
27-
}
23+
object ConfigLoader: Loadable {
24+
override fun load(): String {
25+
Configuration.configurations.forEach {
26+
it.tryLoad()
27+
}
28+
return "Loaded ${Configuration.configurations.size} configurations"
29+
}
30+
}

src/main/kotlin/com/lambda/network/NetworkManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ package com.lambda.network
1919

2020
import com.lambda.Lambda.mc
2121
import com.lambda.config.Configurable
22-
import com.lambda.config.configurations.UserConfig
22+
import com.lambda.config.configurations.LambdaConfig
2323
import com.lambda.core.Loadable
2424
import com.lambda.network.api.v1.models.Authentication
2525
import com.lambda.network.api.v1.models.Authentication.Data
2626
import com.lambda.util.StringUtils.base64UrlDecode
2727
import com.lambda.util.StringUtils.json
2828
import com.lambda.util.collections.updatableLazy
2929

30-
object NetworkManager : Configurable(UserConfig), Loadable {
30+
object NetworkManager : Configurable(LambdaConfig), Loadable {
3131
override val name = "network"
3232

3333
var accessToken by setting("access_token", ""); private set

0 commit comments

Comments
 (0)