From 0bd2b6674edf094134d688b7fb0e5ec446e5ba3f Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:48:32 -0600 Subject: [PATCH 01/15] Fixed bps underestimation error --- .../skyhanni/features/garden/farming/GardenCropSpeed.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt index 0ef02361f855..6d7d2d6784ac 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt @@ -83,7 +83,7 @@ object GardenCropSpeed { } private fun checkSpeed() { - val blocksBroken = blocksBroken.coerceAtMost(20) + val blocksBroken = blocksBroken this.blocksBroken = 0 if (blocksBroken == 0) { From 3d8a4e71aeba67102a74b5f3a0947682d417f9ab Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Fri, 22 Nov 2024 17:09:09 -0600 Subject: [PATCH 02/15] Capped average bps at 20 --- .../skyhanni/features/garden/farming/GardenCropSpeed.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt index 6d7d2d6784ac..7c6cf2b80302 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropSpeed.kt @@ -105,9 +105,9 @@ object GardenCropSpeed { } } averageBlocksPerSecond = if (blocksSpeedList.size > 5) { - blocksSpeedList.drop(3).average() + blocksSpeedList.drop(3).average().coerceAtMost(20.0) } else if (blocksSpeedList.size > 1) { - blocksSpeedList.drop(1).average() + blocksSpeedList.drop(1).average().coerceAtMost(20.0) } else 0.0 GardenAPI.getCurrentlyFarmedCrop()?.let { val heldTool = InventoryUtils.getItemInHand() From f0f8d4755598445b73567aad0660b034e7fa6df4 Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Tue, 26 Nov 2024 12:07:51 -0600 Subject: [PATCH 03/15] Fixed personal best gain --- .../data/jsonobjects/repo/GardenJson.kt | 1 + .../garden/contest/FarmingPersonalBestGain.kt | 27 ++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt index 8f442681edba..bc2ce5b75892 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt @@ -14,6 +14,7 @@ data class GardenJson( @Expose val visitors: Map, @Expose @SerializedName("organic_matter") val organicMatter: Map, @Expose val fuel: Map, + @Expose @SerializedName("max_personal_best") val maxPersonalBest: Map, ) data class GardenVisitor( diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt index a2e8a859f703..ffa94cbc38e1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt @@ -1,6 +1,8 @@ package at.hannibal2.skyhanni.features.garden.contest +import at.hannibal2.skyhanni.data.jsonobjects.repo.GardenJson import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.features.garden.CropType import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule @@ -16,6 +18,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object FarmingPersonalBestGain { private val config get() = GardenAPI.config private val patternGroup = RepoPattern.group("garden.contest.personal.best") + private val maxPB = mutableMapOf() //Crop, Max PB /** * REGEX-TEST: §e[NPC] Jacob§f: §rYou collected §e1,400,694 §fitems! §d§lPERSONAL BEST§f! @@ -46,6 +49,16 @@ object FarmingPersonalBestGain { var oldCollected: Double? = null var newFF: Double? = null var crop: String? = null + var cropType: CropType? = null + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + val data = event.getConstant("Garden") + maxPB.clear() + for ((crop, pb) in data.maxPersonalBest) { + maxPB[crop] = pb + } + } @SubscribeEvent fun onChat(event: LorenzChatEvent) { @@ -55,6 +68,7 @@ object FarmingPersonalBestGain { newCollected = group("collected").formatDouble() checkDelayed() } + oldPattern.matchMatcher(event.message) { oldCollected = group("collected").formatDouble() checkDelayed() @@ -63,7 +77,7 @@ object FarmingPersonalBestGain { val cropName = group("crop") newFF = group("ff").formatDouble() crop = cropName - val cropType = CropType.getByName(cropName) + cropType = CropType.getByName(cropName) GardenAPI.storage?.let { it.personalBestFF[cropType] = newFF } @@ -74,21 +88,22 @@ object FarmingPersonalBestGain { private fun checkDelayed() = DelayedRun.runNextTick { check() } private fun check() { - val newCollected = newCollected ?: return val oldCollected = oldCollected ?: return - val newFF = newFF ?: return + val newFF = newFF?.coerceAtMost(100.0) ?: return val crop = crop ?: return - + val maxPB = maxPB[cropType] ?: return this.newCollected = null this.oldCollected = null this.newFF = null this.crop = null - val collectionPerFF = newCollected / newFF + val collectionPerFF = maxPB / 100 val oldFF = oldCollected / collectionPerFF val ffDiff = newFF - oldFF - ChatUtils.chat("This is §6${ffDiff.roundTo(2)}☘ $crop Fortune §emore than previously!") + if(oldFF<100){ + ChatUtils.chat("This is §6${ffDiff.roundTo(2)}☘ $crop Fortune §emore than previously!") + } } fun isEnabled() = GardenAPI.inGarden() && config.contestPersonalBestIncreaseFF From a03cba2c2a6af396b54dcb41432cb13f765711de Mon Sep 17 00:00:00 2001 From: Chissl <78828070+Chissl@users.noreply.github.com> Date: Tue, 26 Nov 2024 18:41:50 +0000 Subject: [PATCH 04/15] Fixed formatting errors in FarmingPersonalBestGain.kt --- .../features/garden/contest/FarmingPersonalBestGain.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt index ffa94cbc38e1..24a2d49701e4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt @@ -18,7 +18,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object FarmingPersonalBestGain { private val config get() = GardenAPI.config private val patternGroup = RepoPattern.group("garden.contest.personal.best") - private val maxPB = mutableMapOf() //Crop, Max PB + private val maxPB = mutableMapOf() /** * REGEX-TEST: §e[NPC] Jacob§f: §rYou collected §e1,400,694 §fitems! §d§lPERSONAL BEST§f! @@ -101,7 +101,7 @@ object FarmingPersonalBestGain { val oldFF = oldCollected / collectionPerFF val ffDiff = newFF - oldFF - if(oldFF<100){ + if (oldFF < 100) { ChatUtils.chat("This is §6${ffDiff.roundTo(2)}☘ $crop Fortune §emore than previously!") } } From deabce18aa627bd2b21b51dc18d6e023cae350fd Mon Sep 17 00:00:00 2001 From: Chiss5618 Date: Tue, 26 Nov 2024 13:43:28 -0600 Subject: [PATCH 05/15] change max pb value to int --- .../at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt | 2 +- .../skyhanni/features/garden/contest/FarmingPersonalBestGain.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt index bc2ce5b75892..f7df245e0884 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt @@ -14,7 +14,7 @@ data class GardenJson( @Expose val visitors: Map, @Expose @SerializedName("organic_matter") val organicMatter: Map, @Expose val fuel: Map, - @Expose @SerializedName("max_personal_best") val maxPersonalBest: Map, + @Expose @SerializedName("max_personal_best") val maxPersonalBest: Map, ) data class GardenVisitor( diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt index 24a2d49701e4..b96ca41b8b29 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt @@ -18,7 +18,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object FarmingPersonalBestGain { private val config get() = GardenAPI.config private val patternGroup = RepoPattern.group("garden.contest.personal.best") - private val maxPB = mutableMapOf() + private val maxPB = mutableMapOf() /** * REGEX-TEST: §e[NPC] Jacob§f: §rYou collected §e1,400,694 §fitems! §d§lPERSONAL BEST§f! From 985263e34730c9061c15e8af660262a1f11848a5 Mon Sep 17 00:00:00 2001 From: Chiss5618 Date: Tue, 26 Nov 2024 13:57:51 -0600 Subject: [PATCH 06/15] fix wrong int type --- .../at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt | 2 +- .../skyhanni/features/garden/contest/FarmingPersonalBestGain.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt index f7df245e0884..433b545d2d1c 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt @@ -14,7 +14,7 @@ data class GardenJson( @Expose val visitors: Map, @Expose @SerializedName("organic_matter") val organicMatter: Map, @Expose val fuel: Map, - @Expose @SerializedName("max_personal_best") val maxPersonalBest: Map, + @Expose @SerializedName("max_personal_best") val maxPersonalBest: Map, ) data class GardenVisitor( diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt index b96ca41b8b29..30eb9972b042 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt @@ -18,7 +18,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object FarmingPersonalBestGain { private val config get() = GardenAPI.config private val patternGroup = RepoPattern.group("garden.contest.personal.best") - private val maxPB = mutableMapOf() + private val maxPB = mutableMapOf() /** * REGEX-TEST: §e[NPC] Jacob§f: §rYou collected §e1,400,694 §fitems! §d§lPERSONAL BEST§f! From dea08cf55284a5437c471455cb03c317f17f991b Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Tue, 26 Nov 2024 20:54:27 -0600 Subject: [PATCH 07/15] add personal bests overflow --- .../config/features/garden/GardenConfig.java | 14 ++++------ .../features/garden/PersonalBestsConfig.java | 27 +++++++++++++++++++ .../data/jsonobjects/repo/GardenJson.kt | 2 +- .../garden/contest/FarmingPersonalBestGain.kt | 25 ++++++++++------- 4 files changed, 48 insertions(+), 20 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java index 8aa9aa6a1124..b2b3f19aeaa1 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java @@ -140,6 +140,11 @@ public class GardenConfig { @Accordion public AtmosphericFilterDisplayConfig atmosphericFilterDisplay = new AtmosphericFilterDisplayConfig(); + @Expose + @ConfigOption(name = "Personal Bests", desc = "") + @Accordion + public PersonalBestsConfig personalBests = new PersonalBestsConfig(); + @Expose @ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.") @ConfigEditorBoolean @@ -211,15 +216,6 @@ public class GardenConfig { @FeatureToggle public boolean jacobContestSummary = true; - @Expose - @ConfigOption( - name = "Personal Best Increase FF", - desc = "Show in chat how much more FF you get from farming contest personal best bonus after beating the previous record." - ) - @ConfigEditorBoolean - @FeatureToggle - public boolean contestPersonalBestIncreaseFF = true; - // Does not have a config element! @Expose public Position cropSpeedMeterPos = new Position(278, -236, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java new file mode 100644 index 000000000000..66e6a5fd6079 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java @@ -0,0 +1,27 @@ +package at.hannibal2.skyhanni.config.features.garden; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; + + +public class PersonalBestsConfig { + @Expose + @ConfigOption( + name = "Personal Best Increase FF", + desc = "Show in chat how much more FF you get from farming contest personal best bonus after beating the previous record." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean contestPersonalBestIncreaseFF = true; + + @Expose + @ConfigOption( + name = "Overflow Personal Bests", + desc = "Show in chat how much more FF you would have gotten over your previous record if personal best fortune cap was not 100" + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean contestPersonalBestOverflow = false; +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt index 433b545d2d1c..78ebe274ffde 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GardenJson.kt @@ -14,7 +14,7 @@ data class GardenJson( @Expose val visitors: Map, @Expose @SerializedName("organic_matter") val organicMatter: Map, @Expose val fuel: Map, - @Expose @SerializedName("max_personal_best") val maxPersonalBest: Map, + @Expose @SerializedName("personal_best_increment") val personalBestIncrement: Map, ) data class GardenVisitor( diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt index 30eb9972b042..2cd30635642e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt @@ -16,9 +16,9 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @SkyHanniModule object FarmingPersonalBestGain { - private val config get() = GardenAPI.config + private val config get() = GardenAPI.config.personalBests private val patternGroup = RepoPattern.group("garden.contest.personal.best") - private val maxPB = mutableMapOf() + private val pbIncrement = mutableMapOf() /** * REGEX-TEST: §e[NPC] Jacob§f: §rYou collected §e1,400,694 §fitems! §d§lPERSONAL BEST§f! @@ -54,9 +54,9 @@ object FarmingPersonalBestGain { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("Garden") - maxPB.clear() - for ((crop, pb) in data.maxPersonalBest) { - maxPB[crop] = pb + pbIncrement.clear() + for ((crop, pb) in data.personalBestIncrement) { + pbIncrement[crop] = pb } } @@ -88,21 +88,26 @@ object FarmingPersonalBestGain { private fun checkDelayed() = DelayedRun.runNextTick { check() } private fun check() { + val newCollected = newCollected ?: return val oldCollected = oldCollected ?: return - val newFF = newFF?.coerceAtMost(100.0) ?: return + val newFF = newFF ?: return val crop = crop ?: return - val maxPB = maxPB[cropType] ?: return + val pbIncrement = pbIncrement[cropType] ?: return this.newCollected = null this.oldCollected = null this.newFF = null this.crop = null - val collectionPerFF = maxPB / 100 - val oldFF = oldCollected / collectionPerFF + val oldFF = oldCollected / pbIncrement + val newOverflowFF = newCollected / pbIncrement val ffDiff = newFF - oldFF + val overflowFFDiff = newOverflowFF - oldFF - if (oldFF < 100) { + if (oldFF < 100 && !config.contestPersonalBestOverflow) { ChatUtils.chat("This is §6${ffDiff.roundTo(2)}☘ $crop Fortune §emore than previously!") + } else if (newOverflowFF > 100 && config.contestPersonalBestOverflow) { + ChatUtils.chat("You have §6${newOverflowFF.roundTo(2)}☘ $crop Fortune §eincluding overflow!") + ChatUtils.chat("This is §6${overflowFFDiff.roundTo(2)}☘ $crop Fortune §emore than previously!") } } From 2cc450a8b95512795ac7b4f33037a185e516e5c2 Mon Sep 17 00:00:00 2001 From: Chiss5618 <78828070+Chiss5618@users.noreply.github.com> Date: Tue, 26 Nov 2024 21:16:30 -0600 Subject: [PATCH 08/15] update personal best increment to be for every .01 fortune --- .../features/garden/contest/FarmingPersonalBestGain.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt index 2cd30635642e..fd9515f16c2f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt @@ -98,8 +98,8 @@ object FarmingPersonalBestGain { this.newFF = null this.crop = null - val oldFF = oldCollected / pbIncrement - val newOverflowFF = newCollected / pbIncrement + val oldFF = oldCollected / (pbIncrement * 100) + val newOverflowFF = newCollected / (pbIncrement * 100) val ffDiff = newFF - oldFF val overflowFFDiff = newOverflowFF - oldFF From c8ca0f1448d1223d183372d0dbe53e43446b1288 Mon Sep 17 00:00:00 2001 From: Chiss5618 Date: Thu, 28 Nov 2024 14:01:28 -0600 Subject: [PATCH 09/15] config fix --- .../java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index 257518074b06..7ab37e7d3264 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 67 + const val CONFIG_VERSION = 68 fun JsonElement.at(chain: List, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null From 43407084ffa87914aaf749ade4df526eb616eb25 Mon Sep 17 00:00:00 2001 From: Chiss5618 Date: Thu, 28 Nov 2024 14:50:57 -0600 Subject: [PATCH 10/15] removed feature toggle for overflow pb --- .../skyhanni/config/features/garden/PersonalBestsConfig.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java index 66e6a5fd6079..76fdeb49cec8 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java @@ -22,6 +22,5 @@ public class PersonalBestsConfig { desc = "Show in chat how much more FF you would have gotten over your previous record if personal best fortune cap was not 100" ) @ConfigEditorBoolean - @FeatureToggle public boolean contestPersonalBestOverflow = false; } From a44fb51ec691728c34c66247e16d691abdf905f1 Mon Sep 17 00:00:00 2001 From: Chiss5618 Date: Thu, 28 Nov 2024 18:21:13 -0600 Subject: [PATCH 11/15] actually fix config --- .../garden/contest/FarmingPersonalBestGain.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt index fd9515f16c2f..bd5fe2e4e0e1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.garden.contest +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.data.jsonobjects.repo.GardenJson import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent @@ -18,7 +19,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object FarmingPersonalBestGain { private val config get() = GardenAPI.config.personalBests private val patternGroup = RepoPattern.group("garden.contest.personal.best") - private val pbIncrement = mutableMapOf() + private var pbIncrement = mapOf() /** * REGEX-TEST: §e[NPC] Jacob§f: §rYou collected §e1,400,694 §fitems! §d§lPERSONAL BEST§f! @@ -54,10 +55,12 @@ object FarmingPersonalBestGain { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("Garden") - pbIncrement.clear() - for ((crop, pb) in data.personalBestIncrement) { - pbIncrement[crop] = pb - } + pbIncrement = data.personalBestIncrement + } + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(68, "garden.contestPersonalBestIncreaseFF", "garden.personalBests.increaseFF") } @SubscribeEvent @@ -103,13 +106,13 @@ object FarmingPersonalBestGain { val ffDiff = newFF - oldFF val overflowFFDiff = newOverflowFF - oldFF - if (oldFF < 100 && !config.contestPersonalBestOverflow) { + if (oldFF < 100 && !config.overflow) { ChatUtils.chat("This is §6${ffDiff.roundTo(2)}☘ $crop Fortune §emore than previously!") - } else if (newOverflowFF > 100 && config.contestPersonalBestOverflow) { + } else if (newOverflowFF > 100 && config.overflow) { ChatUtils.chat("You have §6${newOverflowFF.roundTo(2)}☘ $crop Fortune §eincluding overflow!") ChatUtils.chat("This is §6${overflowFFDiff.roundTo(2)}☘ $crop Fortune §emore than previously!") } } - fun isEnabled() = GardenAPI.inGarden() && config.contestPersonalBestIncreaseFF + fun isEnabled() = GardenAPI.inGarden() && config.increaseFF } From 45e51d8c45f0f40f08ed5a4e47f1fd23296ba0c9 Mon Sep 17 00:00:00 2001 From: Chiss5618 Date: Thu, 28 Nov 2024 18:21:56 -0600 Subject: [PATCH 12/15] shorten config names for clarity --- .../skyhanni/config/features/garden/PersonalBestsConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java index 76fdeb49cec8..7fe93d5b5c61 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java @@ -14,7 +14,7 @@ public class PersonalBestsConfig { ) @ConfigEditorBoolean @FeatureToggle - public boolean contestPersonalBestIncreaseFF = true; + public boolean increaseFF = true; @Expose @ConfigOption( @@ -22,5 +22,5 @@ public class PersonalBestsConfig { desc = "Show in chat how much more FF you would have gotten over your previous record if personal best fortune cap was not 100" ) @ConfigEditorBoolean - public boolean contestPersonalBestOverflow = false; + public boolean overflow = false; } From 035bc415c4dbe672ff79fe0fabd1112e491dd65d Mon Sep 17 00:00:00 2001 From: Chissl <78828070+Chissl@users.noreply.github.com> Date: Fri, 29 Nov 2024 00:32:07 +0000 Subject: [PATCH 13/15] fix typo Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> --- .../skyhanni/config/features/garden/PersonalBestsConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java index 7fe93d5b5c61..c02642a552a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/PersonalBestsConfig.java @@ -19,7 +19,7 @@ public class PersonalBestsConfig { @Expose @ConfigOption( name = "Overflow Personal Bests", - desc = "Show in chat how much more FF you would have gotten over your previous record if personal best fortune cap was not 100" + desc = "Show in chat how much more FF you would have gotten over your previous record if personal best fortune cap was not 100." ) @ConfigEditorBoolean public boolean overflow = false; From 664d510af25061d8885646c2372aeb9e11d94cf1 Mon Sep 17 00:00:00 2001 From: Chiss5618 Date: Thu, 28 Nov 2024 18:36:37 -0600 Subject: [PATCH 14/15] rename pbIncrement to personalBestIncrements --- .../features/garden/contest/FarmingPersonalBestGain.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt index bd5fe2e4e0e1..bc7efee1e3b3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt @@ -19,7 +19,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent object FarmingPersonalBestGain { private val config get() = GardenAPI.config.personalBests private val patternGroup = RepoPattern.group("garden.contest.personal.best") - private var pbIncrement = mapOf() + private var personalBestIncrements = mapOf() /** * REGEX-TEST: §e[NPC] Jacob§f: §rYou collected §e1,400,694 §fitems! §d§lPERSONAL BEST§f! @@ -55,7 +55,7 @@ object FarmingPersonalBestGain { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant("Garden") - pbIncrement = data.personalBestIncrement + personalBestIncrements = data.personalBestIncrement } @SubscribeEvent @@ -95,7 +95,7 @@ object FarmingPersonalBestGain { val oldCollected = oldCollected ?: return val newFF = newFF ?: return val crop = crop ?: return - val pbIncrement = pbIncrement[cropType] ?: return + val pbIncrement = personalBestIncrements[cropType] ?: return this.newCollected = null this.oldCollected = null this.newFF = null From 5975d0b4a7c0514675c632279a0b539cc771a53f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 29 Nov 2024 10:37:59 +0100 Subject: [PATCH 15/15] fix not resetting values when the repo has problems --- .../skyhanni/features/garden/contest/FarmingPersonalBestGain.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt index bc7efee1e3b3..729693c1d4d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/FarmingPersonalBestGain.kt @@ -95,12 +95,12 @@ object FarmingPersonalBestGain { val oldCollected = oldCollected ?: return val newFF = newFF ?: return val crop = crop ?: return - val pbIncrement = personalBestIncrements[cropType] ?: return this.newCollected = null this.oldCollected = null this.newFF = null this.crop = null + val pbIncrement = personalBestIncrements[cropType] ?: return val oldFF = oldCollected / (pbIncrement * 100) val newOverflowFF = newCollected / (pbIncrement * 100) val ffDiff = newFF - oldFF