using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ChatTweaksPlugin;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using Util;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("Celestial Corp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("ChatTweaksPlugin")]
[assembly: AssemblyTitle("ChatTweaksPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[HarmonyPatch]
public class ChatGuildPatch
{
[HarmonyPatch(typeof(ChatGuild), "FormatNickName")]
private class FormatNickNamePatch
{
private static bool Prefix(ChatGuild __instance, ref string rawNickName, ref Roles role, ref string __result)
{
string text = "";
Color color;
if ((int)role >= 1)
{
text = "yellow";
if (DataUtils.TryParseColor(Plugin.modColor.Value, out color))
{
text = Plugin.modColor.Value;
}
}
else if (rawNickName.Equals(PlayerClient.Singleton.player.clientChatName))
{
text = "#00FFFF";
if (DataUtils.TryParseColor(Plugin.selfColor.Value, out color))
{
text = Plugin.selfColor.Value;
}
}
else
{
text = "#5CF300";
if (DataUtils.TryParseColor(Plugin.pcColor.Value, out color))
{
text = Plugin.pcColor.Value;
}
}
string text2 = "<color=" + text + ">" + rawNickName + "</color>";
if (Plugin.timeStamp.Value)
{
DateTime now = DateTime.Now;
string text3 = now.ToString("hh:mm tt");
if (Plugin.milTime.Value)
{
text3 = now.ToString("HH:mm");
}
text2 = text2 + " <size=80%>- " + text3 + "</size>";
}
__result = text2;
return false;
}
}
}
[HarmonyPatch]
public class UserChatListPatch
{
[HarmonyPatch(typeof(UserChatList), "Configure")]
private class ConfigurePatch
{
private static void Postfix(UserChatList __instance, ref UserChat userChat)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Invalid comparison between Unknown and I4
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
object? value = AccessTools.Field(typeof(UserChatList), "tmpNickName").GetValue(__instance);
TMP_Text val = (TMP_Text)((value is TMP_Text) ? value : null);
Color color = default(Color);
if ((int)userChat.role > 0)
{
DataUtils.TryParseColor(Plugin.modColor.Value, out color);
}
else if (userChat.nickName.Equals(PlayerClient.Singleton.player.clientChatName))
{
DataUtils.TryParseColor(Plugin.selfColor.Value, out color);
}
else
{
DataUtils.TryParseColor(Plugin.pcColor.Value, out color);
}
if (color != default(Color))
{
((Graphic)val).color = color;
}
}
}
}
namespace ChatTweaksPlugin
{
public class DataUtils
{
public static bool TryParseColor(string input, out Color color)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (ColorUtility.TryParseHtmlString(input, ref color))
{
return true;
}
PropertyInfo property = typeof(Color).GetProperty(input, BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public);
if (property != null && property.PropertyType == typeof(Color))
{
color = (Color)property.GetValue(null, null);
return true;
}
color = default(Color);
return false;
}
}
[BepInPlugin("com.machaceleste.chattweaksplugin", "ChatTweaksPlugin", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static ConfigEntry<bool> timeStamp;
public static ConfigEntry<bool> milTime;
public static ConfigEntry<string> modColor;
public static ConfigEntry<string> selfColor;
public static ConfigEntry<string> pcColor;
private void Awake()
{
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
timeStamp = ((BaseUnityPlugin)this).Config.Bind<bool>("Main", "1. Timestamp", true, "Enable chat timestamps.");
milTime = ((BaseUnityPlugin)this).Config.Bind<bool>("Main", "2. 24 Hour Time", false, "Enable 24 hour mode for chat timestamps.");
modColor = ((BaseUnityPlugin)this).Config.Bind<string>("Main", "3. Moderator Color", "yellow", "Select chat name color for moderators.");
selfColor = ((BaseUnityPlugin)this).Config.Bind<string>("Main", "4. Self Color", "#00FFFF", "Select chat name color for yourself.");
pcColor = ((BaseUnityPlugin)this).Config.Bind<string>("Main", "5. Player Color", "#5CF300", "Select chat name color for other players.");
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin ChatTweaksPlugin is loaded!");
new Harmony("com.machaceleste.chattweaksplugin").PatchAll();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ChatTweaksPlugin";
public const string PLUGIN_NAME = "ChatTweaksPlugin";
public const string PLUGIN_VERSION = "1.0.1";
}
}