diff --git a/src/CustomChatColors.sln b/src/CustomChatColors.sln new file mode 100644 index 0000000..0d33436 --- /dev/null +++ b/src/CustomChatColors.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomChatColors", "CustomChatColors\CustomChatColors.csproj", "{4E66C6D8-1DCD-4A6E-A353-6EE6D4C119CA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4E66C6D8-1DCD-4A6E-A353-6EE6D4C119CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4E66C6D8-1DCD-4A6E-A353-6EE6D4C119CA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4E66C6D8-1DCD-4A6E-A353-6EE6D4C119CA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4E66C6D8-1DCD-4A6E-A353-6EE6D4C119CA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/src/CustomChatColors.sln.DotSettings.user b/src/CustomChatColors.sln.DotSettings.user new file mode 100644 index 0000000..b0253c9 --- /dev/null +++ b/src/CustomChatColors.sln.DotSettings.user @@ -0,0 +1,9 @@ + + True + True + True + True + True + True + True + True \ No newline at end of file diff --git a/src/CustomChatColors/CustomChatColors.cs b/src/CustomChatColors/CustomChatColors.cs new file mode 100644 index 0000000..ec970f1 --- /dev/null +++ b/src/CustomChatColors/CustomChatColors.cs @@ -0,0 +1,79 @@ +using System; +using System.Linq; +using Rocket.Core.Plugins; +using Rocket.Unturned.Player; +using SDG.Unturned; +using UnityEngine; + +namespace CustomChatColors +{ + public class CustomChatColors : RocketPlugin + { + public static CustomChatColors Instance; + + protected override void Load() + { + Instance = this; + + ChatManager.onChatted += OnChatted; + + Rocket.Core.Logging.Logger.Log("Loaded! Made by papershredder432#0883, join the support Discord here: https://discord.gg/ydjYVJ2"); + Rocket.Core.Logging.Logger.Log($"Loaded {Configuration.Instance.CustomColors.Count} unique player color(s)!"); + } + + private void OnChatted(SteamPlayer player, EChatMode mode, ref Color chatted, ref bool isrich, string text, ref bool isvisible) + { + if (text.StartsWith("/")) + return; + + var playerId = player.playerID.steamID; + var uPlayer = UnturnedPlayer.FromCSteamID(playerId); + if (Configuration.Instance.CustomColors.FirstOrDefault(x => x.PlayerId == playerId.m_SteamID) == null) + return; + + var multipleEntries = Configuration.Instance.CustomColors.FindAll(x => x.PlayerId == playerId.m_SteamID); + if (multipleEntries.Count > 1) + { + Rocket.Core.Logging.Logger.LogWarning($"Found {multipleEntries.Count} for {playerId}! Remove the duplicate entries in the config for their custom color to work!"); + return; + } + + var selectedEntry = Configuration.Instance.CustomColors.FirstOrDefault(x => x.PlayerId == playerId.m_SteamID); + + isvisible = false; + + switch (mode) + { + 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; + } + } + + protected override void Unload() + { + Instance = null; + + ChatManager.onChatted -= OnChatted; + + Rocket.Core.Logging.Logger.Log("Unloaded"); + } + } +} \ No newline at end of file diff --git a/src/CustomChatColors/CustomChatColors.csproj b/src/CustomChatColors/CustomChatColors.csproj new file mode 100644 index 0000000..3ec7f3b --- /dev/null +++ b/src/CustomChatColors/CustomChatColors.csproj @@ -0,0 +1,82 @@ + + + + + Debug + AnyCPU + {4E66C6D8-1DCD-4A6E-A353-6EE6D4C119CA} + Library + Properties + CustomChatColors + CustomChatColors + v4.8 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + libs\Assembly-CSharp.dll + + + libs\com.rlabrecque.steamworks.net.dll + + + libs\Rocket.API.dll + + + libs\Rocket.Core.dll + + + libs\Rocket.Unturned.dll + + + libs\SDG.NetTransport.dll + + + + + + + libs\UnityEngine.dll + + + libs\UnityEngine.CoreModule.dll + + + + + + + + + + + + + + + diff --git a/src/CustomChatColors/CustomChatColorsConfiguration.cs b/src/CustomChatColors/CustomChatColorsConfiguration.cs new file mode 100644 index 0000000..5d66c0f --- /dev/null +++ b/src/CustomChatColors/CustomChatColorsConfiguration.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using CustomChatColors.Models; +using Rocket.API; + +namespace CustomChatColors +{ + public class CustomChatColorsConfiguration : IRocketPluginConfiguration + { + public List CustomColors; + + public void LoadDefaults() + { + CustomColors = new List + { + new MCustomColor { PlayerId = 76561198132469161, HexColorCode = "FF00FF"} + }; + } + } +} \ No newline at end of file diff --git a/src/CustomChatColors/Models/MCustomColor.cs b/src/CustomChatColors/Models/MCustomColor.cs new file mode 100644 index 0000000..002b7b1 --- /dev/null +++ b/src/CustomChatColors/Models/MCustomColor.cs @@ -0,0 +1,13 @@ +using System.Xml.Serialization; + +namespace CustomChatColors.Models +{ + public class MCustomColor + { + [XmlAttribute] + public ulong PlayerId { get; set; } + + [XmlAttribute] + public string HexColorCode { get; set; } + } +} \ No newline at end of file diff --git a/src/CustomChatColors/Properties/AssemblyInfo.cs b/src/CustomChatColors/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..79964a3 --- /dev/null +++ b/src/CustomChatColors/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CustomChatColors")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CustomChatColors")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4E66C6D8-1DCD-4A6E-A353-6EE6D4C119CA")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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 diff --git a/src/CustomChatColors/libs/Assembly-CSharp.dll b/src/CustomChatColors/libs/Assembly-CSharp.dll new file mode 100644 index 0000000..fdfbe5c Binary files /dev/null and b/src/CustomChatColors/libs/Assembly-CSharp.dll differ diff --git a/src/CustomChatColors/libs/Rocket.API.dll b/src/CustomChatColors/libs/Rocket.API.dll new file mode 100644 index 0000000..cd40e84 Binary files /dev/null and b/src/CustomChatColors/libs/Rocket.API.dll differ diff --git a/src/CustomChatColors/libs/Rocket.Core.dll b/src/CustomChatColors/libs/Rocket.Core.dll new file mode 100644 index 0000000..1e52f31 Binary files /dev/null and b/src/CustomChatColors/libs/Rocket.Core.dll differ diff --git a/src/CustomChatColors/libs/Rocket.Unturned.dll b/src/CustomChatColors/libs/Rocket.Unturned.dll new file mode 100644 index 0000000..23f21ab Binary files /dev/null and b/src/CustomChatColors/libs/Rocket.Unturned.dll differ diff --git a/src/CustomChatColors/libs/SDG.NetTransport.dll b/src/CustomChatColors/libs/SDG.NetTransport.dll new file mode 100644 index 0000000..da6936e Binary files /dev/null and b/src/CustomChatColors/libs/SDG.NetTransport.dll differ diff --git a/src/CustomChatColors/libs/UnityEngine.CoreModule.dll b/src/CustomChatColors/libs/UnityEngine.CoreModule.dll new file mode 100644 index 0000000..a12f151 Binary files /dev/null and b/src/CustomChatColors/libs/UnityEngine.CoreModule.dll differ diff --git a/src/CustomChatColors/libs/UnityEngine.dll b/src/CustomChatColors/libs/UnityEngine.dll new file mode 100644 index 0000000..fc27c7f Binary files /dev/null and b/src/CustomChatColors/libs/UnityEngine.dll differ diff --git a/src/CustomChatColors/libs/com.rlabrecque.steamworks.net.dll b/src/CustomChatColors/libs/com.rlabrecque.steamworks.net.dll new file mode 100644 index 0000000..ec17cbd Binary files /dev/null and b/src/CustomChatColors/libs/com.rlabrecque.steamworks.net.dll differ