forked from SteamWar/SteamWar
Fixes and De-Spagetti Code
This commit is contained in:
@@ -175,10 +175,7 @@ object TNTLeagueGame {
|
||||
blueTeam.invites.remove(player)
|
||||
redTeam.invites.remove(player)
|
||||
getTeam(player)?.apply {
|
||||
members.remove(player)
|
||||
if (leader == player && members.isNotEmpty() && state == GameState.RUNNING) {
|
||||
win(this.opposite, WinReason.LEAVE)
|
||||
}
|
||||
remove(player)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ package de.steamwar.tntleague.game
|
||||
import de.steamwar.tntleague.colorByTeam
|
||||
import de.steamwar.tntleague.config.TNTLeagueWorldConfig
|
||||
import de.steamwar.tntleague.config.targetedBlocks
|
||||
import de.steamwar.tntleague.game.TNTLeagueGame.WinReason
|
||||
import de.steamwar.tntleague.game.TNTLeagueGame.win
|
||||
import de.steamwar.tntleague.message
|
||||
import de.steamwar.tntleague.plugin
|
||||
import net.kyori.adventure.text.Component
|
||||
@@ -127,9 +129,8 @@ data class TNTLeagueTeam(val config: TNTLeagueWorldConfig.TeamConfig, private va
|
||||
}
|
||||
|
||||
fun leave(player: Player) {
|
||||
members.remove(player)
|
||||
if (TNTLeagueGame.state != TNTLeagueGame.GameState.RUNNING) {
|
||||
members.remove(player)
|
||||
|
||||
if (members.isEmpty()) {
|
||||
plugin.server.onlinePlayers.firstOrNull { it != player && TNTLeagueGame.getTeam(it) == null }?.run {
|
||||
members.add(this)
|
||||
@@ -142,6 +143,10 @@ data class TNTLeagueTeam(val config: TNTLeagueWorldConfig.TeamConfig, private va
|
||||
isReady = false
|
||||
}
|
||||
}
|
||||
} else if (TNTLeagueGame.state == TNTLeagueGame.GameState.RUNNING) {
|
||||
if (members.isEmpty()) {
|
||||
win(this.opposite, WinReason.LEAVE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user