From 29fd6603ac9523601863eef2ac2b70fa673b12a6 Mon Sep 17 00:00:00 2001 From: bluefireoly Date: Sat, 5 Sep 2020 19:59:54 +0200 Subject: [PATCH] Update GamePhases.kt --- .../kotlin/net/axay/kspigot/game/GamePhases.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/axay/kspigot/game/GamePhases.kt b/src/main/kotlin/net/axay/kspigot/game/GamePhases.kt index 92af574a..273ba316 100644 --- a/src/main/kotlin/net/axay/kspigot/game/GamePhases.kt +++ b/src/main/kotlin/net/axay/kspigot/game/GamePhases.kt @@ -5,15 +5,29 @@ package net.axay.kspigot.game import net.axay.kspigot.extensions.broadcast import net.axay.kspigot.main.KSpigot import net.axay.kspigot.runnables.task +import net.md_5.bungee.api.ChatColor class GamePhaseSystem(vararg gamePhases: GamePhase) { val gamePhases = gamePhases.toMutableList() fun begin(kSpigot: KSpigot) = gamePhases.removeAt(0).startIt(kSpigot, gamePhases) } -fun counterMessage(prefix: String? = null, beginning: String, seconds: String, second: String): (Long) -> String = { +fun counterMessage( + beginning: String, + seconds: String, + second: String, + prefix: String? = null, + suffix: String? = null +): (Long) -> String { + val realPrefix = prefix?.plus(" ") ?: "" - if (it <= 1L) "$realPrefix$beginning $it $second" else "$prefix $beginning $it $seconds" + val realSuffix = suffix ?: "" + + return { + val realSeconds = if (it <= 1L) second else seconds + "$realPrefix${ChatColor.RESET}$beginning $it $realSeconds$realSuffix" + } + } class GamePhase(