blob: 783664b8b4674fa3aa417828e9a9167ef9da2684 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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()
}
}
|