diff --git a/src/CustomChatColors/CustomChatColors.cs b/src/CustomChatColors/CustomChatColors.cs index ec970f1..5aae9d2 100644 --- a/src/CustomChatColors/CustomChatColors.cs +++ b/src/CustomChatColors/CustomChatColors.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using Rocket.Core.Plugins; using Rocket.Unturned.Player; using SDG.Unturned; @@ -27,7 +26,6 @@ private void OnChatted(SteamPlayer player, EChatMode mode, ref Color chatted, re return; var playerId = player.playerID.steamID; - var uPlayer = UnturnedPlayer.FromCSteamID(playerId); if (Configuration.Instance.CustomColors.FirstOrDefault(x => x.PlayerId == playerId.m_SteamID) == null) return; @@ -40,31 +38,13 @@ private void OnChatted(SteamPlayer player, EChatMode mode, ref Color chatted, re var selectedEntry = Configuration.Instance.CustomColors.FirstOrDefault(x => x.PlayerId == playerId.m_SteamID); - isvisible = false; - - switch (mode) + if (!ColorUtility.TryParseHtmlString($"#{selectedEntry.HexColorCode}", out Color ourColor)) { - case EChatMode.GROUP: - ChatManager.serverSendMessage($"[GROUP] {uPlayer.CharacterName}: {text}", Color.grey, null, null, mode, uPlayer.SteamProfile.AvatarIcon.ToString(), true); - break; - - case EChatMode.LOCAL: - ChatManager.serverSendMessage($"[AREA] {uPlayer.CharacterName}: {text}", Color.grey, null, null, mode, uPlayer.SteamProfile.AvatarIcon.ToString(), true); - break; - - case EChatMode.GLOBAL: - ChatManager.serverSendMessage($"{uPlayer.CharacterName}: {text}", Color.grey, null, null, mode, uPlayer.SteamProfile.AvatarIcon.ToString(), true); - break; - - case EChatMode.WELCOME: - break; - case EChatMode.SAY: - break; - - default: - Rocket.Core.Logging.Logger.Log("How'd ya get here?"); - break; + Rocket.Core.Logging.Logger.LogWarning($"{selectedEntry.PlayerId} has an invalid color code! Please fix the entry in the config for their custom color to work!"); + return; } + + chatted = ourColor; } protected override void Unload() diff --git a/src/CustomChatColors/Properties/AssemblyInfo.cs b/src/CustomChatColors/Properties/AssemblyInfo.cs index 79964a3..87a09cb 100644 --- a/src/CustomChatColors/Properties/AssemblyInfo.cs +++ b/src/CustomChatColors/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.1.0")] +[assembly: AssemblyFileVersion("1.0.1.0")] \ No newline at end of file