diff options
author | Appability <appable@icloud.com> | 2022-10-11 23:59:37 -0700 |
---|---|---|
committer | Appability <appable@icloud.com> | 2022-10-11 23:59:37 -0700 |
commit | 2c0e73deb53f54d78bd5594786313ac82151be1a (patch) | |
tree | 97fc2f389cc99d8f9e078a1cd7b0c6a5859a3f34 /src/main/kotlin/com/ambientaddons/config | |
parent | 363b2426f8d9e45e52c472750c798dcaceb05a88 (diff) | |
download | AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.tar.gz AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.tar.bz2 AmbientAddons-2c0e73deb53f54d78bd5594786313ac82151be1a.zip |
added chest qol features (complete, i think)
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/config')
-rw-r--r-- | src/main/kotlin/com/ambientaddons/config/Config.kt | 36 | ||||
-rw-r--r-- | src/main/kotlin/com/ambientaddons/config/PersistentData.kt | 48 |
2 files changed, 84 insertions, 0 deletions
diff --git a/src/main/kotlin/com/ambientaddons/config/Config.kt b/src/main/kotlin/com/ambientaddons/config/Config.kt new file mode 100644 index 0000000..b283abb --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/config/Config.kt @@ -0,0 +1,36 @@ +package com.ambientaddons.config + +import gg.essential.vigilance.Vigilant +import java.awt.Color +import java.io.File + + +object Config : Vigilant( + File(AmbientAddons.configDirectory, "config.toml"), + AmbientAddons.metadata.name +) { + var blockLowReroll = false + var autoBuyChest = 0 + + init { + category("Pre/Post Dungeon") { + subcategory("Chest QOL") { + switch ( + ::blockLowReroll, + name = "Block rerolling low chests", + description = "Prevents rerolling non-Bedrock chests (or Obsidian on M4)." + ) + selector( + ::autoBuyChest, + name = "Dungeon Reward Chests", + description = "Either blocks rerolls or automatically buys dungeon reward chests containing certain items.", + options = listOf("Off", "Block Reroll", "Autobuy") + ) + } + + } + } + + + +}
\ No newline at end of file diff --git a/src/main/kotlin/com/ambientaddons/config/PersistentData.kt b/src/main/kotlin/com/ambientaddons/config/PersistentData.kt new file mode 100644 index 0000000..87bb287 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/config/PersistentData.kt @@ -0,0 +1,48 @@ +package com.ambientaddons.config + +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 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, + "GIANTS_SWORD" to null, + "DARK_CLAYMORE" to null, + "THUNDERLORD_7" to null, + "WITHER_CHESTPLATE" to null, + "ULTIMATE_ONE_FOR_ALL_1" to null + ) +) { + + 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() + } + } + } +}
\ No newline at end of file |