diff --git a/src/main/kotlin/de/moritzruth/spigot_ttt/game/GameManager.kt b/src/main/kotlin/de/moritzruth/spigot_ttt/game/GameManager.kt index 7439fa9..80eacaa 100644 --- a/src/main/kotlin/de/moritzruth/spigot_ttt/game/GameManager.kt +++ b/src/main/kotlin/de/moritzruth/spigot_ttt/game/GameManager.kt @@ -2,6 +2,7 @@ package de.moritzruth.spigot_ttt.game import com.comphenix.protocol.ProtocolLibrary import de.moritzruth.spigot_ttt.Settings +import de.moritzruth.spigot_ttt.TTTPlugin import de.moritzruth.spigot_ttt.game.classes.TTTClassManager import de.moritzruth.spigot_ttt.game.corpses.CorpseListener import de.moritzruth.spigot_ttt.game.corpses.CorpseManager @@ -20,6 +21,8 @@ import org.bukkit.block.Block import kotlin.random.Random object GameManager { + const val TEAM_CHAT_PREFIX = "." + var phase: GamePhase? = null private set(value) { field = value @@ -158,7 +161,14 @@ object GameManager { if (!it.alive) { it.revive(world.spawnLocation, Settings.initialCredits) } + + if (it.role.group.canUseTeamChat) { + it.player.sendMessage( + "${TTTPlugin.prefix}Schreibe '$TEAM_CHAT_PREFIX' vor deine Nachrichten, um den Team-Chat" + + "zu verwenden.") + } } + ScoreboardHelper.forEveryScoreboard { it.updateTeams() } Timers.playTimerSound() @@ -183,7 +193,7 @@ object GameManager { } } - fun ensurePhase(phase: GamePhase?) { + private fun ensurePhase(phase: GamePhase?) { if (this.phase !== phase) throw IllegalStateException("The game must be in $phase phase") } } diff --git a/src/main/kotlin/de/moritzruth/spigot_ttt/game/GeneralGameListener.kt b/src/main/kotlin/de/moritzruth/spigot_ttt/game/GeneralGameListener.kt index 4e59899..94ad4d1 100644 --- a/src/main/kotlin/de/moritzruth/spigot_ttt/game/GeneralGameListener.kt +++ b/src/main/kotlin/de/moritzruth/spigot_ttt/game/GeneralGameListener.kt @@ -6,7 +6,9 @@ import com.comphenix.protocol.events.PacketAdapter import com.comphenix.protocol.events.PacketEvent import com.comphenix.protocol.wrappers.EnumWrappers import com.comphenix.protocol.wrappers.PlayerInfoData +import de.moritzruth.spigot_ttt.COMMAND_RESPONSE_PREFIX import de.moritzruth.spigot_ttt.TTTPlugin +import de.moritzruth.spigot_ttt.game.GameManager.TEAM_CHAT_PREFIX import de.moritzruth.spigot_ttt.game.players.* import de.moritzruth.spigot_ttt.plugin import de.moritzruth.spigot_ttt.utils.call @@ -139,6 +141,26 @@ object GeneralGameListener : Listener { } event.isCancelled = true + } else { + if (event.message.startsWith(TEAM_CHAT_PREFIX)) { + if (senderTTTPlayer.role.group.canUseTeamChat) { + PlayerManager.tttPlayers + .filter { senderTTTPlayer.role.group == it.role.group } + .forEach { + it.player.sendMessage( + "${ChatColor.GRAY}[${ChatColor.LIGHT_PURPLE}TEAM${ChatColor.GRAY}] " + + "${ChatColor.WHITE}<${event.player.displayName}> ${event.message.drop(1)}" + ) + } + } else { + senderTTTPlayer.player.sendMessage( + "$COMMAND_RESPONSE_PREFIX${ChatColor.RED}Als ${senderTTTPlayer.role.coloredDisplayName}" + + " ${ChatColor.RED}kannst du den Team-Chat nicht verwenden" + ) + } + + event.isCancelled = true + } } } diff --git a/src/main/kotlin/de/moritzruth/spigot_ttt/game/players/RoleGroup.kt b/src/main/kotlin/de/moritzruth/spigot_ttt/game/players/RoleGroup.kt index 0ca9aef..b161c29 100644 --- a/src/main/kotlin/de/moritzruth/spigot_ttt/game/players/RoleGroup.kt +++ b/src/main/kotlin/de/moritzruth/spigot_ttt/game/players/RoleGroup.kt @@ -2,8 +2,12 @@ package de.moritzruth.spigot_ttt.game.players import java.util.* -enum class RoleGroup(val primaryRole: Role, val additionalRoles: EnumSet = EnumSet.noneOf(Role::class.java)) { - INNOCENT(Role.INNOCENT, EnumSet.of(Role.DETECTIVE)), +enum class RoleGroup( + val primaryRole: Role, + val additionalRoles: EnumSet = EnumSet.noneOf(Role::class.java), + val canUseTeamChat: Boolean = true +) { + INNOCENT(Role.INNOCENT, EnumSet.of(Role.DETECTIVE), false), JACKAL(Role.JACKAL, EnumSet.of(Role.SIDEKICK)), TRAITOR(Role.TRAITOR);