From 9f3562c243f9b161ce87a14ee7dd5ee74e9677df Mon Sep 17 00:00:00 2001 From: Obsidianninja11 Date: Tue, 26 Dec 2023 22:32:24 -0900 Subject: [PATCH 01/23] wip live contest stats --- .../config/features/garden/GardenConfig.java | 14 +-- .../garden/JacobContestStatsConfig.java | 60 ++++++++++++ .../contest/JacobContestStatsSummary.kt | 92 ++++++++++++++++++- 3 files changed, 156 insertions(+), 10 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/garden/JacobContestStatsConfig.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 b541cd0ee171..7a210daea070 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 @@ -119,6 +119,11 @@ public class GardenConfig { @Accordion public GardenCommandsConfig gardenCommands = new GardenCommandsConfig(); + @Expose + @ConfigOption(name = "Jacob Contest Stats", desc = "") + @Accordion + public JacobContestStatsConfig jacobContestStats = new JacobContestStatsConfig(); + @Expose @ConfigOption(name = "Plot Price", desc = "Show the price of the plot in coins when inside the Configure Plots inventory.") @ConfigEditorBoolean @@ -191,15 +196,6 @@ public class GardenConfig { @Expose public Position jacobContextTimesPos = new Position(-359, 149, false, true); - @Expose - @ConfigOption( - name = "Contest Summary", - desc = "Show the average Blocks Per Second and blocks clicked at the end of a Jacob Farming Contest in chat." - ) - @ConfigEditorBoolean - @FeatureToggle - public boolean jacobContestSummary = true; - @Expose @ConfigOption(name = "Always Finnegan", desc = "Forcefully set the Finnegan Farming Simulator perk to be active. This is useful if the auto mayor detection fails.") @ConfigEditorBoolean diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/JacobContestStatsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/JacobContestStatsConfig.java new file mode 100644 index 000000000000..d876c6827229 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/JacobContestStatsConfig.java @@ -0,0 +1,60 @@ +package at.hannibal2.skyhanni.config.features.garden; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.core.config.Position; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.moulberry.moulconfig.annotations.ConfigOption; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class JacobContestStatsConfig { + + @Expose + @ConfigOption( + name = "Contest Stats", + desc = "Show contest stats during a contest and after a contest in chat." + ) + @ConfigEditorBoolean + @FeatureToggle + public boolean jacobContestSummary = true; + + @Expose + @ConfigOption(name = "Contest Stats Text", desc = "Drag to change the order of the overlay." + ) + @ConfigEditorDraggableList + public List text = new ArrayList<>(Arrays.asList( + ContestStatsTextEntry.TITLE, + ContestStatsTextEntry.TIME_PARTICIPATED, + ContestStatsTextEntry.BLOCKS_BROKEN, + ContestStatsTextEntry.BPS, + ContestStatsTextEntry.POSITION, + ContestStatsTextEntry.PREDICTED_SCORE + )); + + public enum ContestStatsTextEntry { + TITLE("§e§lWheat Contest Stats"), + TIME_PARTICIPATED("§7Participating for §b18m 23s"), + BLOCKS_BROKEN("§7Blocks Broken: §e21,972"), + BPS("§7Blocks per Second: §c19.92"), + POSITION("§7Estimated Position: §b5th §7§7(Top §b0.4% §7◆ 1.1k)"), + PREDICTED_SCORE("§7Predicted Score: §e432,123"); + + private final String str; + + ContestStatsTextEntry(String str) { + this.str = str; + } + + @Override + public String toString() { + return str; + } + } + + @Expose + public Position pos = new Position(-112, -143, false, true); +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt index 72dc37621b47..0feb5c435ee5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/contest/JacobContestStatsSummary.kt @@ -1,19 +1,37 @@ package at.hannibal2.skyhanni.features.garden.contest import at.hannibal2.skyhanni.data.ClickType +import at.hannibal2.skyhanni.data.ScoreboardData import at.hannibal2.skyhanni.events.CropClickEvent import at.hannibal2.skyhanni.events.FarmingContestEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.ScoreboardChangeEvent +import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeUtils import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.math.roundToInt class JacobContestStatsSummary { - private val config get() = GardenAPI.config + private val config get() = GardenAPI.config.jacobContestStats private var blocksBroken = 0 private var startTime = 0L + private var percent = 0.0 + private var participants = 0 + private var contestStats = emptyList>() + + private val tabContestPattern = + " §r(§e○|§6☘) §r§f(?.+) §r§f◆ §r§f§lTOP §r§e§l(?(\\d|[.])+)% §r§f◆ (?.+) ☻".toPattern() + private val scoreboardContestTimeLeftPattern = "(§e○|§6☘) §f(?.+) §a(?