1
0
Fork 0

Fix Second Chance

This commit is contained in:
Moritz Ruth 2020-06-14 00:20:56 +02:00
parent d0d0cfc124
commit 71ff5f9286
No known key found for this signature in database
GPG key ID: AFD57E23E753841B

View file

@ -84,6 +84,8 @@ object SecondChance: TTTItem, Buyable {
state.timeoutAction = TimeoutAction(event.tttPlayer, event.tttCorpse.location) state.timeoutAction = TimeoutAction(event.tttPlayer, event.tttCorpse.location)
} }
} }
isc.forEveryState { s, _ -> if (s.timeoutAction != null) event.winnerRoleGroup = null }
} }
@EventHandler @EventHandler
@ -137,18 +139,22 @@ object SecondChance: TTTItem, Buyable {
val duration = Duration.between(startedAt, Instant.now()).toMillis().toDouble() / 1000 val duration = Duration.between(startedAt, Instant.now()).toMillis().toDouble() / 1000
val progress = duration / TIMEOUT val progress = duration / TIMEOUT
if (progress > 1) stop() else bossBar.progress = 1.0 - progress if (progress > 1) onTimeout() else bossBar.progress = 1.0 - progress
}, 0, 1) }, 0, 1)
private fun onTimeout() {
try {
PlayerManager.letRemainingRoleGroupWin()
} catch (e: IllegalStateException) {}
stop()
}
fun stop() { fun stop() {
isc.remove(tttPlayer) isc.remove(tttPlayer)
task.cancel() task.cancel()
tttPlayer.player.closeInventory() tttPlayer.player.closeInventory()
bossBar.removePlayer(tttPlayer.player) bossBar.removePlayer(tttPlayer.player)
try {
PlayerManager.letRemainingRoleGroupWin()
} catch (e: IllegalStateException) {}
} }
} }