diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-23 15:38:34 +0100 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-23 15:38:34 +0100 |
| commit | 53303c391dc335bc676263f5be75bcc110a74446 (patch) | |
| tree | bbac55772616c16d041d4753ecd36565441286cb /src/main/java/at/hannibal2/skyhanni/features/misc | |
| parent | afb4dae8eda1403079d73480dd3621d5e361f21f (diff) | |
| download | skyhanni-53303c391dc335bc676263f5be75bcc110a74446.tar.gz skyhanni-53303c391dc335bc676263f5be75bcc110a74446.tar.bz2 skyhanni-53303c391dc335bc676263f5be75bcc110a74446.zip | |
removed toMutableList in render list logic and prevent ConcurrentModificationException
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt index 0fc8b26d8..742e91c1d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -24,7 +24,7 @@ class NonGodPotEffectDisplay { private var checkFooter = false private val activeEffects = mutableMapOf<String, Long>() - private val display = mutableListOf<String>() + private var display = listOf<String>() private var lastTick = 0L private var nonGodPotEffects = mapOf( @@ -82,12 +82,17 @@ class NonGodPotEffectDisplay { private fun update() { val now = System.currentTimeMillis() - display.clear() if (activeEffects.values.removeIf { now > it }) { //to fetch the real amount of active pots totalEffectsCount = 0 checkFooter = true } + + display = drawDisplay(now) + } + + private fun drawDisplay(now: Long): MutableList<String> { + val newDisplay = mutableListOf<String>() for (effect in activeEffects.sorted()) { val label = effect.key if (label.contains("Invisibility")) continue @@ -100,14 +105,15 @@ class NonGodPotEffectDisplay { val color = colorForTime(seconds) - display.add("$label $color$format") + newDisplay.add("$label $color$format") } val diff = totalEffectsCount - activeEffects.size if (diff > 0) { - display.add("§eOpen the /effects inventory") - display.add("§eto show the missing $diff effects!") + newDisplay.add("§eOpen the /effects inventory") + newDisplay.add("§eto show the missing $diff effects!") checkFooter = true } + return newDisplay } private fun colorForTime(seconds: Long): String { |
