aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/features
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-03 20:02:10 +0200
committernea <nea@nea.moe>2023-05-03 20:02:10 +0200
commite9f9ad1ac087066c1e597054fafc55e95f2ccb1e (patch)
tree2e17d890a4bf661e83ee262245c8af3c4222eb2b /src/main/kotlin/moe/nea/notenoughupdates/features
parentf844feba1b874a946f020574fee06c5926d042f8 (diff)
downloadfirmament-e9f9ad1ac087066c1e597054fafc55e95f2ccb1e.tar.gz
firmament-e9f9ad1ac087066c1e597054fafc55e95f2ccb1e.tar.bz2
firmament-e9f9ad1ac087066c1e597054fafc55e95f2ccb1e.zip
Fix color not being reset after block highlights
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/features')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/features/NEUFeature.kt4
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt26
2 files changed, 18 insertions, 12 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/features/NEUFeature.kt b/src/main/kotlin/moe/nea/notenoughupdates/features/NEUFeature.kt
index 1d3628e..39cfb35 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/features/NEUFeature.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/features/NEUFeature.kt
@@ -1,5 +1,7 @@
package moe.nea.notenoughupdates.features
+import moe.nea.notenoughupdates.util.config.ManagedConfig
+
interface NEUFeature {
val name: String
val identifier: String
@@ -10,7 +12,7 @@ interface NEUFeature {
set(value) {
FeatureManager.setEnabled(identifier, value)
}
-
+ val config: ManagedConfig? get() = null
fun onLoad()
}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt b/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt
index d65af26..2a5219a 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt
@@ -3,8 +3,6 @@ package moe.nea.notenoughupdates.features.world
import io.github.moulberry.repo.data.Coordinate
import kotlinx.serialization.Serializable
import kotlinx.serialization.serializer
-import net.minecraft.client.MinecraftClient
-import net.minecraft.util.math.BlockPos
import moe.nea.notenoughupdates.events.ServerChatLineReceivedEvent
import moe.nea.notenoughupdates.events.SkyblockServerUpdateEvent
import moe.nea.notenoughupdates.events.WorldRenderLastEvent
@@ -12,26 +10,32 @@ import moe.nea.notenoughupdates.features.NEUFeature
import moe.nea.notenoughupdates.repo.RepoManager
import moe.nea.notenoughupdates.util.MC
import moe.nea.notenoughupdates.util.SBData
+import moe.nea.notenoughupdates.util.blockPos
import moe.nea.notenoughupdates.util.config.ManagedConfig
import moe.nea.notenoughupdates.util.data.ProfileSpecificDataHolder
import moe.nea.notenoughupdates.util.render.RenderBlockContext.Companion.renderBlocks
import moe.nea.notenoughupdates.util.unformattedString
-val Coordinate.blockPos: BlockPos
- get() = BlockPos(x, y, z)
-object FairySouls : NEUFeature,
- ProfileSpecificDataHolder<FairySouls.Config>(serializer(), "found-fairysouls", ::Config) {
+object FairySouls : NEUFeature {
+
+
@Serializable
- data class Config(
+ data class Data(
val foundSouls: MutableMap<String, MutableSet<Int>> = mutableMapOf()
)
+ override val config: ManagedConfig
+ get() = TConfig
+
+ object DConfig : ProfileSpecificDataHolder<Data>(serializer(), "found-fairysouls", ::Data)
+
+
object TConfig : ManagedConfig("fairysouls") {
val displaySouls by toggle("show") { false }
val resetSouls by button("reset") {
- FairySouls.data?.foundSouls?.clear() != null
+ DConfig.data?.foundSouls?.clear() != null
updateMissingSouls()
}
}
@@ -49,7 +53,7 @@ object FairySouls : NEUFeature,
fun updateMissingSouls() {
currentMissingSouls = emptyList()
- val c = data ?: return
+ val c = DConfig.data ?: return
val fi = c.foundSouls[currentLocationName] ?: setOf()
val cms = currentLocationSouls.toMutableList()
fi.asSequence().sortedDescending().filter { it in cms.indices }.forEach { cms.removeAt(it) }
@@ -77,11 +81,11 @@ object FairySouls : NEUFeature,
private fun markNearestSoul() {
val nearestSoul = findNearestClickableSoul() ?: return
- val c = data ?: return
+ val c = DConfig.data ?: return
val loc = currentLocationName ?: return
val idx = currentLocationSouls.indexOf(nearestSoul)
c.foundSouls.computeIfAbsent(loc) { mutableSetOf() }.add(idx)
- markDirty()
+ DConfig.markDirty()
updateMissingSouls()
}