Please disclose if your mod was created primarily 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 LeaveGroupMod v2.0.0
LeaveGroupMod.dll
Decompiled 4 months agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("FirstDkModValheim")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FirstDkModValheim")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("556bcdc8-ea45-4f8f-8acd-a0ff6fbfeca9")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("leave.group.mod", "Leave group Mod", "3.0.0")] public class LeaveGroupMod : BaseUnityPlugin { [HarmonyPatch(typeof(InventoryGui), "OnRightClickItem")] public class Patch_RightClick { private static void Postfix(ItemData item) { if (IsTargetItem(item)) { SendLeave(); } } } [HarmonyPatch(typeof(Player), "UseHotbarItem")] public class Patch_HotbarDirect { private static void Prefix(Player __instance, int index) { Inventory inventory = ((Humanoid)__instance).GetInventory(); ItemData item = ((inventory != null) ? inventory.GetItemAt(index - 1, 0) : null); if (IsTargetItem(item)) { SendLeave(); } } } [HarmonyPatch(typeof(Player), "UseItem")] public class Patch_UseItemFallback { private static void Prefix(Player __instance, ItemData item) { if (IsTargetItem(item)) { SendLeave(); } } } public static ManualLogSource Log; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("leave.group.mod"); val.PatchAll(); Log.LogInfo((object)"LeaveGroupMod carregado."); } public static bool IsTargetItem(ItemData item) { if (item == null) { return false; } string text = item.m_shared?.m_name ?? ""; return text.Contains("Valheim Map") || text.Contains("kg_ServerChangeMap") || text.Contains("ServerChangeMap"); } public static void SendLeave() { if ((Object)(object)Chat.instance != (Object)null) { Chat.instance.SendText((Type)1, "/leave"); Log.LogInfo((object)"Comando /leave enviado ao chat."); } else { Log.LogWarning((object)"Chat.instance == null — Não foi possível enviar /leave"); } } }