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 LethalReport v1.0.1
BepInEx/plugins/LethalReport.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using LethalReport.Patches; using Steamworks; using Unity.Netcode; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("LethalReport")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("DESKTOP-")] [assembly: AssemblyProduct("LethalReport")] [assembly: AssemblyCopyright("Copyright © DESKTOP- 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("79560b02-a627-40a4-a633-ba1379598abc")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace LethalReport { public class ApiClient { public delegate void OnReportReceived(string json, string steamId); public class ReportReason { public static string Toxic = "TOXIC"; public static string Cheat = "CHEATING"; public static string TeamKill = "TEAM_KILL"; public static string Troll = "TROLL"; public static string Undefined = "Undefined"; } private const string protocol = "https"; private const string url = "lethalapi.oualiyannick.fr"; private static string GetUrl(string endpoint) { return "https://lethalapi.oualiyannick.fr" + endpoint; } public static IEnumerator HealthCheck() { UnityWebRequest webRequest = UnityWebRequest.Get(GetUrl("/healthCheck")); try { yield return webRequest.SendWebRequest(); if ((int)webRequest.result != 1) { Debug.Log((object)("Error: " + webRequest.error)); } else { Debug.Log((object)("Response: " + webRequest.downloadHandler.text)); } } finally { ((IDisposable)webRequest)?.Dispose(); } } public static IEnumerator Report(string reportedSteamId, string reporterSteamId, string reportReason, Action onSuccess = null, Action<string> onFailure = null) { WWWForm val = new WWWForm(); val.AddField("reportedSteamId", reportedSteamId); val.AddField("reporterSteamId", reporterSteamId); val.AddField("reportReason", reportReason); UnityWebRequest webRequest = UnityWebRequest.Post(GetUrl("/lethalreportapi/report"), val); try { yield return webRequest.SendWebRequest(); if ((int)webRequest.result == 1) { Debug.Log((object)("Response: " + webRequest.downloadHandler.text)); onSuccess?.Invoke(); } else { Debug.Log((object)("Error: " + webRequest.error)); onFailure?.Invoke(webRequest.error); } } finally { ((IDisposable)webRequest)?.Dispose(); } } public static IEnumerator GetReportBySteamId(string steamId, OnReportReceived onReportReceived) { UnityWebRequest webRequest = UnityWebRequest.Get(GetUrl("/lethalreportapi/report/" + steamId)); try { yield return webRequest.SendWebRequest(); if ((int)webRequest.result != 1) { Debug.Log((object)("Error: " + webRequest.error)); onReportReceived?.Invoke(null, steamId); } else { string text = webRequest.downloadHandler.text; Debug.Log((object)("Response: " + text)); onReportReceived?.Invoke(text, steamId); } } finally { ((IDisposable)webRequest)?.Dispose(); } } public static IEnumerator CheckVersion(Action<string> onVersionReceived) { string text = GetUrl("/lethalreportapi/version"); Debug.Log((object)("Checking version at: " + text)); UnityWebRequest webRequest = UnityWebRequest.Get(text); try { yield return webRequest.SendWebRequest(); if ((int)webRequest.result != 1) { Debug.LogError((object)("Version check failed: " + webRequest.error)); yield break; } string text2 = webRequest.downloadHandler.text; Debug.Log((object)("Version check success: " + text2)); onVersionReceived?.Invoke(text2); } finally { ((IDisposable)webRequest)?.Dispose(); } } } internal class CoroutineHandler : MonoBehaviour { private static CoroutineHandler _instance; public static CoroutineHandler Instance { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance == (Object)null) { _instance = new GameObject("CoroutineHandler").AddComponent<CoroutineHandler>(); } return _instance; } } public void StartHelperCoroutine(IEnumerator coroutine) { ((MonoBehaviour)this).StartCoroutine(coroutine); } public void StopHelperCoroutine(IEnumerator coroutine) { ((MonoBehaviour)this).StopCoroutine(coroutine); } } internal class JsonParser { public static ReportData ParseReportData(string json) { ReportData reportData = new ReportData(); string[] array = json.Trim('{', '}').Split(new char[2] { ',', ':' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i += 2) { string text = array[i].Trim('"', ' '); string s = array[i + 1].Trim('"', ' '); switch (text) { case "totalReports": reportData.TotalReports = int.Parse(s); break; case "toxicReports": reportData.ToxicReports = int.Parse(s); break; case "cheatingReports": reportData.CheatReports = int.Parse(s); break; case "teamKillReports": reportData.TkReports = int.Parse(s); break; case "trollReports": reportData.CheatReports = int.Parse(s); break; case "undefinedReports": reportData.UndefinedReports = int.Parse(s); break; } } return reportData; } } public static class KickBanTools { public class PlayerInfo { public string Username; public string SteamID; public bool UsingWalkie; public bool Connected; public override string ToString() { return Username + " (" + SteamID + "@steam)"; } } private static readonly List<PlayerInfo> BannedUsers = new List<PlayerInfo>(); public static PlayerInfo[] GetBannedUsers() { return BannedUsers.ToArray(); } public static List<PlayerInfo> GetPlayers() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; SteamId localSteamID = GetLocalSteamID(); string currentSteamId = ((object)(SteamId)(ref localSteamID)).ToString(); List<PlayerInfo> list = (from playerInfo in allPlayerScripts.Select((PlayerControllerB player, int i) => new PlayerInfo { Username = player.playerUsername, SteamID = $"{player.playerSteamId}", UsingWalkie = player.speakingToWalkieTalkie, Connected = StartOfRound.Instance.fullyLoadedPlayers.Contains((ulong)i) }) where playerInfo.SteamID != "0" select playerInfo).ToList(); int num = list.FindIndex((PlayerInfo p) => p.SteamID == currentSteamId); if (num > -1) { PlayerInfo item = list[num]; list.RemoveAt(num); list.Insert(0, item); } return list; } public static void KickPlayer(PlayerInfo playerInfo) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; Debug.Log((object)"Kicking player... 1"); for (int i = 0; i < allPlayerScripts.Length; i++) { Debug.Log((object)$"Kicking player... ${i} ${allPlayerScripts[i].playerUsername}, ${allPlayerScripts[i].playerSteamId}"); Debug.Log((object)("$" + playerInfo.SteamID + " $" + playerInfo.Username)); PlayerControllerB val = allPlayerScripts[i]; if (!(val.playerUsername != playerInfo.Username) && !(val.playerSteamId.ToString() != playerInfo.SteamID)) { StartOfRound.Instance.KickPlayer(i); } } } public static bool ShouldKickPlayer(ReportData reportData, Dictionary<string, (int threshold, bool enabled)> reportThresholds) { if (reportThresholds.TryGetValue("Minimum Amount of Report", out (int, bool) value) && value.Item2 && reportData.TotalReports >= value.Item1) { return true; } if (reportThresholds.TryGetValue("Minimum Amount of Cheating Report", out (int, bool) value2) && value2.Item2 && reportData.CheatReports >= value2.Item1) { return true; } if (reportThresholds.TryGetValue("Minimum Amount of Toxic Report", out (int, bool) value3) && value3.Item2 && reportData.ToxicReports >= value3.Item1) { return true; } return false; } public static SteamId GetLocalSteamID() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (SteamClient.IsValid) { return SteamClient.SteamId; } Debug.LogError((object)"SteamClient is not valid."); return default(SteamId); } } [BepInPlugin("metasmash.LethalReport", "LethalReport", "1.0.0")] public class LethalReportBase : BaseUnityPlugin { private const string modGuid = "metasmash.LethalReport"; private const string modName = "LethalReport"; private const string modVersion = "1.0.0"; private ConfigEntry<int> _minReportThreshold; private ConfigEntry<int> _minCheatingReportThreshold; private ConfigEntry<int> _minToxicReportThreshold; private ConfigEntry<int> _minTkReportThreshold; private ConfigEntry<int> _minTrollReportThreshold; private ConfigEntry<bool> _autoKickOnReport; private ConfigEntry<bool> _enableReportThreshold; private ConfigEntry<bool> _enableCheatingReportThreshold; private ConfigEntry<bool> _enableToxicReportThreshold; private ConfigEntry<bool> _enableTkReportThreshold; private ConfigEntry<bool> _enableTrollReportThreshold; private readonly Harmony harmony = new Harmony("metasmash.LethalReport"); public static LethalReportBase Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)this); Debug.Log((object)"This is good"); return; } _minReportThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Minimum Amount of Report", 1, "Threshold for minimum amount of reports."); _minCheatingReportThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Minimum Amount of Cheating Report", 1, "Threshold for minimum amount of cheating reports."); _minToxicReportThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Minimum Amount of Toxic Report", 1, "Threshold for minimum amount of toxic reports."); _minTkReportThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Minimum Amount of Team Kill Report", 1, "Threshold for minimum amount of team kill reports."); _minTrollReportThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Minimum Amount of Troll Report", 1, "Threshold for minimum amount of troll reports."); _autoKickOnReport = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Auto Kick On Report", true, "Enable or disable auto-kick on report."); _enableReportThreshold = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable Minimum Amount of Report", true, "Enable or disable threshold for minimum amount of reports."); _enableCheatingReportThreshold = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable Minimum Amount of Cheating Report", true, "Enable or disable threshold for minimum amount of cheating reports."); _enableToxicReportThreshold = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable Minimum Amount of Toxic Report", true, "Enable or disable threshold for minimum amount of toxic reports."); _enableTkReportThreshold = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable Minimum Amount of Team Kill Report", true, "Enable or disable threshold for minimum amount of team kill reports."); _enableTrollReportThreshold = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable Minimum Amount of Troll Report", true, "Enable or disable threshold for minimum amount of troll reports."); Instance = this; Object.DontDestroyOnLoad((Object)(object)this); harmony.PatchAll(typeof(MenuPatch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalReport mod has been awakened"); CreateUIObject(); } public void UpdateSetting(string settingName, int threshold, bool enabled) { switch (settingName) { case "Minimum Amount of Report": _minReportThreshold.Value = threshold; _enableReportThreshold.Value = enabled; break; case "Minimum Amount of Cheating Report": _minCheatingReportThreshold.Value = threshold; _enableCheatingReportThreshold.Value = enabled; break; case "Minimum Amount of Toxic Report": _minToxicReportThreshold.Value = threshold; _enableToxicReportThreshold.Value = enabled; break; case "Minimum Amount of Team Kill Report": _minTkReportThreshold.Value = threshold; _enableTkReportThreshold.Value = enabled; break; case "Minimum Amount of Troll Report": _minTrollReportThreshold.Value = threshold; _enableTrollReportThreshold.Value = enabled; break; } ((BaseUnityPlugin)this).Config.Save(); } public void UpdateAutoKickSetting(bool value) { _autoKickOnReport.Value = value; ((BaseUnityPlugin)this).Config.Save(); } public Dictionary<string, (int threshold, bool enabled)> GetSettings() { return new Dictionary<string, (int, bool)> { { "Minimum Amount of Report", (_minReportThreshold.Value, true) }, { "Minimum Amount of Cheating Report", (_minCheatingReportThreshold.Value, true) }, { "Minimum Amount of Toxic Report", (_minToxicReportThreshold.Value, true) }, { "Minimum Amount of Team Kill Report", (_minTkReportThreshold.Value, true) }, { "Minimum Amount of Troll Report", (_minTrollReportThreshold.Value, true) } }; } public bool GetAutoKickSetting() { return _autoKickOnReport.Value; } public bool GetEnableReportThreshold() { return _enableReportThreshold.Value; } public bool GetEnableCheatingReportThreshold() { return _enableCheatingReportThreshold.Value; } public bool GetEnableToxicReportThreshold() { return _enableToxicReportThreshold.Value; } public bool GetEnableTkReportThreshold() { return _enableTkReportThreshold.Value; } public bool GetEnableTrollReportThreshold() { return _enableTrollReportThreshold.Value; } private void CreateUIObject() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown GameObject val = new GameObject("LethalReportUIGameObject"); val.AddComponent<UI>(); Object.DontDestroyOnLoad((Object)val); } } public class ReportData { public int TotalReports { get; set; } public int ToxicReports { get; set; } public int CheatReports { get; set; } public int TkReports { get; set; } public int TrollReports { get; set; } public int UndefinedReports { get; set; } public bool HasBeenReported { get; set; } public void IncrementCheatReport() { CheatReports++; } public void IncrementToxicReport() { ToxicReports++; } public void IncrementTkReport() { TkReports++; } public void IncrementTrollReport() { TrollReports++; } } public class UI : MonoBehaviour { public class PlayerInfoComparer : IEqualityComparer<KickBanTools.PlayerInfo> { public bool Equals(KickBanTools.PlayerInfo x, KickBanTools.PlayerInfo y) { return x.SteamID == y.SteamID; } public int GetHashCode(KickBanTools.PlayerInfo obj) { return obj.SteamID.GetHashCode(); } } private enum ViewMode { Users, Admin, Settings } private static readonly List<UI> Instances = new List<UI>(); private bool _menuOpen; private Rect _windowRect = new Rect(100f, 100f, 800f, 400f); private bool _initialized; private bool isVersionOutdated; private float _checkInterval = 5f; private float _nextCheckTime; private Dictionary<string, ReportData> _playerReports = new Dictionary<string, ReportData>(); private Dictionary<string, bool> _playerButtonStates = new Dictionary<string, bool>(); private List<KickBanTools.PlayerInfo> _lastKnownPlayers = new List<KickBanTools.PlayerInfo>(); private ViewMode _currentViewMode; private Dictionary<string, (int threshold, bool enabled)> _reportThresholds = new Dictionary<string, (int, bool)> { { "Minimum Amount of Report", (1, false) }, { "Minimum Amount of Cheating Report", (1, false) }, { "Minimum Amount of Toxic Report", (1, false) }, { "Minimum Amount of Team Kill Report", (1, false) }, { "Minimum Amount of Troll Report", (1, false) } }; private bool _autoKickOnReport = true; private GUIStyle buttonStyle; private GUIStyle labelStyle; private GUIStyle toggleStyle; private GUIStyle disabledButtonStyle; private void OnVersionCheckCompleted(string serverVersion) { if (string.IsNullOrEmpty(serverVersion)) { Debug.LogError((object)"Failed to retrieve version from server or the version is empty."); return; } serverVersion = serverVersion.Replace("\"", ""); isVersionOutdated = serverVersion != "1.0.0"; Debug.Log((object)"Checking..."); Debug.Log((object)(isVersionOutdated ? "Version is outdated" : "Version is up-to-date")); } private void Update() { if (Time.time >= _nextCheckTime) { CheckForNewPlayers(); _nextCheckTime = Time.time + _checkInterval; } } private void InitializeStyles() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown buttonStyle = new GUIStyle(GUI.skin.button); labelStyle = new GUIStyle(GUI.skin.label); toggleStyle = new GUIStyle(GUI.skin.toggle); disabledButtonStyle = new GUIStyle(GUI.skin.button); disabledButtonStyle.normal.textColor = Color.gray; buttonStyle.normal.textColor = Color.white; labelStyle.fontSize = 12; toggleStyle.margin = new RectOffset(5, 5, 5, 5); } private void Awake() { Instances.Add(this); LoadSettings(); ((MonoBehaviour)this).StartCoroutine(ApiClient.CheckVersion(OnVersionCheckCompleted)); Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } private void LoadSettings() { Dictionary<string, (int, bool)> settings = LethalReportBase.Instance.GetSettings(); _reportThresholds = new Dictionary<string, (int, bool)> { { "Minimum Amount of Report", (settings["Minimum Amount of Report"].Item1, LethalReportBase.Instance.GetEnableReportThreshold()) }, { "Minimum Amount of Cheating Report", (settings["Minimum Amount of Cheating Report"].Item1, LethalReportBase.Instance.GetEnableCheatingReportThreshold()) }, { "Minimum Amount of Toxic Report", (settings["Minimum Amount of Toxic Report"].Item1, LethalReportBase.Instance.GetEnableToxicReportThreshold()) }, { "Minimum Amount of Team Kill Report", (settings["Minimum Amount of Team Kill Report"].Item1, LethalReportBase.Instance.GetEnableTkReportThreshold()) }, { "Minimum Amount of Troll Report", (settings["Minimum Amount of Troll Report"].Item1, LethalReportBase.Instance.GetEnableTrollReportThreshold()) } }; _autoKickOnReport = LethalReportBase.Instance.GetAutoKickSetting(); } private void SaveSetting(string settingName, int threshold, bool enabled) { LethalReportBase.Instance.UpdateSetting(settingName, threshold, enabled); } private void SaveAutoKickSetting(bool value) { LethalReportBase.Instance.UpdateAutoKickSetting(value); } private void OnDestroy() { Instances.Remove(this); } public static void SetMenuForAll(bool value) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (Instances.Count == 0 && value) { new GameObject("Lethal Report Ui").AddComponent<UI>(); } foreach (UI instance in Instances) { instance.SetMenu(value); } } private void SetMenu(bool value) { Debug.Log((object)$"Setting menu: {value}"); _menuOpen = value; } private void OnGUI() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)StartOfRound.Instance).IsSpawned) { if (_initialized) { ResetStates(); } } else if (_menuOpen) { if (!_initialized) { _initialized = true; } _windowRect = GUILayout.Window(0, _windowRect, new WindowFunction(DrawUI), "Lethal Reporter Menu", Array.Empty<GUILayoutOption>()); if (isVersionOutdated) { Rect val = new Rect(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y - 20f, ((Rect)(ref _windowRect)).width, 20f); GUI.color = Color.yellow; GUI.Label(val, "A NEW VERSION IS AVAILABLE", new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4 }); GUI.color = Color.white; } } } private void DrawUI(int windowID) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_004b: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) if (buttonStyle == null) { InitializeStyles(); } GUIStyle val = new GUIStyle(GUI.skin.button) { fontSize = 10, alignment = (TextAnchor)4, padding = new RectOffset(0, 0, 0, 0), margin = new RectOffset(0, 0, 0, 0) }; float num = 18f; if (GUI.Button(new Rect(((Rect)(ref _windowRect)).width - num - 4f, 0f, num, num), "X", val)) { SetMenu(value: false); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Users", Array.Empty<GUILayoutOption>())) { _currentViewMode = ViewMode.Users; } if (GUILayout.Button("Admin tools", Array.Empty<GUILayoutOption>())) { _currentViewMode = ViewMode.Admin; } if (GUILayout.Button("Settings", Array.Empty<GUILayoutOption>())) { _currentViewMode = ViewMode.Settings; } GUILayout.EndHorizontal(); switch (_currentViewMode) { case ViewMode.Users: DrawUsersTab(); break; case ViewMode.Admin: DrawAdminTab(); break; case ViewMode.Settings: DrawSettingsTab(); break; default: DrawUsersTab(); break; } GUILayout.BeginArea(new Rect(((Rect)(ref _windowRect)).width - 200f, ((Rect)(ref _windowRect)).height - 50f, 180f, 40f)); if (GUILayout.Button("[FR] Join us on Discord!", Array.Empty<GUILayoutOption>())) { OpenURL("https://discord.gg/lethalcompanyfr"); } GUILayout.EndArea(); GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f)); } private void DrawUsersTab() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) List<KickBanTools.PlayerInfo> players = KickBanTools.GetPlayers(); KickBanTools.PlayerInfo playerInfo = ((players.Count > 0) ? players[0] : null); foreach (KickBanTools.PlayerInfo item in players) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); ReportData value; bool flag = _playerReports.TryGetValue(item.SteamID, out value) && value.HasBeenReported; labelStyle.normal.textColor = (flag ? Color.red : Color.white); GUILayout.Label($"{item}", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) }); bool isEnabled = !flag || (_playerButtonStates.ContainsKey(item.SteamID) && _playerButtonStates[item.SteamID]); if (value != null && item != playerInfo) { DrawCustomReportButton("CHEAT", value.CheatReports, item, playerInfo, ApiClient.ReportReason.Cheat, isEnabled, buttonStyle); DrawCustomReportButton("TOXIC", value.ToxicReports, item, playerInfo, ApiClient.ReportReason.Toxic, isEnabled, buttonStyle); DrawCustomReportButton("TEAM KILL", value.TkReports, item, playerInfo, ApiClient.ReportReason.TeamKill, isEnabled, buttonStyle); DrawCustomReportButton("TROLL", value.TrollReports, item, playerInfo, ApiClient.ReportReason.Troll, isEnabled, buttonStyle); } GUILayout.EndHorizontal(); } } private void DrawAdminTab() { if (GUILayout.Button("Ship Light", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(100f), GUILayout.Height(100f) })) { StartOfRound.Instance.shipRoomLights.ToggleShipLights(); } } private void DrawSettingsTab() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown GUIStyle val = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)1, fontSize = 14, alignment = (TextAnchor)1 }; GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label("Adjust the report thresholds and auto-kick settings:", val, Array.Empty<GUILayoutOption>()); foreach (string item in _reportThresholds.Keys.ToList()) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); (int, bool) tuple = _reportThresholds[item]; bool flag = GUILayout.Toggle(tuple.Item2, "", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); GUILayout.Label(item, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) }); int num = (int)GUILayout.HorizontalSlider((float)tuple.Item1, 1f, 100f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.Label(num.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (flag != tuple.Item2 || num != tuple.Item1) { _reportThresholds[item] = (num, flag); SaveSetting(item, num, flag); } GUILayout.EndHorizontal(); } bool flag2 = GUILayout.Toggle(_autoKickOnReport, "Auto kick if reported", Array.Empty<GUILayoutOption>()); if (flag2 != _autoKickOnReport) { _autoKickOnReport = flag2; LethalReportBase.Instance.UpdateAutoKickSetting(_autoKickOnReport); } GUILayout.EndVertical(); } private void DrawCustomReportButton(string label, int reportCount, KickBanTools.PlayerInfo player, KickBanTools.PlayerInfo currentPlayer, string reportType, bool isEnabled, GUIStyle buttonStyle) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); GUIStyle val = new GUIStyle(GUI.skin.label); val.fontStyle = (FontStyle)1; val.normal.textColor = Color.white; GUILayout.Label(reportCount.ToString(), val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); bool flag = isEnabled && (!_playerButtonStates.ContainsKey(player.SteamID) || _playerButtonStates[player.SteamID]); if (GUILayout.Button("", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(20f), GUILayout.Height(20f) }) && flag) { ((MonoBehaviour)this).StartCoroutine(ApiClient.Report(player.SteamID, currentPlayer.SteamID, reportType, delegate { if (reportType == ApiClient.ReportReason.Cheat) { _playerReports[player.SteamID].IncrementCheatReport(); } else if (reportType == ApiClient.ReportReason.Toxic) { _playerReports[player.SteamID].IncrementToxicReport(); } else if (reportType == ApiClient.ReportReason.TeamKill) { _playerReports[player.SteamID].IncrementTkReport(); } else if (reportType == ApiClient.ReportReason.Troll) { _playerReports[player.SteamID].IncrementTrollReport(); } _playerButtonStates[player.SteamID] = false; _playerReports[player.SteamID].HasBeenReported = true; if (_autoKickOnReport) { KickBanTools.KickPlayer(player); } })); } GUILayout.EndHorizontal(); } private void CheckForNewPlayers() { List<KickBanTools.PlayerInfo> players = KickBanTools.GetPlayers(); List<KickBanTools.PlayerInfo> list = players.Except(_lastKnownPlayers, new PlayerInfoComparer()).ToList(); if (list.Count <= 0) { return; } Debug.Log((object)("New players detected: " + list.Count)); foreach (KickBanTools.PlayerInfo item in list) { ((MonoBehaviour)this).StartCoroutine(ApiClient.GetReportBySteamId(item.SteamID ?? "", ProcessPlayerReport)); } _lastKnownPlayers = players; } private void ProcessPlayerReport(string jsonReport, string steamId) { if (!string.IsNullOrEmpty(jsonReport)) { ReportData reportData = JsonParser.ParseReportData(jsonReport); _playerReports[steamId] = reportData; Debug.Log((object)("Report data updated for player: " + steamId)); if (KickBanTools.ShouldKickPlayer(reportData, _reportThresholds)) { KickBanTools.PlayerInfo playerInfo = KickBanTools.GetPlayers().FirstOrDefault((KickBanTools.PlayerInfo p) => p.SteamID == steamId); if (playerInfo != null) { KickBanTools.KickPlayer(playerInfo); } } } else { Debug.Log((object)("No report received or an error occurred for player: " + steamId)); } } private void ResetStates() { _playerReports.Clear(); _playerButtonStates.Clear(); _lastKnownPlayers.Clear(); _menuOpen = false; _initialized = false; Debug.Log((object)"States have been reset"); } private void OpenURL(string url) { Application.OpenURL(url); } } } namespace LethalReport.Patches { [HarmonyPatch(typeof(QuickMenuManager))] public class MenuPatch { [HarmonyPatch("OpenQuickMenu")] [HarmonyPostfix] public static void OnOpenMenu() { UI.SetMenuForAll(value: true); } [HarmonyPatch("CloseQuickMenu")] [HarmonyPostfix] public static void OnCloseMenu() { UI.SetMenuForAll(value: false); } } }