diff --git a/MapChooserSharp/Modules/MapVote/McsMapVoteController.cs b/MapChooserSharp/Modules/MapVote/McsMapVoteController.cs index 1c170b4..12d1ac2 100644 --- a/MapChooserSharp/Modules/MapVote/McsMapVoteController.cs +++ b/MapChooserSharp/Modules/MapVote/McsMapVoteController.cs @@ -915,8 +915,12 @@ private void CastPlayerVote(CCSPlayerController player, byte voteIndex) } IMapVoteData votedMap = _mapVoteContent.GetVotingMaps()[voteIndex]; + + if (_mcsPluginConfigProvider.PluginConfig.VoteConfig.ShouldPrintVoteToChat) + { + PrintLocalizedChatToAll("MapVote.Broadcast.VoteCast", player.PlayerName, GetMapName(votedMap, player).ToString()); + } - PrintLocalizedChatToAll("MapVote.Broadcast.VoteCast", player.PlayerName, GetMapName(votedMap, player).ToString()); voteUi.CloseMenu(); diff --git a/MapChooserSharp/Modules/PluginConfig/Interfaces/IMcsVoteConfig.cs b/MapChooserSharp/Modules/PluginConfig/Interfaces/IMcsVoteConfig.cs index 4c52c4a..98077a9 100644 --- a/MapChooserSharp/Modules/PluginConfig/Interfaces/IMcsVoteConfig.cs +++ b/MapChooserSharp/Modules/PluginConfig/Interfaces/IMcsVoteConfig.cs @@ -10,4 +10,6 @@ internal interface IMcsVoteConfig internal McsSupportedMenuType CurrentMenuType { get; } internal int MaxMenuElements { get; } + + internal bool ShouldPrintVoteToChat { get; } } \ No newline at end of file diff --git a/MapChooserSharp/Modules/PluginConfig/McsPluginConfigParser.cs b/MapChooserSharp/Modules/PluginConfig/McsPluginConfigParser.cs index 3defd60..12e77a0 100644 --- a/MapChooserSharp/Modules/PluginConfig/McsPluginConfigParser.cs +++ b/MapChooserSharp/Modules/PluginConfig/McsPluginConfigParser.cs @@ -1,4 +1,5 @@ -using MapChooserSharp.Models; +using CounterStrikeSharp.API; +using MapChooserSharp.Models; using MapChooserSharp.Modules.McsMenu; using MapChooserSharp.Modules.PluginConfig.Interfaces; using MapChooserSharp.Modules.PluginConfig.Models; @@ -182,13 +183,17 @@ private IMcsVoteConfig ParseVoteConfig(TomlTable tomlModel) { throw new InvalidOperationException("MapVote.MaxVoteElements is not found or invalid"); } - + + if (!voteTable.TryGetValue("ShouldPrintVoteToChat", out var shouldPrintVoteToChatObj) || shouldPrintVoteToChatObj is not bool shouldPrintVoteToChatBool) + { + throw new InvalidOperationException("MapVote.ShouldPrintVoteToChat is not found or invalid"); + } var availableMenus = _avaiableMenuTypes; - + var currentMenuType = DecideMenuType(menuTypeStr, availableMenus); - return new McsVoteConfig(availableMenus, currentMenuType, (int)maxVoteElementsLong); + return new McsVoteConfig(availableMenus, currentMenuType, (int)maxVoteElementsLong, shouldPrintVoteToChatBool); } @@ -283,6 +288,9 @@ private void WriteDefaultConfig() # I would recommend to set 5 when you using BuiltInHtml menu MaxVoteElements = 5 +# Should print vote text to everyone? +ShouldPrintVoteToChat = true + [Nomination] # What menu type should be use? diff --git a/MapChooserSharp/Modules/PluginConfig/Models/McsVoteConfig.cs b/MapChooserSharp/Modules/PluginConfig/Models/McsVoteConfig.cs index b758994..b8cd603 100644 --- a/MapChooserSharp/Modules/PluginConfig/Models/McsVoteConfig.cs +++ b/MapChooserSharp/Modules/PluginConfig/Models/McsVoteConfig.cs @@ -4,10 +4,11 @@ namespace MapChooserSharp.Modules.PluginConfig.Models; -public class McsVoteConfig(List availableVoteMenuTypes, McsSupportedMenuType currentMcsVoteMenuType, int maxMenuElements) +public class McsVoteConfig(List availableVoteMenuTypes, McsSupportedMenuType currentMcsVoteMenuType, int maxMenuElements, bool shouldPrintVoteToChat) : IMcsVoteConfig { public List AvailableMenuTypes { get; } = availableVoteMenuTypes; public McsSupportedMenuType CurrentMenuType { get; } = currentMcsVoteMenuType; public int MaxMenuElements { get; } = maxMenuElements; + public bool ShouldPrintVoteToChat { get; } = shouldPrintVoteToChat; } \ No newline at end of file