diff options
Diffstat (limited to 'src')
3 files changed, 12 insertions, 23 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index f5e6bdce2..21ebef73b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.data.model.ComposterUpgrade; import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity; import at.hannibal2.skyhanni.features.garden.CropAccessory; import at.hannibal2.skyhanni.features.garden.CropType; +import at.hannibal2.skyhanni.features.garden.farming.FarmingArmorDrops; import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; import at.hannibal2.skyhanni.features.misc.EnderNode; @@ -128,7 +129,7 @@ public class Storage { public long nextSixthVisitorArrival = 0; @Expose - public Map<String, Integer> farmArmorDrops = new HashMap<>(); + public Map<FarmingArmorDrops.ArmorDropType, Integer> farmArmorDrops = new HashMap<>(); @Expose public Map<ComposterUpgrade, Integer> composterUpgrades = new HashMap<>(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/OldHidden.java b/src/main/java/at/hannibal2/skyhanni/config/features/OldHidden.java index fbb59156d..23de8abe9 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/OldHidden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/OldHidden.java @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.config.features; import at.hannibal2.skyhanni.data.model.ComposterUpgrade; import at.hannibal2.skyhanni.features.garden.CropAccessory; import at.hannibal2.skyhanni.features.garden.CropType; +import at.hannibal2.skyhanni.features.garden.farming.FarmingArmorDrops; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; import com.google.gson.annotations.Expose; @@ -77,7 +78,7 @@ public class OldHidden { public Map<Long, List<CropType>> gardenJacobFarmingContestTimes = new HashMap<>(); @Expose - public Map<String, Integer> gardenFarmingArmorDrops = new HashMap<>(); + public Map<FarmingArmorDrops.ArmorDropType, Integer> gardenFarmingArmorDrops = new HashMap<>(); @Expose public Map<ComposterUpgrade, Integer> gardenComposterUpgrades = new HashMap<>(); diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt index 63d1a39a9..55a0f157b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt @@ -12,7 +12,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class FarmingArmorDrops { private var display = emptyList<String>() - private val drops = mutableMapOf<ArmorDropType, Int>() + private val storage get() = GardenAPI.config + private var hasArmor = false private val armorPattern = "(FERMENTO|CROPIE|SQUASH|MELON)_(LEGGINGS|CHESTPLATE|BOOTS|HELMET)".toPattern() private val config get() = SkyHanniMod.feature.garden @@ -26,7 +27,6 @@ class FarmingArmorDrops { @SubscribeEvent fun onPreProfileSwitch(event: PreProfileSwitchEvent) { display = emptyList() - drops.clear() hasArmor = false } @@ -43,9 +43,9 @@ class FarmingArmorDrops { } private fun addDrop(drop: ArmorDropType) { + val drops = storage?.farmArmorDrops ?: return val old = drops[drop] ?: 0 drops[drop] = old + 1 - saveConfig() update() } @@ -53,31 +53,18 @@ class FarmingArmorDrops { display = drawDisplay() } - private fun drawDisplay(): List<String> { - val help = mutableListOf<String>() - help.add("§7RNG Drops for Farming Armor:") + private fun drawDisplay() = buildList { + val drops = storage?.farmArmorDrops ?: return@buildList + + add("§7RNG Drops for Farming Armor:") for ((drop, amount) in drops.sortedDesc()) { val dropName = drop.dropName - help.add(" §7- §e${amount.addSeparators()}x $dropName") - } - - return help - } - - private fun saveConfig() { - val map = GardenAPI.config?.farmArmorDrops ?: return - map.clear() - for ((drop, amount) in drops) { - map[drop.toString()] = amount + add(" §7- §e${amount.addSeparators()}x $dropName") } } @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { - val map = GardenAPI.config?.farmArmorDrops ?: return - for ((rawName, amount) in map) { - drops[ArmorDropType.valueOf(rawName)] = amount - } update() } |