using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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 ExitGames.Client.Photon; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("my.pahsiv.MyColoredName")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.5.0")] [assembly: AssemblyInformationalVersion("0.1.5")] [assembly: AssemblyProduct("my.pahsiv.MyColoredName")] [assembly: AssemblyTitle("MyColoredName")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.5.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace MyColoredName { public class AntiCheat : IOnEventCallback { private const byte ANTICHEAT_EVENT_CODE = 69; public void OnEvent(EventData photonEvent) { if (photonEvent.Code == 69 && photonEvent.CustomData is object[] array && array.Length >= 3) { string text = (string)array[0]; string text2 = (string)array[1]; string text3 = (string)array[2]; Plugin.Log.LogMessage((object)(" [AntiCheat] Received ping from " + text + " (ID: " + text2 + ", Version: " + text3 + ")")); Plugin.thereIsAntiCheat = true; } } } [BepInPlugin("my.pahsiv.MyColoredName", "MyColoredName", "0.1.5")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__22 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; public bool reset; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; Plugin plugin = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; Log.LogMessage((object)$" Colored Name Started! Waiting for AntiCheat... | thereIsAntiCheat : {thereIsAntiCheat}"); <>2__current = (object)new WaitForSeconds(10f); <>1__state = 1; return true; case 1: <>1__state = -1; if (thereIsAntiCheat) { Log.LogMessage((object)" AntiCheat Detected! Skipping to avoid crashing the lobby..."); Notification("AntiCheat Detected! Skipping color setting...", ColorUtility.ToHtmlStringRGB(Color.yellow), sound: true); } else { if (!hasApplied) { OriginalName = PhotonNetwork.LocalPlayer.NickName; } Log.LogMessage((object)(" Original Name : " + OriginalName)); if (!string.IsNullOrEmpty(OriginalName) && plugin.IsValidColorCode(FirstColor.Value) && plugin.IsValidColorCode(SecondColor.Value) && plugin.IsValidColorCode(ThirdColor.Value) && plugin.IsValidColorCode(FourthColor.Value) && plugin.IsValidColorCode(FifthColor.Value)) { string text = plugin.ColoredName(OriginalName); Notification("Setting your name to : " + text, "FFFFFF", sound: true); PhotonNetwork.LocalPlayer.NickName = text; Log.LogMessage((object)(" New Name : " + text)); hasApplied = true; Item prefab = Player.localPlayer.itemSlots[0].prefab; if ((Object)(object)prefab != (Object)null) { Log.LogMessage((object)(" " + ((Object)prefab).name + " detected!")); if (((Object)prefab).name.ToLower().Contains("passport")) { Log.LogMessage((object)" Destroy floaty passport!"); ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("DestroyHeldItemRpc", (RpcTarget)0, Array.Empty()); } } if (reset) { PhotonNetwork.Instantiate("Character", Character.localCharacter.Head, ((Component)Character.localCharacter).transform.rotation, (byte)0, (object[])null); } } } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static ConfigEntry ColorEnable; public static ConfigEntry FirstColor; public static ConfigEntry SecondColor; public static ConfigEntry ThirdColor; public static ConfigEntry FourthColor; public static ConfigEntry FifthColor; public static ConfigEntry FirstPartLength; public static ConfigEntry SecondPartLength; public static ConfigEntry ThirdPartLength; public static ConfigEntry FourthPartLength; public static ConfigEntry FifthPartLength; private static string OriginalName = string.Empty; private static bool hasApplied = false; public static AntiCheat? antiCheatHandler = null; public static bool thereIsAntiCheat = false; public const string Id = "my.pahsiv.MyColoredName"; internal static ManualLogSource Log { get; private set; } = null; public static string Name => "MyColoredName"; public static string Version => "0.1.5"; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; ColorEnable = ((BaseUnityPlugin)this).Config.Bind("General", "Colored Name Enable", true, "Changes will be applied when you enter the Airport."); FirstColor = ((BaseUnityPlugin)this).Config.Bind("General", "First Color", "FF0000", "First Color to display."); FirstPartLength = ((BaseUnityPlugin)this).Config.Bind("General", "First Length", 1, "Number of characters in First Color."); SecondColor = ((BaseUnityPlugin)this).Config.Bind("General", "Second Color", "00FF00", "Second Color to display."); SecondPartLength = ((BaseUnityPlugin)this).Config.Bind("General", "Second Length", 2, "Number of characters in Second Color."); ThirdColor = ((BaseUnityPlugin)this).Config.Bind("General", "Third Color", "0000FF", "Third Color to display."); ThirdPartLength = ((BaseUnityPlugin)this).Config.Bind("General", "Third Length", 3, "Number of characters in Third Color."); FourthColor = ((BaseUnityPlugin)this).Config.Bind("General", "Fourth Color", "000000", "Fourth Color to display."); FourthPartLength = ((BaseUnityPlugin)this).Config.Bind("General", "Fourth Length", 0, "Number of characters in Fourth Color."); FifthColor = ((BaseUnityPlugin)this).Config.Bind("General", "Fifth Color", "FFFFFF", "Fifth Color to display."); FifthPartLength = ((BaseUnityPlugin)this).Config.Bind("General", "Fifth Length", 5, "Number of characters in Fifth Color."); FirstColor.SettingChanged += SettingChanged; SecondColor.SettingChanged += SettingChanged; ThirdColor.SettingChanged += SettingChanged; FourthColor.SettingChanged += SettingChanged; FifthColor.SettingChanged += SettingChanged; FirstPartLength.SettingChanged += SettingChanged; SecondPartLength.SettingChanged += SettingChanged; ThirdPartLength.SettingChanged += SettingChanged; FourthPartLength.SettingChanged += SettingChanged; FifthPartLength.SettingChanged += SettingChanged; SceneManager.sceneLoaded += OnSceneLoaded; antiCheatHandler = new AntiCheat(); PhotonNetwork.AddCallbackTarget((object)antiCheatHandler); Log.LogMessage((object)(" Plugin " + Name + " " + Version + " is loaded!")); } private void OnDestroy() { PhotonNetwork.RemoveCallbackTarget((object)antiCheatHandler); } private void OnSceneLoaded(Scene scene, LoadSceneMode _) { if (ColorEnable.Value) { Log.LogMessage((object)(" Colored Name Enabled! Current Scene : " + ((Scene)(ref scene)).name)); if (((Scene)(ref scene)).name == "Airport") { ((MonoBehaviour)this).StartCoroutine(SetName(reset: true)); } else if (((Scene)(ref scene)).name.Contains("Level_")) { ((MonoBehaviour)this).StartCoroutine(SetName(reset: false)); } else if (((Scene)(ref scene)).name == "Title") { thereIsAntiCheat = false; } } } [IteratorStateMachine(typeof(d__22))] private IEnumerator SetName(bool reset) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__22(0) { <>4__this = this, reset = reset }; } private string ColoredName(string OriginalName) { int value = FirstPartLength.Value; int value2 = SecondPartLength.Value; int value3 = ThirdPartLength.Value; int value4 = FourthPartLength.Value; int value5 = FifthPartLength.Value; string text = ((value > 0) ? OriginalName.Substring(0, Math.Min(value, OriginalName.Length)) : string.Empty); string text2 = ((value2 > 0 && value < OriginalName.Length) ? OriginalName.Substring(value, Math.Min(value2, OriginalName.Length - value)) : string.Empty); string text3 = ((value3 > 0 && value + value2 < OriginalName.Length) ? OriginalName.Substring(value + value2, Math.Min(value3, OriginalName.Length - value - value2)) : string.Empty); string text4 = ((value4 > 0 && value + value2 + value3 < OriginalName.Length) ? OriginalName.Substring(value + value2 + value3, Math.Min(value4, OriginalName.Length - value - value2 - value3)) : string.Empty); string text5 = ((value5 > 0 && value + value2 + value3 + value4 < OriginalName.Length) ? OriginalName.Substring(value + value2 + value3 + value4, Math.Min(value5, OriginalName.Length - value - value2 - value3 - value4)) : string.Empty); int num = value + value2 + value3 + value4 + value5; string text6 = ((num < OriginalName.Length) ? OriginalName.Substring(num) : string.Empty); string text7 = string.Empty; if (!string.IsNullOrEmpty(text)) { text7 += AddColor(text, FirstColor.Value); } if (!string.IsNullOrEmpty(text2)) { text7 += AddColor(text2, SecondColor.Value); } if (!string.IsNullOrEmpty(text3)) { text7 += AddColor(text3, ThirdColor.Value); } if (!string.IsNullOrEmpty(text4)) { text7 += AddColor(text4, FourthColor.Value); } if (!string.IsNullOrEmpty(text5)) { text7 += AddColor(text5, FifthColor.Value); } if (!string.IsNullOrEmpty(text6)) { text7 += text6; } return text7; } private string AddColor(string inputString, string colorCode) { return "" + inputString + ""; } private void SettingChanged(object sender, EventArgs e) { if (!IsValidColorCode(FirstColor.Value)) { FirstColor.Value = "FFFFFF"; } if (!IsValidColorCode(SecondColor.Value)) { SecondColor.Value = "FFFFFF"; } if (!IsValidColorCode(ThirdColor.Value)) { ThirdColor.Value = "FFFFFF"; } if (!IsValidColorCode(FourthColor.Value)) { FourthColor.Value = "FFFFFF"; } if (!IsValidColorCode(FifthColor.Value)) { FifthColor.Value = "FFFFFF"; } if (FirstPartLength.Value < 0 || FirstPartLength.Value > 100) { FirstPartLength.Value = 0; } if (SecondPartLength.Value < 0 || SecondPartLength.Value > 100) { SecondPartLength.Value = 0; } if (ThirdPartLength.Value < 0 || ThirdPartLength.Value > 100) { ThirdPartLength.Value = 0; } if (FourthPartLength.Value < 0 || FourthPartLength.Value > 100) { FourthPartLength.Value = 0; } if (FifthPartLength.Value < 0 || FifthPartLength.Value > 100) { FifthPartLength.Value = 0; } } private bool IsValidColorCode(string colorCode) { if (string.IsNullOrEmpty(colorCode) || colorCode.Length != 6) { return false; } return colorCode.All((char c) => char.IsDigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')); } public static void Notification(string message, string color = "FFFFFF", bool sound = false) { //IL_0086: 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) PlayerConnectionLog val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null) { return; } string text = "" + message + ""; MethodInfo method = typeof(PlayerConnectionLog).GetMethod("AddMessage", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(val, new object[1] { text }); if ((Object)(object)val.sfxJoin != (Object)null && sound) { val.sfxJoin.Play(default(Vector3)); } } else { Debug.LogWarning((object)"AddMessage method not found."); } } private void SendAntiCheatPing() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom || PhotonNetwork.LocalPlayer == null) { Log.LogWarning((object)" [AntiCheat] Cannot send ping - not in a room yet"); return; } object[] array = new object[3] { PhotonNetwork.LocalPlayer.NickName, PhotonNetwork.LocalPlayer.UserId, "1.4.9" }; RaiseEventOptions val = new RaiseEventOptions { Receivers = (ReceiverGroup)0 }; Log.LogWarning((object)$" [AntiCheat] Sending ping event with code {(byte)69}"); bool flag = PhotonNetwork.RaiseEvent((byte)69, (object)array, val, SendOptions.SendReliable); Log.LogWarning((object)$" [AntiCheat] Anticheat ping sent - Success: {flag}"); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }