From 368523b99992687fbef3acb29f915c0b6ada5fd9 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Sat, 23 Sep 2023 20:42:52 +1000 Subject: guh (#495) internal sidebar changes #495 --- .../at/hannibal2/skyhanni/data/ScoreboardData.kt | 3 +++ .../skyhanni/test/command/CopyScoreboardCommand.kt | 26 ++++++++++---------- .../skyhanni/test/command/CopyTabListCommand.kt | 28 +++++++++------------- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt index 9aee68957..c476482cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ScoreboardData.kt @@ -27,6 +27,7 @@ class ScoreboardData { "\uD83C\uDF81", "\uD83C\uDF89", "\uD83C\uDF82", + "\uD83D\uDD2B", ) fun formatLines(rawList: List): List { @@ -49,6 +50,7 @@ class ScoreboardData { var sidebarLines: List = emptyList() // TODO rename to raw var sidebarLinesRaw: List = emptyList() // TODO delete + var objectiveLine = "" } @SubscribeEvent(priority = EventPriority.HIGHEST) @@ -76,6 +78,7 @@ class ScoreboardData { private fun fetchScoreboardLines(): List { val scoreboard = Minecraft.getMinecraft().theWorld?.scoreboard ?: return emptyList() val objective = scoreboard.getObjectiveInDisplaySlot(1) ?: return emptyList() + objectiveLine = objective.displayName var scores = scoreboard.getSortedScores(objective) val list = scores.filter { input: Score? -> input != null && input.playerName != null && !input.playerName.startsWith("#") diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyScoreboardCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyScoreboardCommand.kt index b53b2af19..0483001f8 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyScoreboardCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyScoreboardCommand.kt @@ -7,19 +7,19 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor object CopyScoreboardCommand { fun command(args: Array) { - try { - val resultList = mutableListOf() - val noColor = args.size == 1 && args[0] == "true" - for (line in ScoreboardData.sidebarLinesFormatted) { - val scoreboardLine = if (noColor) line.removeColor() else line - resultList.add("'$scoreboardLine'") - } - val string = resultList.joinToString("\n") - OSUtils.copyToClipboard(string) - LorenzUtils.chat("§e[SkyHanni] scoreboard copied into the clipboard!") - } - catch (_: Throwable) { - LorenzUtils.chat("§c[SkyHanni] Nothing in scoreboard") + val resultList = mutableListOf() + val noColor = args.size == 1 && args[0] == "true" + resultList.add("Header:") + resultList.add(if (noColor) ScoreboardData.objectiveLine.removeColor() else ScoreboardData.objectiveLine) + resultList.add("") + + for (line in ScoreboardData.sidebarLinesFormatted) { + val scoreboardLine = if (noColor) line.removeColor() else line + resultList.add("'$scoreboardLine'") } + + val string = resultList.joinToString("\n") + OSUtils.copyToClipboard(string) + LorenzUtils.chat("§e[BedWar] scoreboard copied into your clipboard!") } } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt index c5c94b8a2..d308ba09e 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyTabListCommand.kt @@ -9,23 +9,17 @@ import net.minecraft.client.Minecraft object CopyTabListCommand { fun command(args: Array) { - try { - val resultList = mutableListOf() - val noColor = args.size == 1 && args[0] == "true" - for (line in TabListData.getTabList()) { - val tabListLine = if (noColor) line.removeColor() else line - if (tabListLine != "") resultList.add("'$tabListLine'") - } - val tabList = Minecraft.getMinecraft().ingameGUI.tabList as AccessorGuiPlayerTabOverlay - val tabHeader = tabList.header_skyhanni.formattedText - val tabFooter = tabList.footer_skyhanni.formattedText - val string = "Header:\n\n$tabHeader\n\nBody:\n\n${resultList.joinToString("\n")}\nFooter:\n\n$tabFooter" - OSUtils.copyToClipboard(string) - LorenzUtils.chat("§e[SkyHanni] Tab list copied into the clipboard!") - } - catch (_: Throwable) { - // TODO: Note: why are we ignoring this exception? This user facing error message seems out of place to me - LorenzUtils.chat("§c[SkyHanni] Nothing in tab list") + val resultList = mutableListOf() + val noColor = args.size == 1 && args[0] == "true" + for (line in TabListData.getTabList()) { + val tabListLine = if (noColor) line.removeColor() else line + if (tabListLine != "") resultList.add("'$tabListLine'") } + val tabList = Minecraft.getMinecraft().ingameGUI.tabList as AccessorGuiPlayerTabOverlay + val tabHeader = if (noColor) tabList.header_skyhanni.unformattedText else tabList.header_skyhanni.formattedText + val tabFooter = if (noColor) tabList.footer_skyhanni.unformattedText else tabList.footer_skyhanni.formattedText + val string = "Header:\n\n$tabHeader\n\nBody:\n\n${resultList.joinToString("\n")}\n\nFooter:\n\n$tabFooter" + OSUtils.copyToClipboard(string) + LorenzUtils.chat("§e[SkyHanni] Tab list copied into the clipboard!") } } \ No newline at end of file -- cgit