diff options
author | Linnea Gräf <nea@nea.moe> | 2024-04-02 16:01:38 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-04-02 16:01:38 +0200 |
commit | 3e0198e3a803d2dd46988ba0ac445412c7da8390 (patch) | |
tree | 6f08cebe11894769ead7ce7473b27dbdf21523d5 /src/main/kotlin/moe/nea/ledger/ScoreboardUtil.kt | |
parent | 8d26a206297071775e88b99d4b38efcc5577af0a (diff) | |
download | money-ledger-3e0198e3a803d2dd46988ba0ac445412c7da8390.tar.gz money-ledger-3e0198e3a803d2dd46988ba0ac445412c7da8390.tar.bz2 money-ledger-3e0198e3a803d2dd46988ba0ac445412c7da8390.zip |
Add bits stuff
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/ScoreboardUtil.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/ScoreboardUtil.kt | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/ScoreboardUtil.kt b/src/main/kotlin/moe/nea/ledger/ScoreboardUtil.kt new file mode 100644 index 0000000..783664b --- /dev/null +++ b/src/main/kotlin/moe/nea/ledger/ScoreboardUtil.kt @@ -0,0 +1,29 @@ +package moe.nea.ledger + +import net.minecraft.client.Minecraft +import net.minecraft.scoreboard.ScorePlayerTeam + +object ScoreboardUtil { + + val sidebarSlot = 1 + fun getScoreboardStrings(): List<String> { + val scoreboard = Minecraft.getMinecraft().theWorld.scoreboard + val objective = scoreboard.getObjectiveInDisplaySlot(sidebarSlot) + val scoreList = scoreboard.getSortedScores(objective).take(15) + .map { + ScorePlayerTeam.formatPlayerName(scoreboard.getPlayersTeam(it.playerName), it.playerName) + } + .map { stripAlien(it) } + .reversed() + return scoreList + } + + fun stripAlien(string: String): String { + val sb = StringBuilder() + for (c in string) { + if (Minecraft.getMinecraft().fontRendererObj.getCharWidth(c) > 0 || c == '§') + sb.append(c) + } + return sb.toString() + } +}
\ No newline at end of file |