forked from SteamWar/SteamWar
Remove Component Messages
This commit is contained in:
@@ -19,55 +19,49 @@
|
||||
|
||||
package de.steamwar.tntleague.util
|
||||
|
||||
import de.steamwar.kotlin.message.*
|
||||
import de.steamwar.scoreboard.ScoreboardCallback
|
||||
import de.steamwar.tntleague.colorByTeam
|
||||
import de.steamwar.tntleague.config.targetedBlocks
|
||||
import de.steamwar.tntleague.game.TNTLeagueGame
|
||||
import de.steamwar.tntleague.game.TNTLeagueTeam
|
||||
import de.steamwar.tntleague.message
|
||||
import de.steamwar.tntleague.tntLeaguePrefix
|
||||
import net.kyori.adventure.text.Component
|
||||
import org.bukkit.entity.Player
|
||||
import kotlin.collections.HashMap
|
||||
|
||||
private val scoreboardTitle by lazy { tntLeaguePrefix.toLegacy() }
|
||||
|
||||
data class TNTLeagueScoreboard(val p: Player): ScoreboardCallback {
|
||||
override fun getData(): HashMap<String, Int> {
|
||||
val lines = mutableListOf<Component>()
|
||||
val lines = mutableListOf<String>()
|
||||
|
||||
lines.add(Component.space().green())
|
||||
lines.add("§1")
|
||||
|
||||
val minutes = TNTLeagueGame.gameTimeRemaining.floorDiv(60)
|
||||
val seconds = TNTLeagueGame.gameTimeRemaining.rem(60).toString().padStart(2, '0')
|
||||
lines.add(translate("scoreboardTime", minutes.toString().yellow(), seconds.yellow()).gray())
|
||||
lines.add(message.parse("scoreboardTime", p, minutes, seconds))
|
||||
|
||||
lines.add(Component.space().yellow())
|
||||
lines.add("§2")
|
||||
|
||||
when (val team = TNTLeagueGame.getTeam(p)) {
|
||||
is TNTLeagueTeam -> lines.add(translate("scoreboardCoins", team.coins.toString().yellow()).gray())
|
||||
else -> lines.add(
|
||||
translate("scoreboardCoins",
|
||||
Component.text(TNTLeagueGame.blueTeam.coins.toString()).colorByTeam(TNTLeagueGame.blueTeam)
|
||||
.append(Component.text("/").darkGray())
|
||||
.append(Component.text(TNTLeagueGame.redTeam.coins.toString()).colorByTeam(TNTLeagueGame.redTeam))
|
||||
).gray())
|
||||
is TNTLeagueTeam -> lines.add(message.parse("scoreboardCoins", p, team.coins))
|
||||
else -> lines.add(message.parse("scoreboardCoins", p,
|
||||
"§${TNTLeagueGame.blueTeam.color}${TNTLeagueGame.blueTeam.coins}§8:§${TNTLeagueGame.redTeam.color}${TNTLeagueGame.redTeam.coins}"))
|
||||
}
|
||||
|
||||
lines.add(Component.space().red())
|
||||
lines.add("§3")
|
||||
|
||||
with(TNTLeagueGame.redTeam) {
|
||||
lines.add(translate("scoreboardTeam", translate(name).colorByTeam(this), (targetedBlocks - damagedBlocks).toString().yellow()).gray())
|
||||
lines.add(message.parse("scoreboardTeam", p, message.parse(name, p).colorByTeam(this), targetedBlocks - damagedBlocks))
|
||||
}
|
||||
with(TNTLeagueGame.blueTeam) {
|
||||
lines.add(translate("scoreboardTeam", translate(name).colorByTeam(this), (targetedBlocks - damagedBlocks).toString().yellow()).gray())
|
||||
lines.add(message.parse("scoreboardTeam", p, message.parse(name, p).colorByTeam(this), targetedBlocks - damagedBlocks))
|
||||
}
|
||||
|
||||
lines.add(Component.space().gray())
|
||||
lines.add("§4")
|
||||
|
||||
return lines
|
||||
.foldIndexed(HashMap()) { index, acc, component -> acc.also { it[component.translate(p).toLegacy()] = index } }
|
||||
.foldIndexed(HashMap()) { index, acc, component -> acc.also { it[component] = index } }
|
||||
}
|
||||
|
||||
override fun getTitle(): String = scoreboardTitle
|
||||
override fun getTitle(): String = message.parse("PREFIX", p)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user