aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-03-14 21:30:11 +0100
committerGitHub <noreply@github.com>2024-03-14 21:30:11 +0100
commit3375bdeca7e47924616c976b23d017c7f52dc071 (patch)
treee64db3da1e751d9a2fcf977abe09ade2fff7113f /src/main/java/at/hannibal2/skyhanni
parenta556cf5d81eadc41faf37e0b56426d5dc796b651 (diff)
downloadskyhanni-3375bdeca7e47924616c976b23d017c7f52dc071.tar.gz
skyhanni-3375bdeca7e47924616c976b23d017c7f52dc071.tar.bz2
skyhanni-3375bdeca7e47924616c976b23d017c7f52dc071.zip
Improvement + Fix: Custom Scoreboard Fixed and Additions Part 2 (#1174)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/BackgroundConfig.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/DisplayConfig.java18
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt29
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt10
7 files changed, 41 insertions, 38 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/BackgroundConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/BackgroundConfig.java
index 3b4924511..966912d6a 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/BackgroundConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/gui/customscoreboard/BackgroundConfig.java
@@ -22,7 +22,7 @@ public class BackgroundConfig {
desc = "The color of the background."
)
@ConfigEditorColour
- public String color = "0:102:0:0:0";
+ public String color = "0:80:0:0:0";
@Expose
@ConfigOption(
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 874399cfd..e960c5703 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
@@ -5,6 +5,7 @@ import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.annotations.Accordion;
import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider;
import io.github.moulberry.moulconfig.annotations.ConfigOption;
public class DisplayConfig {
@@ -32,12 +33,6 @@ public class DisplayConfig {
public boolean showAllActiveEvents = false;
@Expose
- @ConfigOption(name = "Cache Scoreboard on Island Switch",
- desc = "Will stop the Scoreboard from updating while switching islands.\nRemoves the shaking when loading data.")
- @ConfigEditorBoolean
- public boolean cacheScoreboardOnIslandSwitch = false;
-
- @Expose
@ConfigOption(name = "Number Format", desc = "")
@ConfigEditorDropdown
public NumberFormat numberFormat = NumberFormat.LONG;
@@ -86,6 +81,17 @@ public class DisplayConfig {
public boolean colorArrowAmount = false;
@Expose
+ @ConfigOption(name = "Line Spacing", desc = "The amount of space between each line.")
+ @ConfigEditorSlider(minValue = 0, maxValue = 20, minStep = 1)
+ public int lineSpacing = 10;
+
+ @Expose
+ @ConfigOption(name = "Cache Scoreboard on Island Switch",
+ desc = "Will stop the Scoreboard from updating while switching islands.\nRemoves the shaking when loading data.")
+ @ConfigEditorBoolean
+ public boolean cacheScoreboardOnIslandSwitch = false;
+
+ @Expose
@ConfigOption(name = "Alignment Options", desc = "")
@Accordion
public AlignmentConfig alignment = new AlignmentConfig();
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
index c347fcdba..9617d4e37 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt
@@ -248,6 +248,7 @@ class HypixelData {
if (inSkyBlock) {
checkIsland()
checkSidebar()
+ getCurrentServerId()
}
if (inSkyBlock == skyBlock) return
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 96e501d7c..e260976e0 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
@@ -53,7 +53,7 @@ class CustomScoreboard {
} else {
display
}
- config.position.renderStringsAlignedWidth(render, posLabel = guiName)
+ config.position.renderStringsAlignedWidth(render, posLabel = guiName, extraSpace = displayConfig.lineSpacing - 10)
}
@SubscribeEvent
@@ -74,7 +74,7 @@ class CustomScoreboard {
// Creating the lines
if (event.isMod(5)) {
- display = createLines()
+ display = createLines().removeEmptyLinesFromEdges()
if (TabListData.fullyLoaded) {
cache = display.toList()
}
@@ -92,8 +92,7 @@ class CustomScoreboard {
}
private fun createLines() = buildList<ScoreboardElementType> {
- val configEntries = removeEmptyLinesFromEdges(config.scoreboardEntries)
- for (element in configEntries) {
+ for (element in config.scoreboardEntries) {
val line = element.getVisiblePair()
// Hide consecutive empty lines
@@ -119,13 +118,13 @@ class CustomScoreboard {
}
}
- private fun removeEmptyLinesFromEdges(entries: MutableList<ScoreboardElement>): List<ScoreboardElement> {
+ private fun List<ScoreboardElementType>.removeEmptyLinesFromEdges(): List<ScoreboardElementType> {
if (config.informationFilteringConfig.hideEmptyLinesAtTopAndBottom) {
- return entries
- .dropWhile { it.getVisiblePair().all { it.first == "<empty>" } }
- .dropLastWhile { it.getVisiblePair().all { it.first == "<empty>" } }
+ return this
+ .dropWhile { it.first.isEmpty() }
+ .dropLastWhile { it.first.isEmpty() }
}
- return entries
+ return this
}
// Thank you Apec for showing that the ElementType of the stupid scoreboard is FUCKING HELMET WTF
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 abd5a04f1..15ce71ed9 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
@@ -18,7 +18,6 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Comp
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.informationFilteringConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.formatNum
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getGroupFromPattern
-import at.hannibal2.skyhanni.mixins.hooks.tryToReplaceScoreboardLine
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter
import at.hannibal2.skyhanni.utils.LorenzUtils.inAdvancedMiningIsland
@@ -389,15 +388,11 @@ private fun getIslandDisplayPair() =
private fun getLocationDisplayPair() = buildList {
add(
- (tryToReplaceScoreboardLine(
- getGroupFromPattern(
- ScoreboardData.sidebarLinesFormatted,
- ScoreboardPattern.locationPattern,
- "location"
- )
- )?.trim()
- ?: "<hidden>") to HorizontalAlignment.LEFT
- )
+ getGroupFromPattern(
+ ScoreboardData.sidebarLinesFormatted,
+ ScoreboardPattern.locationPattern,
+ "location"
+ ).trim() to HorizontalAlignment.LEFT)
val plotLine = ScoreboardData.sidebarLinesFormatted.firstOrNull { ScoreboardPattern.plotPattern.matches(it) }
if (plotLine != null) add(plotLine to HorizontalAlignment.LEFT)
@@ -427,14 +422,14 @@ private fun getTimeDisplayPair(): List<ScoreboardElementType> {
}
private fun getLobbyDisplayPair(): List<ScoreboardElementType> {
- val lobbyCode = getGroupFromPattern(
- ScoreboardData.sidebarLinesFormatted,
- ScoreboardPattern.lobbyCodePattern,
- "code"
+ val lobbyCode = HypixelData.serverId ?: "<hidden>"
+ return listOf(
+ if (lobbyCode == "<hidden>") {
+ "<hidden>"
+ } else {
+ "§8$lobbyCode"
+ } to HorizontalAlignment.LEFT
)
-
- val displayValue = if (lobbyCode == "0") "<hidden>" else "§8$lobbyCode"
- return listOf(displayValue to HorizontalAlignment.LEFT)
}
private fun getPowerDisplayPair() = listOf(
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt
index 62d633523..e5b1a9686 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardPattern.kt
@@ -79,7 +79,7 @@ object ScoreboardPattern {
)
val instanceShutdownPattern by multiUseSb.pattern(
"instanceshutdown",
- "(§.)*Instance Shutdown: (§.)*(?<time>(\\w+[ydhms] ?)+)$"
+ "(§.)*Instance Shutdown In: (§.)*(?<time>(\\w+[ydhms] ?)+)$"
)
val timeLeftPattern by multiUseSb.pattern(
"timeleft",
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt
index 5fe788983..7fdac515a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/UnknownLinesHandler.kt
@@ -53,7 +53,7 @@ object UnknownLinesHandler {
SbPattern.peltsPattern,
SbPattern.mobLocationPattern,
SbPattern.jacobsContestPattern,
- SbPattern.plotPattern,
+ SbPattern.plotPattern,
SbPattern.powderPattern,
SbPattern.windCompassPattern,
SbPattern.windCompassArrowPattern,
@@ -149,8 +149,10 @@ object UnknownLinesHandler {
}
// da
- unknownLines = unknownLines.filter { sidebarLines.nextAfter(sidebarLines.firstOrNull { line ->
- SbPattern.darkAuctionCurrentItemPattern.matches(line)
- } ?: "Current Item:") != it }
+ unknownLines = unknownLines.filter {
+ sidebarLines.nextAfter(sidebarLines.firstOrNull { line ->
+ SbPattern.darkAuctionCurrentItemPattern.matches(line)
+ } ?: "Current Item:") != it
+ }
}
}