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..e94dd21a123b 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 = "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 @@ -180,6 +185,10 @@ public class GardenConfig { @FeatureToggle public boolean jacobContestTimes = true; + @Expose + @ConfigLink(owner = GardenConfig.class, field = "jacobContestTimes") + public Position jacobContestTimesPosition = new Position(-359, 149, false, true); + @Expose @ConfigOption( name = "Custom BPS", @@ -198,19 +207,6 @@ public class GardenConfig { ) public double jacobContestCustomBpsValue = 19.9; - @Expose - @ConfigLink(owner = GardenConfig.class, field = "jacobContestTimes") - public Position jacobContestTimesPosition = 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 = "Personal Best Increase FF", @@ -220,7 +216,6 @@ public class GardenConfig { @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/JacobContestStatsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/JacobContestStatsConfig.java new file mode 100644 index 000000000000..69289a822114 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/JacobContestStatsConfig.java @@ -0,0 +1,63 @@ +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.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; +import io.github.notenoughupdates.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.START_TIME, + ContestStatsTextEntry.BLOCKS_BROKEN, + ContestStatsTextEntry.BPS, + ContestStatsTextEntry.POSITION, + ContestStatsTextEntry.PREDICTED_SCORE + )); + + public enum ContestStatsTextEntry { + TITLE("§e§lSugar Cane Contest Stats"), + START_TIME("§7Started §b3s §7into contest"), + PARTICIPATING_TIME("§7Participating for §b15m 25s"), + BLOCKS_BROKEN("§7Blocks Broken: §e14,781"), + BPS("§7Blocks per Second: §c19.94"), + POSITION("§7Position: Top §b0.1%"), + PREDICTED_SCORE("§7Predicted Score: §e915,430"); + + private final String str; + + ContestStatsTextEntry(String str) { + this.str = str; + } + + @Override + public String toString() { + return str; + } + } + + @Expose + @ConfigLink(owner = JacobContestStatsConfig.class, field = "jacobContestSummary") + public Position pos = new Position(0, 240, 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 144abc0c2486..d3b97cfe219e 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 @@ -3,32 +3,150 @@ package at.hannibal2.skyhanni.features.garden.contest import at.hannibal2.skyhanni.data.ClickType import at.hannibal2.skyhanni.events.CropClickEvent import at.hannibal2.skyhanni.events.FarmingContestEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent +import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.NumberUtil.roundTo +import at.hannibal2.skyhanni.utils.NumberUtil.prettyRound +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.TimeUtils import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.seconds +import kotlin.time.DurationUnit @SkyHanniModule object JacobContestStatsSummary { - private val config get() = GardenAPI.config + private val config get() = GardenAPI.config.jacobContestStats private var blocksBroken = 0 - private var startTime = SimpleTimeMark.farPast() + private var startTimeIrl = SimpleTimeMark.farPast() + private var startTimeRelative: Long? = null + private var startScore: Long? = null + private var predictedScore: Long? = null + private var percent: Double? = null + private var medalColor = "" + private var contestStats = mutableListOf() + + private val tabContestPattern by RepoPattern.pattern( + "garden.jacob.contest.tab.data", + " §r(§e○|§6☘) §r§f(?.+) §r§f◆ Top §r(?§.)(?(\\d|[.])+)%" + ) + private val scoreboardContestTimeLeftPattern by RepoPattern.pattern( + "garden.jacob.contest.scoreboard.time.left", + " (§e○|§6☘) §f(?.+) §a(?