forked from SteamWar/SteamWar
Make TNTLeague Event System Capable
This commit is contained in:
@@ -72,9 +72,12 @@ public class Message {
|
|||||||
pattern += fromRB(resourceBundle, message);
|
pattern += fromRB(resourceBundle, message);
|
||||||
|
|
||||||
for (int i = 0; i < params.length; i++) {
|
for (int i = 0; i < params.length; i++) {
|
||||||
if (params[i] instanceof SubMessage) {
|
if (params[i] instanceof SubMessage.Translatable) {
|
||||||
SubMessage smsg = (SubMessage) params[i];
|
SubMessage.Translatable smsg = (SubMessage.Translatable) params[i];
|
||||||
params[i] = parse(smsg.getMessage(), sender, smsg.getParams());
|
params[i] = parse(smsg.getMessage(), sender, smsg.getParams());
|
||||||
|
} else if (params[i] instanceof SubMessage.Literal) {
|
||||||
|
SubMessage.Literal smsg = (SubMessage.Literal) params[i];
|
||||||
|
params[i] = smsg.getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,20 +19,33 @@
|
|||||||
|
|
||||||
package de.steamwar.message;
|
package de.steamwar.message;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class SubMessage {
|
@AllArgsConstructor
|
||||||
|
public abstract class SubMessage {
|
||||||
private final String message;
|
private final String message;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class Translatable extends SubMessage {
|
||||||
private final Object[] params;
|
private final Object[] params;
|
||||||
|
|
||||||
public SubMessage(String message, Object... params) {
|
public Translatable(String message, Object... params) {
|
||||||
this.message = message;
|
super(message);
|
||||||
this.params = params;
|
this.params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubMessage(String message) {
|
public Translatable(String message) {
|
||||||
this.message = message;
|
super(message);
|
||||||
this.params = new Object[0];
|
this.params = new Object[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class Literal extends SubMessage {
|
||||||
|
public Literal(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ 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.message.SubMessage
|
|
||||||
import de.steamwar.tntleague.colorByTeam
|
import de.steamwar.tntleague.colorByTeam
|
||||||
|
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.message
|
||||||
import net.md_5.bungee.api.chat.ClickEvent
|
import net.md_5.bungee.api.chat.ClickEvent
|
||||||
@@ -32,6 +32,7 @@ object InviteCommand: SWCommand("invite") {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
fun invitePlayer(@Validator("isLeader") sender: Player, target: Player) {
|
fun invitePlayer(@Validator("isLeader") sender: Player, target: Player) {
|
||||||
|
if (TNTLeagueConfig.isEvent()) return
|
||||||
if (TNTLeagueGame.state != TNTLeagueGame.GameState.LOBBY) return
|
if (TNTLeagueGame.state != TNTLeagueGame.GameState.LOBBY) return
|
||||||
if (TNTLeagueGame.getTeam(target) != null) return
|
if (TNTLeagueGame.getTeam(target) != null) return
|
||||||
|
|
||||||
@@ -39,8 +40,8 @@ object InviteCommand: SWCommand("invite") {
|
|||||||
team.invites.add(target)
|
team.invites.add(target)
|
||||||
|
|
||||||
message
|
message
|
||||||
.send("INVITED", target, message.parse("INVITED_HOVER", target, SubMessage(team.name)),
|
.send("INVITED", target, message.parse("INVITED_HOVER", target, team.name),
|
||||||
ClickEvent(ClickEvent.Action.RUN_COMMAND, "/accept " + sender.name), sender.name.colorByTeam(team), SubMessage(team.name), )
|
ClickEvent(ClickEvent.Action.RUN_COMMAND, "/accept " + sender.name), sender.name.colorByTeam(team), team.name)
|
||||||
|
|
||||||
message.send("INVITED_PLAYER", sender, target.name)
|
message.send("INVITED_PLAYER", sender, target.name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.tntleague.config
|
package de.steamwar.tntleague.config
|
||||||
|
|
||||||
|
import de.steamwar.message.SubMessage
|
||||||
|
import de.steamwar.sql.Event
|
||||||
|
import de.steamwar.sql.EventFight
|
||||||
|
import de.steamwar.sql.Team
|
||||||
import de.steamwar.tntleague.plugin
|
import de.steamwar.tntleague.plugin
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
import org.bukkit.configuration.ConfigurationSection
|
import org.bukkit.configuration.ConfigurationSection
|
||||||
@@ -36,7 +40,34 @@ data class TNTLeagueConfig(
|
|||||||
|
|
||||||
val blueLeader: UUID? = System.getProperty("blueLeader")?.let { UUID.fromString(it) },
|
val blueLeader: UUID? = System.getProperty("blueLeader")?.let { UUID.fromString(it) },
|
||||||
val redLeader: UUID? = System.getProperty("redLeader")?.let { UUID.fromString(it) },
|
val redLeader: UUID? = System.getProperty("redLeader")?.let { UUID.fromString(it) },
|
||||||
|
|
||||||
|
val eventFightId: Int? = System.getProperty("fightID")?.toInt()
|
||||||
) {
|
) {
|
||||||
|
lateinit var eventFight: EventFight
|
||||||
|
lateinit var event: Event
|
||||||
|
lateinit var eventTeamBlue: Team
|
||||||
|
lateinit var eventTeamRed: Team
|
||||||
|
|
||||||
|
val blueTeam: TeamConfig
|
||||||
|
val redTeam: TeamConfig
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (eventFightId != null) {
|
||||||
|
eventFight = EventFight.get(eventFightId) ?: throw IllegalArgumentException("EventFight with ID $eventFightId not found")
|
||||||
|
|
||||||
|
event = Event.get(eventFight.eventID)
|
||||||
|
|
||||||
|
eventTeamBlue = Team.get(eventFight.teamBlue)
|
||||||
|
eventTeamRed = Team.get(eventFight.teamRed)
|
||||||
|
|
||||||
|
blueTeam = TeamConfig(TNTLeagueWorldConfig.blueTeam, SubMessage.Literal("§${eventTeamBlue.teamColor}${eventTeamBlue.teamName}"), eventTeamBlue.teamColor[0])
|
||||||
|
redTeam = TeamConfig(TNTLeagueWorldConfig.redTeam, SubMessage.Literal("§${eventTeamRed.teamColor}${eventTeamRed.teamName}"), eventTeamRed.teamColor[0])
|
||||||
|
} else {
|
||||||
|
blueTeam = TeamConfig(TNTLeagueWorldConfig.blueTeam, SubMessage.Translatable("BLUE"), '3')
|
||||||
|
redTeam = TeamConfig(TNTLeagueWorldConfig.redTeam, SubMessage.Translatable("RED"), 'c')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val config: TNTLeagueConfig by lazy { loadConfig(plugin.config) }
|
val config: TNTLeagueConfig by lazy { loadConfig(plugin.config) }
|
||||||
|
|
||||||
@@ -55,6 +86,8 @@ data class TNTLeagueConfig(
|
|||||||
)
|
)
|
||||||
}.mapKeys { Material.getMaterial(it.key) ?: Material.BARRIER }
|
}.mapKeys { Material.getMaterial(it.key) ?: Material.BARRIER }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isEvent() = config.eventFightId != null
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Price(
|
data class Price(
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ object TNTLeagueWorldConfig {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
lateinit var blueTeam: TeamConfig
|
lateinit var blueTeam: TeamWorldConfig
|
||||||
lateinit var redTeam: TeamConfig
|
lateinit var redTeam: TeamWorldConfig
|
||||||
lateinit var lobby: Location
|
lateinit var lobby: Location
|
||||||
var teamsOnSameLine by Delegates.notNull<Boolean>()
|
var teamsOnSameLine by Delegates.notNull<Boolean>()
|
||||||
lateinit var targetMaterial: Material
|
lateinit var targetMaterial: Material
|
||||||
@@ -64,8 +64,8 @@ object TNTLeagueWorldConfig {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
try {
|
try {
|
||||||
blueTeam = TeamConfig.fromConfig(config.getConfigurationSection("blueTeam")!!)
|
blueTeam = TeamWorldConfig.fromConfig(config.getConfigurationSection("blueTeam")!!)
|
||||||
redTeam = TeamConfig.fromConfig(config.getConfigurationSection("redTeam")!!)
|
redTeam = TeamWorldConfig.fromConfig(config.getConfigurationSection("redTeam")!!)
|
||||||
teamsOnSameLine = abs(blueTeam.spawnLocation.blockX - redTeam.spawnLocation.blockX) < 20
|
teamsOnSameLine = abs(blueTeam.spawnLocation.blockX - redTeam.spawnLocation.blockX) < 20
|
||||||
lobby = config.getWorldLocation("lobby", blueTeam.spawnLocation.clone().add(redTeam.spawnLocation).multiply(0.5))
|
lobby = config.getWorldLocation("lobby", blueTeam.spawnLocation.clone().add(redTeam.spawnLocation).multiply(0.5))
|
||||||
targetMaterial = Material.matchMaterial(config.getString("targetMaterial", "IRON_BLOCK")!!)!!
|
targetMaterial = Material.matchMaterial(config.getString("targetMaterial", "IRON_BLOCK")!!)!!
|
||||||
@@ -76,39 +76,6 @@ object TNTLeagueWorldConfig {
|
|||||||
Bukkit.shutdown()
|
Bukkit.shutdown()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmRecord
|
|
||||||
data class TeamConfig(
|
|
||||||
val spawnLocation: Location,
|
|
||||||
val dealerSpawn: Location,
|
|
||||||
val itemSpawn: Location,
|
|
||||||
val target: Area
|
|
||||||
) {
|
|
||||||
companion object {
|
|
||||||
fun fromConfig(config: ConfigurationSection): TeamConfig {
|
|
||||||
val spawnLocation = config.getWorldLocation("spawn")
|
|
||||||
val dealerSpawn = config.getWorldLocation("dealerSpawn")
|
|
||||||
val itemSpawn = config.getWorldLocation("itemSpawn")
|
|
||||||
val targetPos1 = config.getWorldLocation("targetMin")
|
|
||||||
val targetPos2 = config.getWorldLocation("targetMax")
|
|
||||||
|
|
||||||
spawnDealer(dealerSpawn)
|
|
||||||
|
|
||||||
return TeamConfig(spawnLocation, dealerSpawn, itemSpawn, Area(targetPos1, targetPos2))
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun spawnDealer(loc: Location) = world.spawn(loc, WanderingTrader::class.java)
|
|
||||||
.apply {
|
|
||||||
customName(Component.text("Shop"))
|
|
||||||
isCustomNameVisible = false
|
|
||||||
isInvulnerable = true
|
|
||||||
isSilent = true
|
|
||||||
isCollidable = false
|
|
||||||
isAware = false
|
|
||||||
setAI(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ConfigurationSection.getWorldLocation(s: String, default: Location? = null): Location {
|
fun ConfigurationSection.getWorldLocation(s: String, default: Location? = null): Location {
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2025 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.tntleague.config
|
||||||
|
|
||||||
|
import de.steamwar.kotlin.util.Area
|
||||||
|
import de.steamwar.message.SubMessage
|
||||||
|
import net.kyori.adventure.text.Component
|
||||||
|
import org.bukkit.Location
|
||||||
|
import org.bukkit.configuration.ConfigurationSection
|
||||||
|
import org.bukkit.entity.WanderingTrader
|
||||||
|
|
||||||
|
data class TeamConfig(
|
||||||
|
val worldConfig: TeamWorldConfig,
|
||||||
|
|
||||||
|
val name: SubMessage,
|
||||||
|
val color: Char
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmRecord
|
||||||
|
data class TeamWorldConfig(
|
||||||
|
val spawnLocation: Location,
|
||||||
|
val dealerSpawn: Location,
|
||||||
|
val itemSpawn: Location,
|
||||||
|
val target: Area
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
fun fromConfig(config: ConfigurationSection): TeamWorldConfig {
|
||||||
|
val spawnLocation = config.getWorldLocation("spawn")
|
||||||
|
val dealerSpawn = config.getWorldLocation("dealerSpawn")
|
||||||
|
val itemSpawn = config.getWorldLocation("itemSpawn")
|
||||||
|
val targetPos1 = config.getWorldLocation("targetMin")
|
||||||
|
val targetPos2 = config.getWorldLocation("targetMax")
|
||||||
|
|
||||||
|
spawnDealer(dealerSpawn)
|
||||||
|
|
||||||
|
return TeamWorldConfig(spawnLocation, dealerSpawn, itemSpawn, Area(targetPos1, targetPos2))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun spawnDealer(loc: Location) = world.spawn(loc, WanderingTrader::class.java)
|
||||||
|
.apply {
|
||||||
|
customName(Component.text("Shop"))
|
||||||
|
isCustomNameVisible = false
|
||||||
|
isInvulnerable = true
|
||||||
|
isSilent = true
|
||||||
|
isCollidable = false
|
||||||
|
isAware = false
|
||||||
|
setAI(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -66,7 +66,7 @@ object GlobalListener: Listener {
|
|||||||
fun onPlayerMove(e: PlayerMoveEvent) {
|
fun onPlayerMove(e: PlayerMoveEvent) {
|
||||||
if (e.to.blockY < TNTLeagueWorldConfig.minHeight) {
|
if (e.to.blockY < TNTLeagueWorldConfig.minHeight) {
|
||||||
when (val team = TNTLeagueGame.getTeam(e.player)) {
|
when (val team = TNTLeagueGame.getTeam(e.player)) {
|
||||||
is TNTLeagueTeam -> e.player.teleport(team.config.spawnLocation)
|
is TNTLeagueTeam -> e.player.teleport(team.config.worldConfig.spawnLocation)
|
||||||
null -> e.player.teleport(TNTLeagueWorldConfig.blueTeam.spawnLocation)
|
null -> e.player.teleport(TNTLeagueWorldConfig.blueTeam.spawnLocation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ object GlobalListener: Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
fun onPlayerRespawn(e: PlayerRespawnEvent) {
|
fun onPlayerRespawn(e: PlayerRespawnEvent) {
|
||||||
when (val team = TNTLeagueGame.getTeam(e.player)) {
|
when (val team = TNTLeagueGame.getTeam(e.player)) {
|
||||||
is TNTLeagueTeam -> e.respawnLocation = team.config.spawnLocation
|
is TNTLeagueTeam -> e.respawnLocation = team.config.worldConfig.spawnLocation
|
||||||
null -> e.respawnLocation = TNTLeagueWorldConfig.lobby
|
null -> e.respawnLocation = TNTLeagueWorldConfig.lobby
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ object GlobalListener: Listener {
|
|||||||
|
|
||||||
val fightTeam = TNTLeagueGame.getTeam(player)
|
val fightTeam = TNTLeagueGame.getTeam(player)
|
||||||
if (fightTeam != null) {
|
if (fightTeam != null) {
|
||||||
message.broadcastPrefixless("PARTICIPANT_CHAT", SubMessage(fightTeam.name), player.name, msg)
|
message.broadcastPrefixless("PARTICIPANT_CHAT", fightTeam.name, player.name, msg)
|
||||||
} else {
|
} else {
|
||||||
message.broadcastPrefixless("SPECTATOR_CHAT", player.name, msg)
|
message.broadcastPrefixless("SPECTATOR_CHAT", player.name, msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ object TNTLeagueGame {
|
|||||||
|
|
||||||
var gameTimeRemaining: Int = TNTLeagueConfig.config.gameTime
|
var gameTimeRemaining: Int = TNTLeagueConfig.config.gameTime
|
||||||
|
|
||||||
val blueTeam = TNTLeagueTeam(TNTLeagueWorldConfig.blueTeam, TNTLeagueTeam.Team.BLUE)
|
val blueTeam = TNTLeagueTeam(TNTLeagueConfig.config.blueTeam)
|
||||||
val redTeam = TNTLeagueTeam(TNTLeagueWorldConfig.redTeam, TNTLeagueTeam.Team.RED)
|
val redTeam = TNTLeagueTeam(TNTLeagueConfig.config.redTeam)
|
||||||
|
|
||||||
private lateinit var start: Timestamp
|
private lateinit var start: Timestamp
|
||||||
|
|
||||||
@@ -156,10 +156,18 @@ object TNTLeagueGame {
|
|||||||
|
|
||||||
fun getTeam(player: Player) = if (player in blueTeam.members) blueTeam else if (player in redTeam.members) redTeam else null
|
fun getTeam(player: Player) = if (player in blueTeam.members) blueTeam else if (player in redTeam.members) redTeam else null
|
||||||
|
|
||||||
fun getFreeTeam(player: Player) = if (blueTeam.leader == null && (TNTLeagueConfig.config.blueLeader == null || player.uniqueId == TNTLeagueConfig.config.blueLeader)) blueTeam
|
fun getFreeTeam(player: Player) = if (TNTLeagueConfig.isEvent()) getEventFreeTeam(player) else getNormalFreeTeam(player)
|
||||||
|
|
||||||
|
private fun getNormalFreeTeam(player: Player) = if (blueTeam.leader == null && (TNTLeagueConfig.config.blueLeader == null || player.uniqueId == TNTLeagueConfig.config.blueLeader)) blueTeam
|
||||||
else if (redTeam.leader == null && TNTLeagueConfig.config.redLeader == null || player.uniqueId == TNTLeagueConfig.config.redLeader) redTeam
|
else if (redTeam.leader == null && TNTLeagueConfig.config.redLeader == null || player.uniqueId == TNTLeagueConfig.config.redLeader) redTeam
|
||||||
else null
|
else null
|
||||||
|
|
||||||
|
private fun getEventFreeTeam(player: Player) = SteamwarUser.get(player.uniqueId).let { user ->
|
||||||
|
if (user.team == TNTLeagueConfig.config.eventTeamBlue.teamId && blueTeam.members.size < TNTLeagueConfig.config.event.maximumTeamMembers) blueTeam
|
||||||
|
else if (user.team == TNTLeagueConfig.config.eventTeamRed.teamId && redTeam.members.size < TNTLeagueConfig.config.event.maximumTeamMembers) redTeam
|
||||||
|
else null
|
||||||
|
}
|
||||||
|
|
||||||
fun checkStart() {
|
fun checkStart() {
|
||||||
if (blueTeam.isReady && redTeam.isReady) {
|
if (blueTeam.isReady && redTeam.isReady) {
|
||||||
blueTeam.leader?.inventory?.clear()
|
blueTeam.leader?.inventory?.clear()
|
||||||
@@ -209,18 +217,26 @@ 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.onlinePlayers.forEach { message.send("TEAM_WIN", it, SubMessage(tntLeagueTeam.name)) }
|
plugin.server.onlinePlayers.forEach { message.send("TEAM_WIN", it, tntLeagueTeam.name) }
|
||||||
explode(tntLeagueTeam.opposite)
|
explode(tntLeagueTeam.opposite)
|
||||||
|
|
||||||
|
if (TNTLeagueConfig.isEvent()) {
|
||||||
|
TNTLeagueConfig.config.eventFight.ergebnis = tntLeagueTeam.ergebnisInt
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun draw(reason: WinReason) {
|
fun draw(reason: WinReason) {
|
||||||
if (state != GameState.RUNNING) return
|
if (state != GameState.RUNNING) return
|
||||||
end()
|
end()
|
||||||
message.broadcast("DRAW")
|
message.broadcast("DRAW")
|
||||||
|
|
||||||
|
if (TNTLeagueConfig.isEvent()) {
|
||||||
|
TNTLeagueConfig.config.eventFight.ergebnis = 3
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun explode(team: TNTLeagueTeam) {
|
fun explode(team: TNTLeagueTeam) {
|
||||||
Area(team.config.spawnLocation.clone().add(20.0, 30.0, 20.0), team.config.spawnLocation.clone().subtract(20.0, 0.0, 20.0).add(0.0, 30.0, 0.0))
|
Area(team.config.worldConfig.spawnLocation.clone().add(20.0, 30.0, 20.0), team.config.worldConfig.spawnLocation.clone().subtract(20.0, 0.0, 20.0).add(0.0, 30.0, 0.0))
|
||||||
.locations
|
.locations
|
||||||
.filterIndexed { index, _ -> index % 7 == 0 }
|
.filterIndexed { index, _ -> index % 7 == 0 }
|
||||||
.forEachIndexed { index, location ->
|
.forEachIndexed { index, location ->
|
||||||
@@ -235,8 +251,8 @@ object TNTLeagueGame {
|
|||||||
plugin.server.worlds.first().name,
|
plugin.server.worlds.first().name,
|
||||||
"TNTLeague",
|
"TNTLeague",
|
||||||
"",
|
"",
|
||||||
blueTeam.name.colorByTeam(blueTeam),
|
blueTeam.name.message.colorByTeam(blueTeam),
|
||||||
redTeam.name.colorByTeam(redTeam),
|
redTeam.name.message.colorByTeam(redTeam),
|
||||||
state.lobbyName,
|
state.lobbyName,
|
||||||
TNTLeagueConfig.config.gameTime - gameTimeRemaining,
|
TNTLeagueConfig.config.gameTime - gameTimeRemaining,
|
||||||
blueTeam.leader?.let { SteamwarUser.get(it.uniqueId).id } ?: 0,
|
blueTeam.leader?.let { SteamwarUser.get(it.uniqueId).id } ?: 0,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ package de.steamwar.tntleague.game
|
|||||||
import de.steamwar.message.SubMessage
|
import de.steamwar.message.SubMessage
|
||||||
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.TeamConfig
|
||||||
import de.steamwar.tntleague.config.targetedBlocks
|
import de.steamwar.tntleague.config.targetedBlocks
|
||||||
import de.steamwar.tntleague.game.TNTLeagueGame.WinReason
|
import de.steamwar.tntleague.game.TNTLeagueGame.WinReason
|
||||||
import de.steamwar.tntleague.game.TNTLeagueGame.updateFightinfo
|
import de.steamwar.tntleague.game.TNTLeagueGame.updateFightinfo
|
||||||
@@ -32,11 +33,10 @@ import net.kyori.adventure.text.Component
|
|||||||
import org.bukkit.GameMode
|
import org.bukkit.GameMode
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
import org.bukkit.Sound
|
import org.bukkit.Sound
|
||||||
import org.bukkit.enchantments.Enchantment
|
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
|
|
||||||
data class TNTLeagueTeam(val config: TNTLeagueWorldConfig.TeamConfig, private val team: Team) {
|
data class TNTLeagueTeam(val config: TeamConfig) {
|
||||||
|
|
||||||
var leader: Player? = null
|
var leader: Player? = null
|
||||||
set(player) {
|
set(player) {
|
||||||
@@ -52,11 +52,11 @@ data class TNTLeagueTeam(val config: TNTLeagueWorldConfig.TeamConfig, private va
|
|||||||
val members = mutableListOf<Player>()
|
val members = mutableListOf<Player>()
|
||||||
val invites = mutableListOf<Player>()
|
val invites = mutableListOf<Player>()
|
||||||
|
|
||||||
val name: String
|
val name: SubMessage
|
||||||
get() = team.name.uppercase()
|
get() = config.name
|
||||||
|
|
||||||
val color: Char
|
val color: Char
|
||||||
get() = team.color
|
get() = config.color
|
||||||
|
|
||||||
var isReady: Boolean = false
|
var isReady: Boolean = false
|
||||||
set(value) {
|
set(value) {
|
||||||
@@ -64,7 +64,7 @@ data class TNTLeagueTeam(val config: TNTLeagueWorldConfig.TeamConfig, private va
|
|||||||
leader?.inventory?.setItem(4, readyItem())
|
leader?.inventory?.setItem(4, readyItem())
|
||||||
leader?.let { it.playSound(it.location, Sound.BLOCK_NOTE_BLOCK_PLING, 1f, 1f) }
|
leader?.let { it.playSound(it.location, Sound.BLOCK_NOTE_BLOCK_PLING, 1f, 1f) }
|
||||||
|
|
||||||
message.broadcastActionbar(if (value) "IS_READY" else "IS_NOT_READY", SubMessage(name))
|
message.broadcastActionbar(if (value) "IS_READY" else "IS_NOT_READY", name)
|
||||||
|
|
||||||
if (value && opposite.isReady) {
|
if (value && opposite.isReady) {
|
||||||
TNTLeagueGame.checkStart()
|
TNTLeagueGame.checkStart()
|
||||||
@@ -82,19 +82,27 @@ data class TNTLeagueTeam(val config: TNTLeagueWorldConfig.TeamConfig, private va
|
|||||||
var coins: Int = 0
|
var coins: Int = 0
|
||||||
|
|
||||||
val opposite: TNTLeagueTeam
|
val opposite: TNTLeagueTeam
|
||||||
get() = when (team) {
|
get() = when (this) {
|
||||||
Team.BLUE -> TNTLeagueGame.redTeam
|
TNTLeagueGame.redTeam -> TNTLeagueGame.blueTeam
|
||||||
Team.RED -> TNTLeagueGame.blueTeam
|
TNTLeagueGame.blueTeam -> TNTLeagueGame.redTeam
|
||||||
|
else -> error("Invalid Team")
|
||||||
|
}
|
||||||
|
|
||||||
|
val ergebnisInt: Int
|
||||||
|
get() = when (this) {
|
||||||
|
TNTLeagueGame.redTeam -> 2
|
||||||
|
TNTLeagueGame.blueTeam -> 3
|
||||||
|
else -> error("Invalid Team")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun join(player: Player): Boolean {
|
fun join(player: Player): Boolean {
|
||||||
members.add(player)
|
members.add(player)
|
||||||
|
|
||||||
with(player) {
|
with(player) {
|
||||||
teleport(config.spawnLocation)
|
teleport(config.worldConfig.spawnLocation)
|
||||||
gameMode = GameMode.ADVENTURE
|
gameMode = GameMode.ADVENTURE
|
||||||
inventory.clear()
|
inventory.clear()
|
||||||
message.broadcast("JOIN_TEAM", name.colorByTeam(this@TNTLeagueTeam), SubMessage(this@TNTLeagueTeam.name))
|
message.broadcast("JOIN_TEAM", name.colorByTeam(this@TNTLeagueTeam), this@TNTLeagueTeam.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leader == null) {
|
if (leader == null) {
|
||||||
@@ -154,13 +162,8 @@ 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()
|
||||||
message.broadcast("QUIT_TEAM", name.colorByTeam(this@TNTLeagueTeam), SubMessage(this@TNTLeagueTeam.name))
|
message.broadcast("QUIT_TEAM", name.colorByTeam(this@TNTLeagueTeam), this@TNTLeagueTeam.name)
|
||||||
}
|
}
|
||||||
updateFightinfo()
|
updateFightinfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class Team(val color: Char) {
|
|
||||||
BLUE('3'),
|
|
||||||
RED('c');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -50,10 +50,10 @@ data class TNTLeagueScoreboard(val p: Player): ScoreboardCallback {
|
|||||||
lines.add("§3")
|
lines.add("§3")
|
||||||
|
|
||||||
with(TNTLeagueGame.redTeam) {
|
with(TNTLeagueGame.redTeam) {
|
||||||
lines.add(message.parse("SCOREBOARD_TEAM", p, SubMessage(name), targetedBlocks - damagedBlocks))
|
lines.add(message.parse("SCOREBOARD_TEAM", p, name, targetedBlocks - damagedBlocks))
|
||||||
}
|
}
|
||||||
with(TNTLeagueGame.blueTeam) {
|
with(TNTLeagueGame.blueTeam) {
|
||||||
lines.add(message.parse("SCOREBOARD_TEAM", p, SubMessage(name), targetedBlocks - damagedBlocks))
|
lines.add(message.parse("SCOREBOARD_TEAM", p, name, targetedBlocks - damagedBlocks))
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.add("§4")
|
lines.add("§4")
|
||||||
|
|||||||
Reference in New Issue
Block a user