aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-06-22 11:00:32 +0200
committerGitHub <noreply@github.com>2024-06-22 11:00:32 +0200
commit426ea5e879aee0a6d0e7d27416d816cb5f8eb692 (patch)
tree6632f36ec1ff2592b2fae8770f974279174914c7 /src/main/java/at
parentfcc31674e40ed044f46813c2185f8de29d974932 (diff)
downloadskyhanni-426ea5e879aee0a6d0e7d27416d816cb5f8eb692.tar.gz
skyhanni-426ea5e879aee0a6d0e7d27416d816cb5f8eb692.tar.bz2
skyhanni-426ea5e879aee0a6d0e7d27416d816cb5f8eb692.zip
Feature: Added Chunked Stats to Custom Scoreboard (#1341)
Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/ChunkedStatsConfig.java32
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStat.kt81
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt27
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt54
6 files changed, 177 insertions, 29 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/ChunkedStatsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/ChunkedStatsConfig.java
new file mode 100644
index 000000000..4293dd168
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/ChunkedStatsConfig.java
@@ -0,0 +1,32 @@
+package at.hannibal2.skyhanni.config.features.gui.customscoreboard;
+
+import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStat;
+import com.google.gson.annotations.Expose;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
+import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ChunkedStatsConfig {
+
+ @Expose
+ @ConfigOption(
+ name = "Chunked Stats",
+ desc = "Select the stats you want to display chunked on the scoreboard."
+ )
+ @ConfigEditorDraggableList
+ public List<ChunkedStat> chunkedStats = new ArrayList<>(ChunkedStat.getEntries());
+
+ @Expose
+ @ConfigOption(
+ name = "Max Stats per Line",
+ desc = "The maximum amount of stats that will be displayed in one line."
+ )
+ @ConfigEditorSlider(
+ minValue = 1,
+ maxValue = 10,
+ minStep = 1)
+ public int maxStatsPerLine = 3;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java
index 2700a19b8..c9e330b33 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java
@@ -22,6 +22,11 @@ public class DisplayConfig {
public ArrowConfig arrow = new ArrowConfig();
@Expose
+ @ConfigOption(name = "Chunked Stats Options", desc = "")
+ @Accordion
+ public ChunkedStatsConfig chunkedStats = new ChunkedStatsConfig();
+
+ @Expose
@ConfigOption(name = "Events Options", desc = "")
@Accordion
public EventsConfig events = new EventsConfig();
@@ -78,7 +83,7 @@ public class DisplayConfig {
public enum PowderDisplay {
AVAILABLE("Available"),
TOTAL("Total"),
- BOTH("Available / All")
+ BOTH("Available / All"),
;
private final String str;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStat.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStat.kt
new file mode 100644
index 000000000..4acfcb81d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ChunkedStat.kt
@@ -0,0 +1,81 @@
+package at.hannibal2.skyhanni.features.gui.customscoreboard
+
+import at.hannibal2.skyhanni.data.MiningAPI
+import at.hannibal2.skyhanni.data.PurseAPI
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.chunkedConfig
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.informationFilteringConfig
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.formatNum
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getBank
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getBits
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getBitsLine
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getBitsToClaim
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getCopper
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getGems
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getHeat
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getMotes
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getNorthStars
+
+private val hideEmptyLines get() = informationFilteringConfig.hideEmptyLines
+
+enum class ChunkedStat(
+ private val displayPair: () -> String,
+ val showWhen: () -> Boolean,
+ private val configLine: String,
+) {
+ PURSE(
+ displayPair = { "§6${PurseAPI.currentPurse.formatNum()}" },
+ showWhen = { !(hideEmptyLines && PurseAPI.currentPurse.toInt() == 0) && ScoreboardElement.PURSE.showWhen() },
+ configLine = "§6Purse",
+ ),
+ MOTES(
+ displayPair = { "§b${getMotes()}" },
+ showWhen = { !(hideEmptyLines && getMotes() == "0") && ScoreboardElement.MOTES.showWhen() },
+ configLine = "§dMotes",
+ ),
+ BANK(
+ displayPair = { "§6${getBank()}" },
+ showWhen = { !(hideEmptyLines && (getBank() == "0" || getBank() == "0§7 / §60")) && ScoreboardElement.BANK.showWhen() },
+ configLine = "§6Bank",
+ ),
+ BITS(
+ displayPair = { getBitsLine() },
+ showWhen = { !(hideEmptyLines && getBits() == "0" && getBitsToClaim() == "0") && ScoreboardElement.BITS.showWhen() },
+ configLine = "§bBits",
+ ),
+ COPPER(
+ displayPair = { "§c${getCopper()}" },
+ showWhen = { !(hideEmptyLines && getCopper() == "0") && ScoreboardElement.COPPER.showWhen() },
+ configLine = "§cCopper",
+ ),
+ GEMS(
+ displayPair = { "§a${getGems()}" },
+ showWhen = { !(hideEmptyLines && getGems() == "0") && ScoreboardElement.GEMS.showWhen() },
+ configLine = "§aGems",
+ ),
+ HEAT(
+ displayPair = { "§c${getHeat()}" },
+ showWhen = { !(hideEmptyLines && getHeat() == "§c♨ 0") && ScoreboardElement.HEAT.showWhen() },
+ configLine = "§cHeat",
+ ),
+ COLD(
+ displayPair = { "§b${MiningAPI.cold}❄" },
+ showWhen = { !(hideEmptyLines && MiningAPI.cold == 0) && ScoreboardElement.COLD.showWhen() },
+ configLine = "§bCold",
+ ),
+ NORTH_STARS(
+ displayPair = { "§d${getNorthStars()}" },
+ showWhen = { !(hideEmptyLines && getNorthStars() == "0") && ScoreboardElement.NORTH_STARS.showWhen() },
+ configLine = "§dNorth Stars",
+ ),
+ ;
+
+ override fun toString() = configLine
+
+ companion object {
+ fun getChunkedStats() = chunkedConfig.chunkedStats.mapNotNull {
+ it.takeIf { it.showWhen() }?.displayPair?.invoke()
+ }
+
+ fun shouldShowChunkedStats() = chunkedConfig.chunkedStats.any { it.showWhen() }
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt
index a4d5bd628..df8adab37 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt
@@ -29,7 +29,7 @@ import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.ChatUtils
-import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle
+import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.DelayedRun.runDelayed
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment
@@ -108,6 +108,7 @@ object CustomScoreboard {
internal val displayConfig get() = config.display
internal val alignmentConfig get() = displayConfig.alignment
internal val arrowConfig get() = displayConfig.arrow
+ internal val chunkedConfig get() = displayConfig.chunkedStats
internal val eventsConfig get() = displayConfig.events
internal val mayorConfig get() = displayConfig.mayor
internal val partyConfig get() = displayConfig.party
@@ -170,7 +171,7 @@ object CustomScoreboard {
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
- onToggle(config.enabled, displayConfig.hideVanillaScoreboard) {
+ ConditionalUtils.onToggle(config.enabled, displayConfig.hideVanillaScoreboard) {
if (!isHideVanillaScoreboardEnabled()) dirty = true
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt
index 6c7f6fa82..d1eaf2abd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.gui.customscoreboard
import at.hannibal2.skyhanni.config.features.gui.customscoreboard.DisplayConfig
+import at.hannibal2.skyhanni.data.BitsAPI
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.features.bingo.BingoAPI
@@ -11,6 +12,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeResets
import at.hannibal2.skyhanni.utils.StringUtils.trimWhiteSpace
+import at.hannibal2.skyhanni.utils.TabListData
import java.util.regex.Pattern
object CustomScoreboardUtils {
@@ -42,5 +44,30 @@ object CustomScoreboardUtils {
internal fun String.formatNum() = this.formatDouble().formatNum()
+ internal fun getMotes() = getGroupFromPattern(ScoreboardData.sidebarLinesFormatted, ScoreboardPattern.motesPattern, "motes")
+ internal fun getBank() = getGroupFromPattern(TabListData.getTabList(), ScoreboardPattern.bankPattern, "bank")
+
+ internal fun getBits() = BitsAPI.bits.coerceAtLeast(0).formatNum()
+
+ internal fun getBitsToClaim() = BitsAPI.bitsAvailable.coerceAtLeast(0).formatNum()
+
+ internal fun getBitsLine() = if (displayConfig.showUnclaimedBits) {
+ "§b${getBits()}§7/§b${getBitsToClaim()}"
+ } else {
+ "§b${getBits()}"
+ }
+
+ internal fun getCopper() =
+ getGroupFromPattern(ScoreboardData.sidebarLinesFormatted, ScoreboardPattern.copperPattern, "copper")
+
+ internal fun getGems() = getGroupFromPattern(TabListData.getTabList(), ScoreboardPattern.gemsPattern, "gems")
+
+ internal fun getHeat() =
+ getGroupFromPattern(ScoreboardData.sidebarLinesFormatted, ScoreboardPattern.heatPattern, "heat")
+
+ internal fun getNorthStars() =
+ getGroupFromPattern(ScoreboardData.sidebarLinesFormatted, ScoreboardPattern.northstarsPattern, "northstars")
+
+
class UndetectedScoreboardLines(message: String) : Exception(message)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt
index ab3584251..1a435a269 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt
@@ -19,7 +19,10 @@ import at.hannibal2.skyhanni.data.QuiverAPI.asArrowPercentage
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.data.SlayerAPI
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
+import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStat.Companion.getChunkedStats
+import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStat.Companion.shouldShowChunkedStats
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.arrowConfig
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.chunkedConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.config
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.displayConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.informationFilteringConfig
@@ -27,7 +30,14 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.maxw
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.mayorConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.partyConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.formatNum
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getBank
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getBitsLine
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getCopper
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getGems
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getGroupFromPattern
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getHeat
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getMotes
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getNorthStars
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy
import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter
@@ -42,7 +52,6 @@ import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment
import at.hannibal2.skyhanni.utils.SkyBlockTime
import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.StringUtils.pluralize
-import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.TimeLimitedSet
import at.hannibal2.skyhanni.utils.TimeUtils.format
import at.hannibal2.skyhanni.utils.TimeUtils.formatted
@@ -133,6 +142,11 @@ enum class ScoreboardElement(
::getNorthStarsShowWhen,
"North Stars: §d756",
),
+ CHUNKED_STATS(
+ ::getChunkedStatsDisplayPair,
+ ::shouldShowChunkedStats,
+ "§652,763,737 §7| §d64,647 §7| §6249M\n§b59,264 §7| §c23,495 §7| §a57,873\n§c♨ 0 §7| §b0❄ §7| §d756",
+ ),
EMPTY_LINE(
::getEmptyLineDisplayPair,
{ true }, "",
@@ -371,8 +385,7 @@ private fun getPurseDisplayPair(): List<ScoreboardElementType> {
private fun getPurseShowWhen() = !inAnyIsland(IslandType.THE_RIFT)
private fun getMotesDisplayPair(): List<ScoreboardElementType> {
- val motes = getGroupFromPattern(ScoreboardData.sidebarLinesFormatted, ScoreboardPattern.motesPattern, "motes")
- .formatNum()
+ val motes = getMotes().formatNum()
return listOf(
when {
@@ -386,7 +399,7 @@ private fun getMotesDisplayPair(): List<ScoreboardElementType> {
private fun getMotesShowWhen() = inAnyIsland(IslandType.THE_RIFT)
private fun getBankDisplayPair(): List<ScoreboardElementType> {
- val bank = getGroupFromPattern(TabListData.getTabList(), ScoreboardPattern.bankPattern, "bank")
+ val bank = getBank()
return listOf(
when {
@@ -410,21 +423,8 @@ private fun getBitsDisplayPair(): List<ScoreboardElementType> {
return listOf(
when {
informationFilteringConfig.hideEmptyLines && bits == "0" && bitsToClaim == "0" -> "<hidden>"
- displayConfig.displayNumbersFirst -> {
- if (displayConfig.showUnclaimedBits) {
- "§b$bits§7/${if (bitsToClaim == "0") "§30" else "§b${bitsToClaim}"} §bBits"
- } else {
- "§b$bits Bits"
- }
- }
-
- else -> {
- if (displayConfig.showUnclaimedBits) {
- "Bits: §b$bits§7/${if (bitsToClaim == "0") "§30" else "§b${bitsToClaim}"}"
- } else {
- "Bits: §b$bits"
- }
- }
+ displayConfig.displayNumbersFirst -> "${getBitsLine()} Bits"
+ else -> "Bits: ${getBitsLine()}"
} to HorizontalAlignment.LEFT,
)
}
@@ -432,8 +432,7 @@ private fun getBitsDisplayPair(): List<ScoreboardElementType> {
private fun getBitsShowWhen() = !HypixelData.bingo && !inAnyIsland(IslandType.CATACOMBS, IslandType.KUUDRA_ARENA)
private fun getCopperDisplayPair(): List<ScoreboardElementType> {
- val copper = getGroupFromPattern(ScoreboardData.sidebarLinesFormatted, ScoreboardPattern.copperPattern, "copper")
- .formatNum()
+ val copper = getCopper().formatNum()
return listOf(
when {
@@ -447,7 +446,7 @@ private fun getCopperDisplayPair(): List<ScoreboardElementType> {
private fun getCopperShowWhen() = inAnyIsland(IslandType.GARDEN)
private fun getGemsDisplayPair(): List<ScoreboardElementType> {
- val gems = getGroupFromPattern(TabListData.getTabList(), ScoreboardPattern.gemsPattern, "gems")
+ val gems = getGems()
return listOf(
when {
@@ -461,7 +460,7 @@ private fun getGemsDisplayPair(): List<ScoreboardElementType> {
private fun getGemsShowWhen() = !inAnyIsland(IslandType.THE_RIFT, IslandType.CATACOMBS, IslandType.KUUDRA_ARENA)
private fun getHeatDisplayPair(): List<ScoreboardElementType> {
- val heat = getGroupFromPattern(ScoreboardData.sidebarLinesFormatted, ScoreboardPattern.heatPattern, "heat")
+ val heat = getHeat()
return listOf(
when {
@@ -491,9 +490,7 @@ private fun getColdShowWhen() = inAnyIsland(IslandType.DWARVEN_MINES, IslandType
&& ScoreboardData.sidebarLinesFormatted.any { ScoreboardPattern.coldPattern.matches(it) }
private fun getNorthStarsDisplayPair(): List<ScoreboardElementType> {
- val northStars =
- getGroupFromPattern(ScoreboardData.sidebarLinesFormatted, ScoreboardPattern.northstarsPattern, "northstars")
- .formatNum()
+ val northStars = getNorthStars().formatNum()
return listOf(
when {
@@ -506,6 +503,11 @@ private fun getNorthStarsDisplayPair(): List<ScoreboardElementType> {
private fun getNorthStarsShowWhen() = inAnyIsland(IslandType.WINTER)
+private fun getChunkedStatsDisplayPair(): List<ScoreboardElementType> =
+ getChunkedStats()
+ .chunked(chunkedConfig.maxStatsPerLine)
+ .map { it.joinToString(" §f| ") to HorizontalAlignment.LEFT }
+
private fun getEmptyLineDisplayPair() = listOf("<empty>" to HorizontalAlignment.LEFT)
private fun getIslandDisplayPair() =