From 7944f8f88ec20b8caea0c41757366734682e059d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 26 Apr 2023 13:26:51 +0200 Subject: Added command /shclearminiondata - Manually reset all private island minion location data. --- .../hannibal2/skyhanni/config/commands/Commands.kt | 2 ++ .../skyhanni/features/minion/MinionFeatures.kt | 39 +++++++++++++--------- 2 files changed, 26 insertions(+), 15 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 452b038e7..259beee57 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenCropTimeCommand import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay import at.hannibal2.skyhanni.features.garden.farming.CropSpeedMeter +import at.hannibal2.skyhanni.features.minion.MinionFeatures import at.hannibal2.skyhanni.features.misc.CollectionCounter import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.test.LorenzTest @@ -61,6 +62,7 @@ object Commands { registerCommand("shcroptime") { GardenCropTimeCommand.onCommand(it) } registerCommand("shtestcomposter") { ComposterOverlay.onCommand(it) } registerCommand("shclearcropspeed") { GardenAPI.clearCropSpeed() } + registerCommand("shclearminiondata") { MinionFeatures.clearMinionData() } } private fun registerCommand(name: String, function: (Array) -> Unit) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt index d04372b32..382a3d8ed 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt @@ -37,7 +37,6 @@ class MinionFeatures { private var lastCoinsRecived = 0L private var lastMinionPickedUp = 0L - private val minions = mutableMapOf() private var coinsPerDay = "" private val minionUpgradePattern = "§aYou have upgraded your Minion to Tier (.*)".toPattern() @@ -179,20 +178,6 @@ class MinionFeatures { return "§7Coins/day with $hopperName§7: §6$format coins" } - private fun saveConfig() { - val minionConfig = SkyHanniMod.feature.hidden.minionLastClick - val minionName = SkyHanniMod.feature.hidden.minionName - - minionConfig.clear() - minionName.clear() - for (minion in minions) { - val coordinates = minion.key.encodeToString() - val data = minion.value - minionConfig[coordinates] = data.lastClicked - minionName[coordinates] = data.displayName - } - } - @SubscribeEvent fun onWorldChange(event: WorldEvent.Load) { lastClickedEntity = null @@ -283,4 +268,28 @@ class MinionFeatures { config.hopperProfitPos.renderString(coinsPerDay, posLabel = "Minion Coins Per Day") } } + + companion object { + private val minions = mutableMapOf() + + fun clearMinionData() { + minions.clear() + saveConfig() + LorenzUtils.chat("§e[SkyHanni] Manually reset all private island minion location data!") + } + + private fun saveConfig() { + val minionConfig = SkyHanniMod.feature.hidden.minionLastClick + val minionName = SkyHanniMod.feature.hidden.minionName + + minionConfig.clear() + minionName.clear() + for (minion in minions) { + val coordinates = minion.key.encodeToString() + val data = minion.value + minionConfig[coordinates] = data.lastClicked + minionName[coordinates] = data.displayName + } + } + } } \ No newline at end of file -- cgit