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 ChillShopKeeper v0.2.1
ChillShopKeeper.dll
Decompiled 13 hours agousing System; using System.Collections.Concurrent; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; 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.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("ChillShopKeeper")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.1.0")] [assembly: AssemblyInformationalVersion("0.2.1")] [assembly: AssemblyProduct("ChillShopKeeper")] [assembly: AssemblyTitle("ChillShopKeeper")] [assembly: AssemblyVersion("0.2.1.0")] 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; } } } namespace ChillShopKeeper { public static class ChillPolicy { public static bool ShouldSkip(bool disableGlobally, bool playerExempt) { return disableGlobally || playerExempt; } } public sealed class PlayerRegistry { private const string Section = "Immunity"; private readonly ConfigFile _config; private readonly ConcurrentDictionary<string, ConfigEntry<bool>> _entries = new ConcurrentDictionary<string, ConfigEntry<bool>>(); public PlayerRegistry(ConfigFile config) { _config = config; } public void Observe(string steamID, string displayName) { string displayName2 = displayName; if (!string.IsNullOrEmpty(steamID)) { _entries.GetOrAdd(steamID, (Func<string, ConfigEntry<bool>>)((string sid) => _config.Bind<bool>("Immunity", ConfigKeyFor(sid, displayName2), false, "Steam ID " + sid + ". When true, this player is exempt from ShopKeeper punishment."))); } } public bool IsExempt(string steamID) { if (string.IsNullOrEmpty(steamID)) { return false; } if (_entries.TryGetValue(steamID, out ConfigEntry<bool> value)) { return value.Value; } return false; } public void SetExempt(string steamID, bool value) { if (_entries.TryGetValue(steamID, out ConfigEntry<bool> value2)) { value2.Value = value; } } private static string ConfigKeyFor(string steamID, string displayName) { string text = Sanitize(displayName); if (!string.IsNullOrEmpty(text)) { return text; } return "Player_" + steamID; } private static string Sanitize(string name) { if (string.IsNullOrEmpty(name)) { return string.Empty; } char[] array = name.ToCharArray(); for (int i = 0; i < array.Length; i++) { char c = array[i]; if (c == '=' || c == '\n' || c == '\r' || c == '[' || c == ']') { array[i] = '_'; } } return new string(array).Trim(); } } [BepInPlugin("darkharasho.ChillShopKeeper", "ChillShopKeeper", "0.2.1")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry<bool> DisableGlobally; internal static PlayerRegistry Players; private void Awake() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; DisableGlobally = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableGlobally", false, "When true, the ShopKeeper ignores ruckus from everyone. Overrides per-player toggles."); Players = new PlayerRegistry(((BaseUnityPlugin)this).Config); new Harmony("darkharasho.ChillShopKeeper").PatchAll(); Log.LogInfo((object)"ChillShopKeeper v0.2.1 loaded."); } } public static class PluginInfo { public const string PLUGIN_GUID = "darkharasho.ChillShopKeeper"; public const string PLUGIN_NAME = "ChillShopKeeper"; public const string PLUGIN_VERSION = "0.2.1"; } } namespace ChillShopKeeper.Patches { [HarmonyPatch(typeof(PlayerAvatar), "AddToStatsManagerRPC")] internal static class PlayerAvatar_AddToStatsManagerRPC_Postfix { private static void Postfix(string _playerName, string _steamID) { try { Plugin.Players.Observe(_steamID, _playerName); } catch (Exception arg) { Plugin.Log.LogError((object)$"PlayerObserver postfix failed: {arg}"); } } } [HarmonyPatch(typeof(ShopKeeper), "AddRuckusScore")] internal static class ShopKeeper_AddRuckusScore_Prefix { private static readonly FieldRef<PlayerAvatar, string> SteamIdRef = AccessTools.FieldRefAccess<PlayerAvatar, string>("steamID"); private static bool Prefix(PlayerAvatar _player) { try { if ((Object)(object)_player == (Object)null) { return true; } bool playerExempt = false; string text = SteamIdRef.Invoke(_player); if (!string.IsNullOrEmpty(text)) { playerExempt = Plugin.Players.IsExempt(text); } if (ChillPolicy.ShouldSkip(Plugin.DisableGlobally.Value, playerExempt)) { return false; } return true; } catch (Exception arg) { Plugin.Log.LogError((object)$"AddRuckusScore prefix failed: {arg}"); return true; } } } }