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