diff --git a/KotlinCore/src/de/steamwar/kotlin/KotlinCore.kt b/KotlinCore/src/de/steamwar/kotlin/KotlinCore.kt
index 89aa1b34..1c4bc406 100644
--- a/KotlinCore/src/de/steamwar/kotlin/KotlinCore.kt
+++ b/KotlinCore/src/de/steamwar/kotlin/KotlinCore.kt
@@ -19,7 +19,6 @@
package de.steamwar.kotlin
-import de.steamwar.kotlin.message.LanguageListener
import org.bukkit.plugin.java.JavaPlugin
class KotlinCore : JavaPlugin() {
@@ -33,7 +32,7 @@ class KotlinCore : JavaPlugin() {
}
override fun onEnable() {
- server.pluginManager.registerEvents(LanguageListener, this)
+
}
override fun onDisable() {
diff --git a/KotlinCore/src/de/steamwar/kotlin/message/ComponentMessage.kt b/KotlinCore/src/de/steamwar/kotlin/message/ComponentMessage.kt
deleted file mode 100644
index 12ba5f0a..00000000
--- a/KotlinCore/src/de/steamwar/kotlin/message/ComponentMessage.kt
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * This file is a part of the SteamWar software.
- *
- * Copyright (C) 2024 SteamWar.de-Serverteam
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package de.steamwar.kotlin.message
-
-import net.kyori.adventure.key.Key
-import net.kyori.adventure.translation.GlobalTranslator
-import net.kyori.adventure.translation.Translator
-import java.text.MessageFormat
-import java.util.*
-
-class ComponentMessage(private val resourceBundleName: String, private val classLoader: ClassLoader) : Translator {
- init {
- GlobalTranslator.translator().addSource(this)
- }
-
- override fun name(): Key = Key.key("steamwar", resourceBundleName)
-
- override fun translate(key: String, locale: Locale) =
- ResourceBundle.getBundle(resourceBundleName, locale, classLoader).let {
- if (it.containsKey(key)) {
- MessageFormat(it.getString(key), locale)
- } else {
- null
- }
- }
-}
diff --git a/KotlinCore/src/de/steamwar/kotlin/message/LanguageListener.kt b/KotlinCore/src/de/steamwar/kotlin/message/LanguageListener.kt
deleted file mode 100644
index 918248f0..00000000
--- a/KotlinCore/src/de/steamwar/kotlin/message/LanguageListener.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is a part of the SteamWar software.
- *
- * Copyright (C) 2024 SteamWar.de-Serverteam
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package de.steamwar.kotlin.message
-
-import com.comphenix.tinyprotocol.Reflection
-import de.steamwar.kotlin.KotlinCore
-import de.steamwar.sql.SteamwarUser
-import org.bukkit.Bukkit
-import org.bukkit.entity.Player
-import org.bukkit.event.EventHandler
-import org.bukkit.event.EventPriority
-import org.bukkit.event.Listener
-import org.bukkit.event.player.PlayerJoinEvent
-import org.bukkit.event.player.PlayerLocaleChangeEvent
-import java.util.Locale
-
-object LanguageListener: Listener {
-
- private val getHandleMethod = Reflection.getMethod("{obc}.entity.CraftPlayer", "getHandle")
- private val localeField = Reflection.getField("{nms.server.level}.EntityPlayer", "adventure\$locale", Locale::class.java)
-
- private val Player.handle
- get() = getHandleMethod.invoke(this)
-
- private var Player.adventureLocale
- get() = localeField.get(handle) as Locale
- set(value) {
- localeField.set(handle, value)
- }
-
- @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
- fun onPlayerJoin(event: PlayerJoinEvent) {
- event.player.adventureLocale = SteamwarUser.get(event.player.uniqueId).locale
- }
-
- @EventHandler
- fun onPlayerConfig(event: PlayerLocaleChangeEvent) {
- Bukkit.getScheduler().runTask(KotlinCore.plugin, Runnable {
- event.player.adventureLocale = SteamwarUser.get(event.player.uniqueId).locale
- })
- }
-}
\ No newline at end of file
diff --git a/KotlinCore/src/de/steamwar/kotlin/message/Style.kt b/KotlinCore/src/de/steamwar/kotlin/message/Style.kt
deleted file mode 100644
index 79603241..00000000
--- a/KotlinCore/src/de/steamwar/kotlin/message/Style.kt
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This file is a part of the SteamWar software.
- *
- * Copyright (C) 2024 SteamWar.de-Serverteam
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package de.steamwar.kotlin.message
-
-import net.kyori.adventure.text.Component
-import net.kyori.adventure.text.ComponentLike
-import net.kyori.adventure.text.TranslatableComponent
-import net.kyori.adventure.text.format.NamedTextColor
-import net.kyori.adventure.text.format.Style
-import net.kyori.adventure.text.format.TextDecoration
-import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
-import net.kyori.adventure.translation.GlobalTranslator
-import org.bukkit.entity.Player
-import java.util.Locale
-
-object StyleConfig {
- var prefix = Component.text("Steam").yellow()
- .append(Component.text("War").darkGray())
- .appendSpace()
- set(value) {
- field = value
- chatPrefix = value
- .append(Component.text("»").darkGray())
- .appendSpace()
- }
- var chatPrefix = prefix
- .append(Component.text("»").darkGray())
- .appendSpace()
-}
-
-fun TranslatableComponent.basic(): Component = StyleConfig.chatPrefix.append(this.gray())
-
-fun TranslatableComponent.error(): Component = StyleConfig.chatPrefix.append(this.red())
-
-fun TranslatableComponent.success(): Component = StyleConfig.chatPrefix.append(this.green())
-
-fun String.component(): Component = Component.text(this)
-
-fun Component.bold(): Component = this.decorate(TextDecoration.BOLD)
-
-fun String.bold(): Component = this.component().bold()
-
-fun Component.yellow(): Component = this.color(NamedTextColor.YELLOW)
-
-fun String.yellow(): Component = this.component().yellow()
-
-fun Component.red(): Component = this.color(NamedTextColor.RED)
-
-fun String.red(): Component = this.component().red()
-
-fun Component.green(): Component = this.color(NamedTextColor.GREEN)
-
-fun String.green(): Component = this.component().green()
-
-fun Component.gray(): Component = this.color(NamedTextColor.GRAY)
-
-fun String.gray(): Component = this.component().gray()
-
-fun Component.darkGray(): Component = this.color(NamedTextColor.DARK_GRAY)
-
-fun String.darkGray(): Component = this.component().darkGray()
-
-fun Component.gold(): Component = this.color(NamedTextColor.GOLD)
-
-fun translate(key: String, vararg args: ComponentLike): TranslatableComponent = Component.translatable(key, *args).decoration(TextDecoration.ITALIC, false)
-
-fun Component.reset(): Component = this.style(Style.empty())
-
-fun Component.translate(locale: Locale): Component = GlobalTranslator.render(this, locale)
-
-fun Component.translate(p: Player): Component = this.translate(p.locale())
-
-fun Component.toLegacy(): String = LegacyComponentSerializer.legacySection().serialize(this)
-
-fun Component.space(): Component = append(Component.space())
diff --git a/TNTLeague/src/de/steamwar/tntleague/TNTLeague.kt b/TNTLeague/src/de/steamwar/tntleague/TNTLeague.kt
index 50572805..dd1c0327 100644
--- a/TNTLeague/src/de/steamwar/tntleague/TNTLeague.kt
+++ b/TNTLeague/src/de/steamwar/tntleague/TNTLeague.kt
@@ -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}"
}
diff --git a/TNTLeague/src/de/steamwar/tntleague/TNTLeague.properties b/TNTLeague/src/de/steamwar/tntleague/TNTLeague.properties
index 46d8dd35..3e44dcba 100644
--- a/TNTLeague/src/de/steamwar/tntleague/TNTLeague.properties
+++ b/TNTLeague/src/de/steamwar/tntleague/TNTLeague.properties
@@ -17,37 +17,32 @@
# along with this program. If not, see .
#
-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!
\ No newline at end of file
+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!
\ No newline at end of file
diff --git a/TNTLeague/src/de/steamwar/tntleague/TNTLeague_de.properties b/TNTLeague/src/de/steamwar/tntleague/TNTLeague_de.properties
index 21e48240..17577e40 100644
--- a/TNTLeague/src/de/steamwar/tntleague/TNTLeague_de.properties
+++ b/TNTLeague/src/de/steamwar/tntleague/TNTLeague_de.properties
@@ -17,30 +17,29 @@
# along with this program. If not, see .
#
-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!
\ No newline at end of file
+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!
\ No newline at end of file
diff --git a/TNTLeague/src/de/steamwar/tntleague/command/InviteCommand.kt b/TNTLeague/src/de/steamwar/tntleague/command/InviteCommand.kt
index b33806c7..0a8d628c 100644
--- a/TNTLeague/src/de/steamwar/tntleague/command/InviteCommand.kt
+++ b/TNTLeague/src/de/steamwar/tntleague/command/InviteCommand.kt
@@ -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)
diff --git a/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueWorldConfig.kt b/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueWorldConfig.kt
index ae863071..44405103 100644
--- a/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueWorldConfig.kt
+++ b/TNTLeague/src/de/steamwar/tntleague/config/TNTLeagueWorldConfig.kt
@@ -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
diff --git a/TNTLeague/src/de/steamwar/tntleague/events/GlobalListener.kt b/TNTLeague/src/de/steamwar/tntleague/events/GlobalListener.kt
index 23cf69f4..00af6e79 100644
--- a/TNTLeague/src/de/steamwar/tntleague/events/GlobalListener.kt
+++ b/TNTLeague/src/de/steamwar/tntleague/events/GlobalListener.kt
@@ -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)
}
diff --git a/TNTLeague/src/de/steamwar/tntleague/game/TNTLeagueGame.kt b/TNTLeague/src/de/steamwar/tntleague/game/TNTLeagueGame.kt
index 2a83b9ec..3a6ac9c5 100644
--- a/TNTLeague/src/de/steamwar/tntleague/game/TNTLeagueGame.kt
+++ b/TNTLeague/src/de/steamwar/tntleague/game/TNTLeagueGame.kt
@@ -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)
}
diff --git a/TNTLeague/src/de/steamwar/tntleague/game/TNTLeagueTeam.kt b/TNTLeague/src/de/steamwar/tntleague/game/TNTLeagueTeam.kt
index f13ec602..4bd5e98f 100644
--- a/TNTLeague/src/de/steamwar/tntleague/game/TNTLeagueTeam.kt
+++ b/TNTLeague/src/de/steamwar/tntleague/game/TNTLeagueTeam.kt
@@ -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');
}
}
\ No newline at end of file
diff --git a/TNTLeague/src/de/steamwar/tntleague/inventory/DealerInventory.kt b/TNTLeague/src/de/steamwar/tntleague/inventory/DealerInventory.kt
index 4d098510..2aec75e4 100644
--- a/TNTLeague/src/de/steamwar/tntleague/inventory/DealerInventory.kt
+++ b/TNTLeague/src/de/steamwar/tntleague/inventory/DealerInventory.kt
@@ -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)
diff --git a/TNTLeague/src/de/steamwar/tntleague/util/TNTLeagueScoreboard.kt b/TNTLeague/src/de/steamwar/tntleague/util/TNTLeagueScoreboard.kt
index 31245584..61a6bd9b 100644
--- a/TNTLeague/src/de/steamwar/tntleague/util/TNTLeagueScoreboard.kt
+++ b/TNTLeague/src/de/steamwar/tntleague/util/TNTLeagueScoreboard.kt
@@ -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 {
- val lines = mutableListOf()
+ val lines = mutableListOf()
- 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)
}