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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
package com.ambientaddons.config
import com.ambientaddons.gui.GuiPosition
import com.ambientaddons.utils.SalvageStrategy
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import java.io.File
import kotlinx.serialization.encodeToString
import kotlinx.serialization.decodeFromString
@Serializable
data class PersistentData(
var isFirstLoad: Boolean = true,
var autoBuyItems: MutableMap<String, Int?> = mutableMapOf(
"RECOMBOBULATOR_3000" to 5000000,
"FIRST_MASTER_STAR" to null,
"SECOND_MASTER_STAR" to null,
"THIRD_MASTER_STAR" to null,
"FOURTH_MASTER_STAR" to null,
"FIFTH_MASTER_STAR" to null,
"SPIRIT_WING" to null,
"SPIRIT_STONE" to 1000000,
"SHADOW_ASSASSIN_CHESTPLATE" to null,
"SHADOW_FURY" to null,
"GIANTS_SWORD" to null,
"DARK_CLAYMORE" to null,
"THUNDERLORD_7" to null,
"WITHER_CHESTPLATE" to null,
"ULTIMATE_ONE_FOR_ALL_1" to null,
"NECRON_HANDLE" to null
),
var positions: MutableMap<String, GuiPosition> = mutableMapOf(),
var salvageMap: MutableMap<String, SalvageStrategy> = mutableMapOf(
"SLUG_BOOTS" to SalvageStrategy.Always,
"MOOGMA_LEGGINGS" to SalvageStrategy.Always,
"FLAMING_CHESTPLATE" to SalvageStrategy.Always,
"TAURUS_HELMET" to SalvageStrategy.Always,
"BLADE_OF_THE_VOLCANO" to SalvageStrategy.Always,
"STAFF_OF_THE_VOLCANO" to SalvageStrategy.Always,
"RAMPART_HELMET" to SalvageStrategy.Always,
"RAMPART_CHESTPLATE" to SalvageStrategy.Always,
"RAMPART_LEGGINGS" to SalvageStrategy.Always,
"RAMPART_BOOTS" to SalvageStrategy.Always,
"SWORD_OF_BAD_HEALTH" to SalvageStrategy.Always,
"ARACK" to SalvageStrategy.Always,
"ARACHNE_HELMET" to SalvageStrategy.Always,
"ARACHNE_CHESTPLATE" to SalvageStrategy.Always,
"ARACHNE_LEGGINGS" to SalvageStrategy.Always,
"ARACHNE_BOOTS" to SalvageStrategy.Always,
"BOUNCY_HELMET" to SalvageStrategy.Allow,
"BOUNCY_CHESTPLATE" to SalvageStrategy.Allow,
"BOUNCY_LEGGINGS" to SalvageStrategy.Allow,
"BOUNCY_BOOTS" to SalvageStrategy.Allow,
"SKELETON_LORD_HELMET" to SalvageStrategy.Allow,
"SKELETON_LORD_CHESTPLATE" to SalvageStrategy.Allow,
"SKELETON_LORD_LEGGINGS" to SalvageStrategy.Allow,
"SKELETON_LORD_BOOTS" to SalvageStrategy.Allow,
"ZOMBIE_LORD_HELMET" to SalvageStrategy.Allow,
"ZOMBIE_LORD_CHESTPLATE" to SalvageStrategy.Allow,
"ZOMBIE_LORD_LEGGINGS" to SalvageStrategy.Allow,
"ZOMBIE_LORD_BOOTS" to SalvageStrategy.Allow,
"WITHER_CLOAK_SWORD" to SalvageStrategy.Block,
"DARK_CLAYMORE" to SalvageStrategy.Block,
"GIANTS_SWORD" to SalvageStrategy.Block,
"WITHER_HELMET" to SalvageStrategy.Block,
"WITHER_CHESTPLATE" to SalvageStrategy.Block,
"WITHER_LEGGINGS" to SalvageStrategy.Block,
"WITHER_BOOTS" to SalvageStrategy.Block,
"ICE_SPRAY_WAND" to SalvageStrategy.Block,
"SHADOW_ASSASSIN_HELMET" to SalvageStrategy.Block,
"SHADOW_ASSASSIN_CHESTPLATE" to SalvageStrategy.Block,
"SHADOW_ASSASSIN_LEGGINGS" to SalvageStrategy.Block,
"SHADOW_ASSASSIN_BOOTS" to SalvageStrategy.Block,
)
) {
fun save() {
configFile.writeText(Json.encodeToString(this))
}
companion object {
private val configFile: File = File(AmbientAddons.configDirectory,"data.json")
fun load(): PersistentData {
val data = if (!configFile.exists()) {
configFile.createNewFile()
PersistentData()
} else configFile.runCatching {
Json.decodeFromString<PersistentData>(this.readText())
}.getOrNull() ?: PersistentData()
return data.apply {
this.save()
}
}
}
}
|