blob: e16c51c483fb6f1fa5172b2192e456a529de2ca3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
package moe.nea.firmament.compat.configured
import com.mrcrayfish.configured.api.IConfigValue
import net.minecraft.text.Text
import moe.nea.firmament.gui.config.ManagedOption
class ConfigValue<T: Any>(val option: ManagedOption<T>) : IConfigValue<T> {
var value = option.get()
var initialValue = option.get()
override fun get(): T {
return value
}
override fun set(p0: T) {
this.value = p0
}
override fun getDefault(): T {
return option.default()
}
override fun isDefault(): Boolean {
// TODO: should this be an option in handlers?
return option == option.default()
}
override fun isChanged(): Boolean {
return value != initialValue
}
override fun restore() {
this.value = option.default()
}
override fun getComment(): Text? {
return null
}
override fun getTranslationKey(): String? {
return option.rawLabelText
}
override fun getValidationHint(): Text? {
return null
}
override fun getName(): String {
return ""
}
override fun cleanCache() {
}
override fun requiresWorldRestart(): Boolean {
return false
}
override fun requiresGameRestart(): Boolean {
return false
}
override fun isValid(p0: T): Boolean {
// TODO: should this be validated?
return true
}
fun saveValue() {
option.set(value)
}
}
|