Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FixAchievements v1.0.2
FixAchievements.dll
Decompiled a week agousing System; using System.Collections.Generic; 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 HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("FixAchievements")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("Fix Achievements")] [assembly: AssemblyTitle("FixAchievements")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 FixAchievements { [BepInPlugin("FixAchievements", "Fix Achievements", "1.0.2")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Achievements), "CanGetAchievements")] private static class Patch { private static bool Prefix(ref bool __result, bool cheated) { if (Instance.isOn() && cheated) { if (Instance.showMessages.Status && (Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, "Cheated detected in CanGetAchievements!", 0, (Sprite)null, false, true); } Instance.debugLog("Cheat detected in CanGetAchievements!"); __result = true; return false; } return true; } } [HarmonyPatch(typeof(Achievements), "IsCheatedAtAll")] private static class Patch2 { private static bool modded = true; private static void Prefix() { if (Instance.isOn()) { modded = Game.isModded; Game.isModded = false; } } private static void Postfix(bool ___m_cheatCheckCache) { if (Instance.isOn()) { Game.isModded = modded; if (___m_cheatCheckCache && Instance.showMessages.Status && (Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, "Cheated detected in IsCheatedAtAll!", 0, (Sprite)null, false, true); } if (___m_cheatCheckCache) { Instance.debugLog("Cheat check cache is true"); } } } } [HarmonyPatch(typeof(Achievements), "IsWorldCheated")] private static class Patch3 { private static bool Prefix(ref bool __result) { if (Instance.isOn() && Instance.BypassIsWorldCheated.Status) { __result = false; Instance.debugLog("Bypassing is world cheated detection!"); return false; } return true; } } [HarmonyPatch(typeof(Player), "OnInventoryChanged")] private static class Patch4 { private static void Prefix(bool ___m_isLoading) { if (!___m_isLoading && Instance.isOn() && Instance.ClearCheatedItemsTag.Status) { Instance.ClearTagCheatedItems(); } } } [HarmonyPatch(typeof(Humanoid), "Pickup")] private static class Patch5 { private static void Prefix(GameObject go, Humanoid __instance) { if (!Instance.isOn() || !Instance.ClearCheatedItemsTag.Status) { return; } ItemDrop component = go.GetComponent<ItemDrop>(); if (!((Object)(object)component != (Object)null)) { return; } component.Load(); if (((Character)__instance).IsPlayer() && component.m_itemData.m_cheated) { component.m_itemData.m_cheated = false; if (Instance.showMessages.Status && (Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, "Cheated tag cleared on pickup: " + component.m_itemData.m_shared.m_name, 0, (Sprite)null, false, true); } Instance.debugLog("Clearing cheated tag on pickup!"); } } } internal static Plugin Instance; internal static ManualLogSource Logger; internal static Harmony Harmony = new Harmony("FixAchievements"); internal PluginConfig Enabled = null; internal PluginConfig Debug = null; internal PluginConfig BypassIsWorldCheated = null; internal PluginConfig ClearCheatedItemsTag = null; internal PluginConfig showMessages = null; private void Awake() { Instance = this; Logger = ((BaseUnityPlugin)this).Logger; Enabled = new PluginConfig("General", "Enabled", "Enable the plugin", defaultValue: true); Debug = new PluginConfig("General", "Debug", "Enable debug mode"); BypassIsWorldCheated = new PluginConfig("General", "Bypass IsWorldCheated", "Bypass world cheated detection", defaultValue: true); ClearCheatedItemsTag = new PluginConfig("General", "Clear Cheated Items Tag", "Clear cheated tags from items", defaultValue: true); showMessages = new PluginConfig("General", "Show Messages", "Show messages when cheats are detected", defaultValue: true); Harmony.PatchAll(); Logger.LogInfo((object)"Plugin FixAchievements is loaded!"); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); Harmony.UnpatchSelf(); Logger.LogInfo((object)"Plugin FixAchievements is unloaded!"); } public bool isOn() { if (Enabled != null) { return Enabled.Status; } return false; } private void FixedUpdate() { if (Enabled != null) { Enabled.Update(); } if (Debug != null) { Debug.Update(); } if (showMessages != null) { showMessages.Update(); } if (BypassIsWorldCheated != null) { BypassIsWorldCheated.Update(); } if (ClearCheatedItemsTag != null) { ClearCheatedItemsTag.Update(); } if (!isOn() || (Object)(object)Player.m_localPlayer == (Object)null) { return; } PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); ZNetView component = ((Component)Player.m_localPlayer).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null) { return; } if (component.GetZDO().GetBool(ZDOVars.s_cheated, false)) { if (showMessages != null && showMessages.Status && (Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, "Cheat detected on " + Player.m_localPlayer.GetPlayerName() + "!", 0, (Sprite)null, false, true); } debugLog("Cheat detected on " + Player.m_localPlayer.GetPlayerName() + "!"); component.GetZDO().Set(ZDOVars.s_cheated, false); } if (playerProfile != null && playerProfile.m_usedCheats) { if (showMessages != null && showMessages.Status && (Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, "Cheat detected on " + Player.m_localPlayer.GetPlayerName() + " in Player Profile!", 0, (Sprite)null, false, true); } debugLog("Cheat detected on " + Player.m_localPlayer.GetPlayerName() + " in Player Profile!"); playerProfile.m_usedCheats = false; } if (ClearCheatedItemsTag != null && ClearCheatedItemsTag.Status) { ClearTagCheatedItems(); } } public void ClearTagCheatedItems() { if ((Object)(object)Player.m_localPlayer == (Object)null) { return; } Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); if (inventory == null || !inventory.AnyCheatedItem()) { return; } int num = 0; List<ItemData> allItems = inventory.GetAllItems(); foreach (ItemData item in allItems) { if (item.m_cheated) { num++; item.m_cheated = false; } } if (showMessages != null && showMessages.Status && (Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)2, $"Cheated tags removed from {num} items!", 0, (Sprite)null, false, true); } debugLog($"Cheated tags removed from {num} items!"); } public void debugLog(string message) { if (Debug != null && Debug.Status) { Logger.LogInfo((object)message); } } } public class PluginConfig { private ConfigEntry<bool> status = null; private bool LastStatus = false; private Action onTrigger = null; public string Section { get; private set; } public string Name { get; private set; } public bool Status { get { if (status != null) { return status.Value; } return false; } set { if (status != null && status.Value != value) { status.Value = value; } } } public PluginConfig(string section, string name, string description, bool defaultValue = false) { Section = section; Name = name; status = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>(Section, "Status of " + Name, defaultValue, description ?? ""); } public PluginConfig SetAction(Action action) { onTrigger = action; return this; } public virtual void Update() { if (status != null && Status != LastStatus) { string text = Section + " " + Name + " " + (Status ? "<color=green>Enabled</color>" : "<color=red>Disabled</color>"); if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage((MessageType)1, text, 0, (Sprite)null, false, true); } if (onTrigger != null) { onTrigger(); } else { LastStatus = Status; } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "FixAchievements"; public const string PLUGIN_NAME = "Fix Achievements"; public const string PLUGIN_VERSION = "1.0.2"; } }