forked from SteamWar/SteamWar
Remove Component Messages
This commit is contained in:
@@ -19,10 +19,7 @@
|
||||
|
||||
package de.steamwar.tntleague
|
||||
|
||||
import de.steamwar.kotlin.message.ComponentMessage
|
||||
import de.steamwar.kotlin.message.StyleConfig
|
||||
import de.steamwar.kotlin.message.darkGray
|
||||
import de.steamwar.kotlin.message.gray
|
||||
import de.steamwar.message.Message
|
||||
import de.steamwar.tntleague.command.AcceptCommand
|
||||
import de.steamwar.tntleague.command.InviteCommand
|
||||
import de.steamwar.tntleague.command.LeaveCommand
|
||||
@@ -30,17 +27,12 @@ import de.steamwar.tntleague.command.RemoveCommand
|
||||
import de.steamwar.tntleague.events.GlobalListener
|
||||
import de.steamwar.tntleague.events.LobbyListener
|
||||
import de.steamwar.tntleague.game.TNTLeagueTeam
|
||||
import net.kyori.adventure.key.Key
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.format.NamedTextColor
|
||||
import net.kyori.adventure.translation.GlobalTranslator
|
||||
import net.kyori.adventure.translation.TranslationRegistry
|
||||
import net.kyori.adventure.util.UTF8ResourceBundleControl
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
import java.util.*
|
||||
|
||||
lateinit var plugin: TNTLeague
|
||||
lateinit var message: ComponentMessage
|
||||
lateinit var message: Message
|
||||
|
||||
val tntLeaguePrefix = Component.text("TNT").color(NamedTextColor.DARK_RED)
|
||||
.append(Component.text("League").color(NamedTextColor.GOLD))
|
||||
@@ -48,15 +40,13 @@ val tntLeaguePrefix = Component.text("TNT").color(NamedTextColor.DARK_RED)
|
||||
class TNTLeague : JavaPlugin() {
|
||||
init {
|
||||
plugin = this
|
||||
|
||||
StyleConfig.prefix = tntLeaguePrefix
|
||||
}
|
||||
|
||||
override fun onEnable() {
|
||||
saveResource("config.yml", false)
|
||||
saveDefaultConfig()
|
||||
|
||||
message = ComponentMessage("de.steamwar.tntleague.TNTLeague", classLoader)
|
||||
message = Message("de.steamwar.tntleague.TNTLeague", classLoader)
|
||||
|
||||
server.pluginManager.registerEvents(LobbyListener, this)
|
||||
server.pluginManager.registerEvents(GlobalListener, this)
|
||||
@@ -70,7 +60,7 @@ class TNTLeague : JavaPlugin() {
|
||||
}
|
||||
}
|
||||
|
||||
fun Component.colorByTeam(team: TNTLeagueTeam?) = when (team) {
|
||||
null -> this.gray()
|
||||
else -> this.color(team.color)
|
||||
fun String.colorByTeam(team: TNTLeagueTeam?) = when (team) {
|
||||
null -> "§7${this}"
|
||||
else -> "§${team.color}${this}"
|
||||
}
|
||||
|
||||
@@ -17,37 +17,32 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
join={0} joined the game!
|
||||
joinTeam={0} joined the {1} team!
|
||||
quit={0} left the game!
|
||||
quitTeam={0} left the {1} team!
|
||||
PREFIX=§4TNT§6League§8»
|
||||
join=§e{0} §ajoined the game!
|
||||
joinTeam={0} §7joined the {1} §7team!
|
||||
quit={0} §cleft the game!
|
||||
quitTeam={0} §7left the {1} §7team!
|
||||
blue=Blue
|
||||
red=Red
|
||||
shutdown=The server stops in {0} seconds!
|
||||
teamWin=Team {0} wins!
|
||||
|
||||
notEnoughCoins=You don't have enough coins to buy this item!
|
||||
|
||||
gameStarting=The game starts in {0} seconds!
|
||||
gameStart=Starting in {0}
|
||||
gameStarted=The game has started!
|
||||
|
||||
timeRemaining={0} minutes remaining!
|
||||
|
||||
gameEnded=The game has ended!
|
||||
draw=The game ended in a draw!
|
||||
shutdown=§cThe server stops in §e{0} §cseconds!
|
||||
teamWin=§aTeam {0} §awins!
|
||||
notEnoughCoins=§cYou don't have enough coins to buy this item!
|
||||
gameStarting=§aThe game starts in §e{0} §aseconds!
|
||||
gameStart=
|
||||
gameStarted=§aThe game has started!
|
||||
timeRemaining=§e{0} §7minutes remaining!
|
||||
gameEnded=§cThe game has ended!
|
||||
draw=§cThe game ended in a draw!
|
||||
dealer=Shopkeeper
|
||||
dealerItem={0} {1}
|
||||
|
||||
scoreboardTime=Time: {0}:{1}
|
||||
scoreboardCoins=Coins: {0}
|
||||
scoreboardTeam=Team {0}: {1}
|
||||
|
||||
ready=Ready
|
||||
notReady=Not ready
|
||||
isReady=Team {0} is ready!
|
||||
isNotReady=Team {0} is not ready!
|
||||
|
||||
invited={0} invited you to join the {1} team! *Click*
|
||||
invitedHover=Click to join the {0} team!
|
||||
invitedPlayer=Invited {0} to join your team!
|
||||
dealerPrice=
|
||||
scoreboardTime=§7Time: §e{0}§8:§e{1}
|
||||
scoreboardCoins=§7Coins: §e{0}
|
||||
scoreboardTeam=§7Team {0}§8: §e{1}
|
||||
ready=§aReady
|
||||
notReady=§cNot ready
|
||||
isReady=§aTeam {0} §ais ready!
|
||||
isNotReady=§cTeam {0} §cis not ready!
|
||||
invited={0} §ainvited you to join the {1} §ateam! §e*Click*
|
||||
invitedHover=§7Click to join the {0} §7team!
|
||||
invitedPlayer=§aInvited §e{0} §ato join your team!
|
||||
@@ -17,30 +17,29 @@
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
join={0} ist dem Spiel beigetreten!
|
||||
joinTeam={0} ist dem {1} team begetreten!
|
||||
quit={0} hat das Spiel verlassen!
|
||||
quitTeam={0} hat das {1} team verlassen!
|
||||
join=§e{0} §aist dem Spiel beigetreten!
|
||||
joinTeam={0} §7ist dem {1} §7team begetreten!
|
||||
quit={0} §chat das Spiel verlassen!
|
||||
quitTeam={0} §7hat Team {1} §7verlassen!
|
||||
blue=Blau
|
||||
red=Rot
|
||||
shutdown=Der Server fährt in {0} sekunden herunter!
|
||||
teamWin=Team {0} gewinnt!
|
||||
notEnoughCoins=Du hast nicht genug Coins um dir das zu kaufen!
|
||||
gameStarting=Das Spiel beginnt in {0} Sekunden!
|
||||
gameStart=Start in {0}
|
||||
gameStarted=Das Spiel beginnt!
|
||||
timeRemaining=noch {0} Minuten!
|
||||
gameEnded=Das Spiel ist vorbei!
|
||||
draw=Keiner hat gewonnen!
|
||||
shutdown=§cDer Server fährt in §e{0} §csekunden herunter!
|
||||
teamWin=§aTeam {0} §agewinnt!
|
||||
notEnoughCoins=§cDu hast nicht genug Coins um dir das zu kaufen!
|
||||
gameStarting=§aDas Spiel beginnt in §e{0} §aSekunden!
|
||||
gameStarted=§aDas Spiel beginnt!
|
||||
timeRemaining=§7noch §e{0} §7Minuten!
|
||||
gameEnded=§cDas Spiel ist vorbei!
|
||||
draw=§cKeiner hat gewonnen!
|
||||
dealer=Händler
|
||||
dealerPrice=Kosten: {0} Coins
|
||||
dealerPrice=§7Kosten: §e{0} Coins
|
||||
|
||||
scoreboardTarget=Ziel: {0}
|
||||
scoreboardTime=Zeit: {0}:{1}
|
||||
ready=Bereit
|
||||
notReady=Nicht bereit
|
||||
isReady=Team {0} ist bereit!
|
||||
isNotReady=Team {0} ist nicht bereit!
|
||||
invited={0} hat dich in team {1} eingeladen! *Klick*
|
||||
invitedHover=Team {0} beitreten!
|
||||
invitedPlayer={0} wurde eingeladen!
|
||||
scoreboardTarget=§7Ziel: {0}
|
||||
scoreboardTime=§7Zeit: §e{0}§8:§e{1}
|
||||
ready=§aBereit
|
||||
notReady=§cNicht bereit
|
||||
isReady=§aTeam {0} §aist bereit!
|
||||
isNotReady=§cTeam {0} §cist nicht bereit!
|
||||
invited={0} §ahat dich in team {1} §aeingeladen! §e*Klick*
|
||||
invitedHover=§7Team {0} §7beitreten!
|
||||
invitedPlayer={0} §awurde eingeladen!
|
||||
@@ -21,11 +21,10 @@ package de.steamwar.tntleague.command
|
||||
|
||||
import de.steamwar.command.SWCommand
|
||||
import de.steamwar.command.TypeValidator
|
||||
import de.steamwar.kotlin.message.*
|
||||
import de.steamwar.tntleague.colorByTeam
|
||||
import de.steamwar.tntleague.game.TNTLeagueGame
|
||||
import net.kyori.adventure.text.event.ClickEvent
|
||||
import net.kyori.adventure.text.event.HoverEvent
|
||||
import de.steamwar.tntleague.message
|
||||
import net.md_5.bungee.api.chat.ClickEvent
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
object InviteCommand: SWCommand("invite") {
|
||||
@@ -38,17 +37,11 @@ object InviteCommand: SWCommand("invite") {
|
||||
val team = TNTLeagueGame.getTeam(sender)!!
|
||||
team.invites.add(target)
|
||||
|
||||
target.sendMessage(
|
||||
translate("invited", sender.name.yellow(), translate(team.name).colorByTeam(team)).basic().clickEvent(
|
||||
ClickEvent.callback {
|
||||
if (target !in team.invites) return@callback
|
||||
message
|
||||
.send("invited", target, message.parse("invitedHover", target, team.name.colorByTeam(team)),
|
||||
ClickEvent(ClickEvent.Action.RUN_COMMAND, "/accept "), sender.name, team.name.colorByTeam(team), )
|
||||
|
||||
team.invites.remove(target)
|
||||
team.opposite.invites.remove(target)
|
||||
team.join(target)
|
||||
})
|
||||
.hoverEvent(HoverEvent.showText(translate("invitedHover", translate(team.name).colorByTeam(team)).green())))
|
||||
sender.sendMessage(translate("invitedPlayer", target.name.yellow()).basic())
|
||||
message.send("invitedPlayer", sender, target.name)
|
||||
}
|
||||
|
||||
@Validator("isLeader", local = false)
|
||||
|
||||
@@ -21,7 +21,7 @@ package de.steamwar.tntleague.config
|
||||
|
||||
import de.steamwar.tntleague.plugin
|
||||
import de.steamwar.kotlin.util.Area
|
||||
import de.steamwar.kotlin.message.translate
|
||||
import net.kyori.adventure.text.Component
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.configuration.ConfigurationSection
|
||||
@@ -80,7 +80,7 @@ object TNTLeagueWorldConfig {
|
||||
|
||||
private fun spawnDealer(loc: Location) = world.spawn(loc, WanderingTrader::class.java)
|
||||
.apply {
|
||||
customName(translate("dealer"))
|
||||
customName(Component.text("Shop"))
|
||||
isCustomNameVisible = false
|
||||
isInvulnerable = true
|
||||
isSilent = true
|
||||
|
||||
@@ -19,15 +19,12 @@
|
||||
|
||||
package de.steamwar.tntleague.events
|
||||
|
||||
import de.steamwar.kotlin.message.basic
|
||||
import de.steamwar.kotlin.message.bold
|
||||
import de.steamwar.kotlin.message.translate
|
||||
import de.steamwar.tntleague.colorByTeam
|
||||
import de.steamwar.tntleague.config.TNTLeagueWorldConfig
|
||||
import de.steamwar.tntleague.game.TNTLeagueGame
|
||||
import de.steamwar.tntleague.game.TNTLeagueTeam
|
||||
import de.steamwar.kotlin.inventory.SWInventoryHolder
|
||||
import de.steamwar.tntleague.plugin
|
||||
import de.steamwar.tntleague.message
|
||||
import org.bukkit.GameMode
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.event.EventHandler
|
||||
@@ -48,7 +45,7 @@ object GlobalListener: Listener {
|
||||
with(e.player) {
|
||||
teleport(TNTLeagueWorldConfig.lobby)
|
||||
inventory.clear()
|
||||
plugin.server.broadcast(translate("join", name.bold()).basic())
|
||||
message.broadcast("join", name)
|
||||
isOp = false
|
||||
gameMode = GameMode.SPECTATOR
|
||||
respawnLocation = TNTLeagueWorldConfig.lobby
|
||||
@@ -58,7 +55,7 @@ object GlobalListener: Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
fun onPlayerQuit(e: PlayerQuitEvent) {
|
||||
e.quitMessage(null)
|
||||
plugin.server.broadcast(translate("quit", e.player.name.bold().colorByTeam(TNTLeagueGame.getTeam(e.player))).basic())
|
||||
message.broadcast("quit", e.player.name.colorByTeam(TNTLeagueGame.getTeam(e.player)))
|
||||
TNTLeagueGame.playerLeave(e.player)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
|
||||
package de.steamwar.tntleague.game
|
||||
|
||||
import de.steamwar.kotlin.message.*
|
||||
import de.steamwar.kotlin.util.Area
|
||||
import de.steamwar.scoreboard.SWScoreboard
|
||||
import de.steamwar.sql.Fight
|
||||
import de.steamwar.sql.FightPlayer
|
||||
import de.steamwar.sql.SteamwarUser
|
||||
import de.steamwar.tntleague.colorByTeam
|
||||
import de.steamwar.tntleague.config.TNTLeagueConfig
|
||||
import de.steamwar.tntleague.config.TNTLeagueWorldConfig
|
||||
import de.steamwar.tntleague.config.world
|
||||
@@ -32,6 +32,7 @@ import de.steamwar.tntleague.events.DummyListener
|
||||
import de.steamwar.tntleague.events.IngameListener
|
||||
import de.steamwar.tntleague.events.LobbyListener
|
||||
import de.steamwar.tntleague.inventory.DealerInventory
|
||||
import de.steamwar.tntleague.message
|
||||
import de.steamwar.tntleague.plugin
|
||||
import de.steamwar.tntleague.util.*
|
||||
import net.kyori.adventure.bossbar.BossBar
|
||||
@@ -80,7 +81,7 @@ object TNTLeagueGame {
|
||||
blueTeam.start()
|
||||
redTeam.start()
|
||||
|
||||
plugin.server.broadcast(translate("gameStarted").success())
|
||||
message.broadcast("gameStarted")
|
||||
|
||||
val tnt = ItemStack(Material.TNT)
|
||||
|
||||
@@ -105,7 +106,7 @@ object TNTLeagueGame {
|
||||
}
|
||||
|
||||
if (gameTimeRemaining % 300 == 0) {
|
||||
plugin.server.broadcast(translate("timeRemaining", (gameTimeRemaining / 60).toString().yellow()).basic())
|
||||
message.broadcast("timeRemaining", (gameTimeRemaining / 60))
|
||||
plugin.server.onlinePlayers.forEach { it.playSound(Sound.sound(org.bukkit.Sound.BLOCK_NOTE_BLOCK_PLING.key, Sound.Source.MASTER, 1f, 1f)) }
|
||||
}
|
||||
}, 20, 20)
|
||||
@@ -123,7 +124,7 @@ object TNTLeagueGame {
|
||||
it.playSound(Sound.sound(org.bukkit.Sound.ENTITY_ENDER_DRAGON_DEATH.key, Sound.Source.MASTER, 1f, 1f))
|
||||
}
|
||||
|
||||
plugin.server.broadcast(translate("gameEnded").success())
|
||||
message.broadcast("gameEnded")
|
||||
|
||||
spawnerTask.cancel()
|
||||
|
||||
@@ -134,7 +135,7 @@ object TNTLeagueGame {
|
||||
plugin.server.shutdown()
|
||||
}
|
||||
|
||||
plugin.server.broadcast(translate("shutdown", shutdown.toString().yellow()).basic())
|
||||
message.broadcast("shutdown", shutdown)
|
||||
|
||||
shutdown--
|
||||
}, 20, 20)
|
||||
@@ -153,19 +154,15 @@ object TNTLeagueGame {
|
||||
state = GameState.STARTING
|
||||
|
||||
var countdown = TNTLeagueConfig.config.startDelay
|
||||
plugin.server.broadcast(translate("gameStarting", countdown.toString().yellow()).basic())
|
||||
val bar = BossBar.bossBar(translate("gameStart", countdown.toString().yellow()).gray(), (TNTLeagueConfig.config.startDelay - countdown) / TNTLeagueConfig.config.startDelay.toFloat(), BossBar.Color.GREEN, BossBar.Overlay.NOTCHED_10)
|
||||
plugin.server.onlinePlayers.forEach { bar.addViewer(it) }
|
||||
message.broadcast("gameStarting", countdown.toString())
|
||||
task = plugin.server.scheduler.scheduleSyncRepeatingTask(plugin, {
|
||||
plugin.server.onlinePlayers.forEach { it.playSound(Sound.sound(org.bukkit.Sound.ENTITY_EXPERIENCE_ORB_PICKUP.key, Sound.Source.MASTER, 1f, 1f)) }
|
||||
if (countdown-- == 0) {
|
||||
plugin.server.onlinePlayers.forEach { it.hideBossBar(bar) }
|
||||
if (--countdown == 0) {
|
||||
plugin.server.onlinePlayers.forEach { it.level = 0 }
|
||||
task = task?.also { plugin.server.scheduler.cancelTask(it) }.let { null }
|
||||
setup()
|
||||
} else {
|
||||
bar.name(translate("gameStart", countdown.toString().yellow()).gray())
|
||||
bar.progress((TNTLeagueConfig.config.startDelay - countdown) / TNTLeagueConfig.config.startDelay.toFloat())
|
||||
plugin.server.onlinePlayers.filter { !it.activeBossBars().contains(bar) }.forEach { bar.addViewer(it) }
|
||||
plugin.server.onlinePlayers.forEach { it.level = countdown }
|
||||
}
|
||||
}, 20, 20)
|
||||
|
||||
@@ -191,7 +188,6 @@ object TNTLeagueGame {
|
||||
|
||||
if (state == GameState.STARTING) {
|
||||
task = task?.also { plugin.server.scheduler.cancelTask(it) }.let { null }
|
||||
plugin.server.onlinePlayers.forEach { p -> p.activeBossBars().forEach { it.removeViewer(p) } }
|
||||
state = GameState.LOBBY
|
||||
}
|
||||
}
|
||||
@@ -199,7 +195,7 @@ object TNTLeagueGame {
|
||||
fun win(tntLeagueTeam: TNTLeagueTeam, reason: WinReason) {
|
||||
if (state != GameState.RUNNING) return
|
||||
end()
|
||||
plugin.server.broadcast(translate("teamWin", translate(tntLeagueTeam.name).color(tntLeagueTeam.color)).success())
|
||||
plugin.server.onlinePlayers.forEach { message.send("teamWin", it, message.parse(tntLeagueTeam.name, it).colorByTeam(tntLeagueTeam)) }
|
||||
statistic(tntLeagueTeam, reason)
|
||||
explode(tntLeagueTeam.opposite)
|
||||
}
|
||||
@@ -207,7 +203,7 @@ object TNTLeagueGame {
|
||||
fun draw(reason: WinReason) {
|
||||
if (state != GameState.RUNNING) return
|
||||
end()
|
||||
plugin.server.broadcast(translate("draw").success())
|
||||
message.broadcast("draw")
|
||||
statistic(null, reason)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,14 +19,13 @@
|
||||
|
||||
package de.steamwar.tntleague.game
|
||||
|
||||
import de.steamwar.kotlin.message.*
|
||||
import de.steamwar.tntleague.colorByTeam
|
||||
import de.steamwar.tntleague.config.TNTLeagueWorldConfig
|
||||
import de.steamwar.tntleague.config.targetedBlocks
|
||||
import de.steamwar.tntleague.message
|
||||
import de.steamwar.tntleague.plugin
|
||||
import net.kyori.adventure.sound.Sound
|
||||
import net.kyori.adventure.text.format.NamedTextColor
|
||||
import net.kyori.adventure.text.format.TextColor
|
||||
import net.kyori.adventure.text.Component
|
||||
import org.bukkit.GameMode
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.enchantments.Enchantment
|
||||
@@ -52,7 +51,7 @@ data class TNTLeagueTeam(val config: TNTLeagueWorldConfig.TeamConfig, private va
|
||||
val name: String
|
||||
get() = team.name.lowercase()
|
||||
|
||||
val color: TextColor
|
||||
val color: Char
|
||||
get() = team.color
|
||||
|
||||
var isReady: Boolean = false
|
||||
@@ -61,13 +60,7 @@ data class TNTLeagueTeam(val config: TNTLeagueWorldConfig.TeamConfig, private va
|
||||
leader?.inventory?.setItem(4, readyItem())
|
||||
leader?.playSound(Sound.sound(org.bukkit.Sound.BLOCK_NOTE_BLOCK_PLING.key, Sound.Source.MASTER, 1f, 1f))
|
||||
|
||||
plugin.server.onlinePlayers.forEach { it.sendActionBar(translate(if (value) "isReady" else "isNotReady", translate(this.name).colorByTeam(this)).let { cmp ->
|
||||
if (value) {
|
||||
cmp.green()
|
||||
} else {
|
||||
cmp.red()
|
||||
}
|
||||
}) }
|
||||
message.broadcastActionbar(if (value) "isReady" else "isNotReady", name.colorByTeam(this))
|
||||
|
||||
if (value && opposite.isReady) {
|
||||
TNTLeagueGame.checkStart()
|
||||
@@ -97,7 +90,7 @@ data class TNTLeagueTeam(val config: TNTLeagueWorldConfig.TeamConfig, private va
|
||||
teleport(config.spawnLocation)
|
||||
gameMode = GameMode.ADVENTURE
|
||||
inventory.clear()
|
||||
plugin.server.broadcast(translate("joinTeam", name().colorByTeam(this@TNTLeagueTeam), translate(this@TNTLeagueTeam.name).colorByTeam(this@TNTLeagueTeam)).basic())
|
||||
message.broadcast("joinTeam", name.colorByTeam(this@TNTLeagueTeam), this@TNTLeagueTeam.name.colorByTeam(this@TNTLeagueTeam))
|
||||
}
|
||||
|
||||
if (leader == null) {
|
||||
@@ -110,13 +103,13 @@ data class TNTLeagueTeam(val config: TNTLeagueWorldConfig.TeamConfig, private va
|
||||
fun readyItem() = if (isReady) {
|
||||
ItemStack.of(Material.LIME_DYE).apply {
|
||||
itemMeta = itemMeta.apply {
|
||||
displayName(translate("ready").green().translate(leader!!))
|
||||
displayName(Component.text(message.parse("ready", leader!!)))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ItemStack.of(Material.RED_DYE).apply {
|
||||
itemMeta = itemMeta.apply {
|
||||
displayName(translate("notReady").red().translate(leader!!))
|
||||
displayName(Component.text(message.parse("notReady", leader!!)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,12 +151,12 @@ data class TNTLeagueTeam(val config: TNTLeagueWorldConfig.TeamConfig, private va
|
||||
teleport(TNTLeagueWorldConfig.lobby)
|
||||
gameMode = GameMode.SPECTATOR
|
||||
inventory.clear()
|
||||
plugin.server.broadcast(translate("quitTeam", name().colorByTeam(this@TNTLeagueTeam), translate(this@TNTLeagueTeam.name).colorByTeam(this@TNTLeagueTeam)).basic())
|
||||
message.broadcast("quitTeam", name.colorByTeam(this@TNTLeagueTeam), this@TNTLeagueTeam.name.colorByTeam(this@TNTLeagueTeam))
|
||||
}
|
||||
}
|
||||
|
||||
enum class Team(val color: TextColor) {
|
||||
BLUE(NamedTextColor.BLUE),
|
||||
RED(NamedTextColor.RED);
|
||||
enum class Team(val color: Char) {
|
||||
BLUE('9'),
|
||||
RED('c');
|
||||
}
|
||||
}
|
||||
@@ -20,12 +20,14 @@
|
||||
package de.steamwar.tntleague.inventory
|
||||
|
||||
import de.steamwar.kotlin.inventory.SWInventoryHolder
|
||||
import de.steamwar.kotlin.message.*
|
||||
import de.steamwar.tntleague.config.TNTLeagueConfig
|
||||
import de.steamwar.tntleague.game.TNTLeagueGame
|
||||
import de.steamwar.tntleague.message
|
||||
import de.steamwar.tntleague.plugin
|
||||
import net.kyori.adventure.sound.Sound
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.format.NamedTextColor
|
||||
import net.kyori.adventure.text.format.TextDecoration
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.NamespacedKey
|
||||
import org.bukkit.entity.Player
|
||||
@@ -35,7 +37,7 @@ import org.bukkit.persistence.PersistentDataType
|
||||
import java.util.*
|
||||
import kotlin.math.ceil
|
||||
|
||||
class DealerInventory(player: Player): SWInventoryHolder() {
|
||||
class DealerInventory(val player: Player): SWInventoryHolder() {
|
||||
|
||||
init {
|
||||
items.forEachIndexed { index, item ->
|
||||
@@ -46,7 +48,7 @@ class DealerInventory(player: Player): SWInventoryHolder() {
|
||||
val team = TNTLeagueGame.getTeam(player) ?: return@to
|
||||
|
||||
if (team.coins < price) {
|
||||
player.sendMessage(translate("notEnoughCoins").error())
|
||||
message.send("notEnoughCoins", player)
|
||||
player.playSound(Sound.sound(org.bukkit.Sound.ENTITY_VILLAGER_HURT.key, net.kyori.adventure.sound.Sound.Source.MASTER, 1f, 1f))
|
||||
return@to
|
||||
}
|
||||
@@ -57,7 +59,7 @@ class DealerInventory(player: Player): SWInventoryHolder() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun createInventory(): Inventory = plugin.server.createInventory(this, ceil(TNTLeagueConfig.config.prices.size / 9f).toInt() * 9, translate("dealer").reset())
|
||||
override fun createInventory(): Inventory = plugin.server.createInventory(this, ceil(TNTLeagueConfig.config.prices.size / 9f).toInt() * 9, Component.text(message.parse("dealer", player)))
|
||||
|
||||
companion object {
|
||||
private val priceKey = NamespacedKey(plugin, "price")
|
||||
@@ -66,7 +68,7 @@ class DealerInventory(player: Player): SWInventoryHolder() {
|
||||
|
||||
val coins = ItemStack(Material.RAW_GOLD).apply {
|
||||
itemMeta = itemMeta.apply {
|
||||
displayName(Component.text("Coins").bold().gold())
|
||||
displayName(Component.text("Coins").color(NamedTextColor.GOLD))
|
||||
persistentDataContainer.apply {
|
||||
set(coinKey, PersistentDataType.BOOLEAN, true)
|
||||
}
|
||||
@@ -79,11 +81,13 @@ class DealerInventory(player: Player): SWInventoryHolder() {
|
||||
prices.map { (material, price) ->
|
||||
ItemStack(material).apply {
|
||||
itemMeta = itemMeta.apply {
|
||||
displayName(material.name.lowercase().replace("_", " ")
|
||||
.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
|
||||
.component().gray().appendSpace().append(price.amount.toString().component().yellow()))
|
||||
displayName(Component.text(material.name.lowercase().replace("_", " ")
|
||||
.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() })
|
||||
.color(NamedTextColor.GRAY).appendSpace().append(Component.text(price.amount).color(NamedTextColor.YELLOW)))
|
||||
|
||||
|
||||
amount = price.amount
|
||||
lore(listOf(price.price.toString().component().yellow().bold().appendSpace().append(Component.text("Coins").yellow())))
|
||||
lore(listOf(Component.text(price.price).color(NamedTextColor.YELLOW).decorate(TextDecoration.BOLD).appendSpace().append(Component.text("Coins").color(NamedTextColor.YELLOW))))
|
||||
persistentDataContainer.apply {
|
||||
set(priceKey, PersistentDataType.INTEGER, price.price)
|
||||
set(amountKey, PersistentDataType.INTEGER, price.amount)
|
||||
|
||||
@@ -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