using System;
using System.Collections;
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 System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;
using Zorro.Core;
using Zorro.Core.Serizalization;
[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.MyBackpackAlert")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.6.0")]
[assembly: AssemblyInformationalVersion("0.1.6")]
[assembly: AssemblyProduct("my.pahsiv.MyBackpackAlert")]
[assembly: AssemblyTitle("MyBackpackAlert")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.6.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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]
[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 MyBackpackAlert
{
public static class ColorHelper
{
public const string White = "FFFFFF";
public const string Black = "000000";
public const string Red = "FF0000";
public const string Green = "00FF00";
public const string Blue = "0000FF";
public const string Yellow = "FFFF00";
public const string Purple = "8765CA";
public const string Gray = "808080";
public const string Orange = "FFA500";
public const string Cyan = "00FFFF";
public const string Magenta = "FF00FF";
public const string Pink = "FFC0CB";
public const string Brown = "A52A2A";
public const string Lime = "00FF00";
public const string Teal = "008080";
public const string Navy = "000080";
public const string Maroon = "800000";
public const string Olive = "808000";
public const string Aqua = "00FFFF";
public const string Silver = "C0C0C0";
public const string Gold = "FFD700";
public const string LightRed = "FF6B6B";
public const string LightGreen = "90EE90";
public const string LightBlue = "ADD8E6";
public const string LightGray = "D3D3D3";
public const string LightPink = "FFB6C1";
public const string DarkRed = "8B0000";
public const string DarkGreen = "006400";
public const string DarkBlue = "00008B";
public const string DarkGray = "A9A9A9";
public const string DarkOrange = "FF8C00";
public const string Pahsiv = "3582E7";
}
internal class EventAlert
{
private static bool PreOnEvent(EventData photonEvent)
{
if (!Plugin.EnableOwnershipAlert.Value)
{
return true;
}
return photonEvent.Code switch
{
204 => HandleDestroyEvent(photonEvent),
209 => HandleOwnershipRequestEvent(photonEvent),
210 => HandleOwnershipTransferEvent(photonEvent),
_ => true,
};
}
private static bool HandleDestroyEvent(EventData photonEvent)
{
try
{
object customData = photonEvent.CustomData;
Hashtable val = (Hashtable)((customData is Hashtable) ? customData : null);
if (val != null)
{
int num = (int)val[(byte)0];
PhotonView val2 = PhotonView.Find(num);
int sender = photonEvent.Sender;
Room currentRoom = PhotonNetwork.CurrentRoom;
Player val3 = ((currentRoom != null) ? currentRoom.GetPlayer(sender, false) : null);
if ((Object)(object)val2 != (Object)null && val2.Owner != null)
{
Player owner = val2.Owner;
if (val3 != null && !val3.IsMasterClient)
{
if ((Object)(object)((Component)val2).GetComponent<Character>() != (Object)null)
{
Plugin.Notification(Plugin.AddColor("[CHARACTER DESTROY (204)]", "FF0000") + " " + Plugin.AddColor(((val3 != null) ? val3.NickName : null) ?? $"Actor {sender})", "00FFFF") + " tried to destroy " + Plugin.AddColor(((owner != null) ? owner.NickName : null) ?? "your", "00FFFF") + "'s character!", "FFFF00", sound: true);
Plugin.Log.LogFatal((object)$"Character Destroy Request (204) | ViewID: {num}, Attacker: {sender}");
return false;
}
if ((Object)(object)((Component)val2).GetComponent<Player>() != (Object)null)
{
Plugin.Notification(Plugin.AddColor("[PLAYER DESTROY (204)]", "FF0000") + " " + Plugin.AddColor(((val3 != null) ? val3.NickName : null) ?? $"Actor {sender})", "00FFFF") + " tried to destroy " + Plugin.AddColor(((owner != null) ? owner.NickName : null) ?? "your", "00FFFF") + "'s player object!", "FFFF00", sound: true);
Plugin.Log.LogFatal((object)$"Player Destroy Request (204) | ViewID: {num}, Attacker: {sender}");
return false;
}
}
}
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Error in HandleDestroyEvent: {arg}");
return false;
}
return true;
}
private static bool HandleOwnershipRequestEvent(EventData photonEvent)
{
try
{
if (photonEvent.CustomData is int[] array)
{
int sender = photonEvent.Sender;
int[] array2 = array;
foreach (int num in array2)
{
PhotonView val = PhotonView.Find(num);
if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent<Character>() != (Object)null && val.OwnerActorNr != sender)
{
Room currentRoom = PhotonNetwork.CurrentRoom;
Player val2 = ((currentRoom != null) ? currentRoom.GetPlayer(sender, false) : null);
Player owner = val.Owner;
Plugin.Notification(Plugin.AddColor("[OWNERSHIP REQUEST (209)]", "FF0000") + " " + Plugin.AddColor(((val2 != null) ? val2.NickName : null) ?? $"Actor {sender})", "00FFFF") + " requested ownership of " + Plugin.AddColor(((owner != null) ? owner.NickName : null) ?? "your", "00FFFF") + "'s character!", "FFFF00", sound: true);
Plugin.Log.LogFatal((object)$"Character Ownership Request (209) | ViewID: {num}, Owner: {val.OwnerActorNr}, Requester: {sender}");
return false;
}
}
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Error in HandleOwnershipRequestEvent: {arg}");
}
return true;
}
private static bool HandleOwnershipTransferEvent(EventData photonEvent)
{
try
{
if (!(photonEvent.CustomData is int[] array))
{
return false;
}
int num = array[0];
int num2 = array[1];
int sender = photonEvent.Sender;
Room currentRoom = PhotonNetwork.CurrentRoom;
Player val = ((currentRoom != null) ? currentRoom.GetPlayer(sender, false) : null);
PhotonView val2 = PhotonView.Find(num);
if ((Object)(object)val2 != (Object)null && val2.Owner != null)
{
Player owner = val2.Owner;
if (val != null && !val.IsMasterClient && (Object)(object)((Component)val2).GetComponent<Character>() != (Object)null)
{
Plugin.Notification(Plugin.AddColor("[OWNERSHIP THEFT (210)]", "FF0000") + " " + Plugin.AddColor(((val != null) ? val.NickName : null) ?? $"Actor {sender})", "00FFFF") + " tried to steal ownership of " + Plugin.AddColor(((owner != null) ? owner.NickName : null) ?? "your", "00FFFF") + "'s character!", "FFFF00", sound: true);
Plugin.Log.LogWarning((object)$"Character Ownership Theft (210) | ViewID: {num}, Sender: {sender}, NewOwner: {num2}");
return false;
}
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Error in HandleOwnershipTransferEvent: {arg}");
return false;
}
return true;
}
}
internal class Patch
{
[HarmonyPatch(typeof(Player), "SyncInventoryRPC")]
public class SyncInventoryRPC_Patch
{
private static Dictionary<Player, Queue<float>> NotificationTimes = new Dictionary<Player, Queue<float>>();
private static int MaxNotifications = 5;
private static float NotificationTimeWindow = 20f;
[HarmonyPostfix]
public static void Postfix(Player __instance, byte[] data, bool forceSync)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.EnableBackpackAlert.Value)
{
return;
}
try
{
if ((Object)(object)__instance.character == (Object)(object)Character.localCharacter || !Plugin.RegisterBackpack.HasValue)
{
return;
}
string text = ((Object)__instance).name.Replace("Player: ", "");
if (data != null && data.Length != 0)
{
InventorySyncData fromManagedArray = IBinarySerializable.GetFromManagedArray<InventorySyncData>(data);
if (fromManagedArray.tempSlot.ItemID != ushort.MaxValue && fromManagedArray.tempSlot.Data != null)
{
string itemName = GetItemName(fromManagedArray.tempSlot.ItemID);
if (Plugin.RegisterItem.ContainsKey(fromManagedArray.tempSlot.Data.guid))
{
if (CanShowNotification(__instance))
{
if (Plugin.WarnList.Contains(__instance))
{
Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has a backpack with the same BackpackReference as yours!", "FFFF00");
}
Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has taken the " + Plugin.AddColor(itemName, "00FFFF") + " from your backpack!", "FFFFFF", sound: true);
}
return;
}
}
for (int i = 0; i < fromManagedArray.slots.Length; i++)
{
SlotData val = fromManagedArray.slots[i];
if (val.ItemID == ushort.MaxValue)
{
continue;
}
string itemName2 = GetItemName(val.ItemID);
if (val.Data != null && Plugin.RegisterItem.ContainsKey(val.Data.guid))
{
if (!CanShowNotification(__instance))
{
break;
}
if (Plugin.WarnList.Contains(__instance))
{
Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has a backpack with the same BackpackReference as yours!", "FFFF00");
}
Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has taken the " + Plugin.AddColor(itemName2, "00FFFF") + " from your backpack!", "FFFFFF", sound: true);
}
}
}
else
{
Plugin.Log.LogMessage((object)"Data is null or empty");
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Error in SyncInventoryRPC_Patch: {arg}");
}
}
private static bool CanShowNotification(Player player)
{
float time = Time.time;
if (!NotificationTimes.ContainsKey(player))
{
NotificationTimes[player] = new Queue<float>();
}
Queue<float> queue = NotificationTimes[player];
while (queue.Count > 0 && time - queue.Peek() >= NotificationTimeWindow)
{
queue.Dequeue();
}
if (queue.Count < MaxNotifications)
{
queue.Enqueue(time);
return true;
}
return false;
}
}
[HarmonyPatch(typeof(Item), "Interact")]
public class InteractPatch
{
[HarmonyPostfix]
public static void Postfix(Item __instance, Character interactor)
{
if ((Object)(object)__instance != (Object)null && __instance.data != null)
{
_ = __instance.data.guid;
Guid guid = __instance.data.guid;
if (Plugin.RegisterItem.ContainsKey(guid))
{
int num = Plugin.RegisterItem[guid];
Plugin.Log.LogMessage((object)$" Remove Item : [Slot {num}] {((Object)__instance).name} | {guid}");
Plugin.RegisterItem.Remove(guid);
}
}
}
}
[HarmonyPatch(typeof(Item), "PutInBackpackRPC")]
public class PutInBackpackRPCPatch
{
[HarmonyPostfix]
public static void Postfix(Item __instance, byte slotID, ref BackpackReference backpackReference)
{
ItemInstanceData itemInstanceData = ((BackpackReference)(ref backpackReference)).GetItemInstanceData();
Guid guid = itemInstanceData.guid;
Guid? registerBackpack = Plugin.RegisterBackpack;
if (!(guid == registerBackpack))
{
return;
}
Plugin.RegisterItem.Clear();
BackpackData data = ((BackpackReference)(ref backpackReference)).GetData();
for (int i = 0; i < data.itemSlots.Length; i++)
{
if (!data.itemSlots[i].IsEmpty())
{
Guid guid2 = data.itemSlots[i].data.guid;
if (!Plugin.RegisterItem.ContainsKey(guid2))
{
Plugin.Log.LogMessage((object)$" Add Item : [Slot {i}] {((Object)data.itemSlots[i].prefab).name} | {guid2}");
Plugin.RegisterItem.Add(guid2, i);
}
}
}
}
}
[HarmonyPatch(typeof(BackpackWheel), "Choose")]
public class ChoosePatch
{
[HarmonyPostfix]
public static void Postfix(BackpackWheel __instance)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.chosenSlice.IsSome || !__instance.chosenSlice.Value.isBackpackWear)
{
return;
}
SliceData value = __instance.chosenSlice.Value;
Backpack val = default(Backpack);
if (!((BackpackReference)(ref value.backpackReference)).TryGetBackpackItem(ref val))
{
return;
}
Plugin.Log.LogMessage((object)$" Picking up backpack : {((Item)val).data.guid}");
Plugin.RegisterBackpack = ((Item)val).data.guid;
Plugin.Log.LogMessage((object)" Clearing backpack item!");
Plugin.RegisterItem.Clear();
EmptySlotPatch.CancelBackpackRemoval(((Item)val).data.guid);
BackpackData data = ((Item)val).GetData<BackpackData>((DataEntryKey)7);
for (int i = 0; i < data.itemSlots.Length; i++)
{
if (!data.itemSlots[i].IsEmpty())
{
Guid guid = data.itemSlots[i].data.guid;
if (!Plugin.RegisterItem.ContainsKey(guid))
{
Plugin.Log.LogMessage((object)$" Add Item : [Slot {i}] {((Object)data.itemSlots[i].prefab).name} | {guid}");
Plugin.RegisterItem.Add(guid, i);
}
}
}
Plugin.BackpackReferenceCheck();
}
}
[HarmonyPatch(typeof(BackpackWheel), "TryStash")]
public class TryStashPatch
{
[HarmonyPrefix]
public static void Prefix(BackpackWheel __instance, byte backpackSlotID)
{
Backpack component = ((Component)__instance.backpack.view).GetComponent<Backpack>();
Guid guid;
Guid? registerBackpack;
if ((Object)(object)component != (Object)null)
{
if (!Plugin.RegisterBackpack.HasValue)
{
return;
}
guid = ((Item)component).data.guid;
registerBackpack = Plugin.RegisterBackpack;
if (guid == registerBackpack)
{
Item currentItem = Character.localCharacter.data.currentItem;
Guid guid2 = currentItem.data.guid;
if (!Plugin.RegisterItem.ContainsKey(guid2))
{
Plugin.Log.LogMessage((object)$" Add Item : [Slot {backpackSlotID}] {((Object)currentItem).name} | {guid2}");
Plugin.RegisterItem.Add(guid2, backpackSlotID);
}
}
return;
}
guid = ((ItemSlot)((Component)__instance.backpack.view).GetComponent<CharacterBackpackHandler>().character.player.backpackSlot).data.guid;
registerBackpack = Plugin.RegisterBackpack;
if (guid == registerBackpack)
{
Item currentItem2 = Character.localCharacter.data.currentItem;
Guid guid3 = currentItem2.data.guid;
if (!Plugin.RegisterItem.ContainsKey(guid3))
{
Plugin.Log.LogMessage((object)$" Add Item : [Slot {backpackSlotID}] {((Object)currentItem2).name} | {guid3}");
Plugin.RegisterItem.Add(guid3, backpackSlotID);
}
}
}
}
[HarmonyPatch(typeof(Player), "EmptySlot")]
public class EmptySlotPatch
{
private static Dictionary<Guid, Coroutine> pendingRemovals = new Dictionary<Guid, Coroutine>();
private static MonoBehaviour coroutineRunner;
[HarmonyPostfix]
public static void Postfix(Player __instance, ref Optionable<byte> slot)
{
if ((Object)(object)coroutineRunner == (Object)null)
{
coroutineRunner = (MonoBehaviour)(object)__instance;
}
if (slot.IsNone)
{
return;
}
byte value = slot.Value;
ItemSlot itemSlot = __instance.GetItemSlot(value);
if (itemSlot != null && Plugin.RegisterBackpack.HasValue)
{
Guid guid = itemSlot.data.guid;
Guid? registerBackpack = Plugin.RegisterBackpack;
if (registerBackpack.HasValue && guid == registerBackpack.GetValueOrDefault() && Plugin.RegisterBackpack.HasValue)
{
Plugin.Log.LogMessage((object)$"Backpack dropped: {Plugin.RegisterBackpack}. Will unregister in {Plugin.unregisterTime} seconds.");
Guid value2 = Plugin.RegisterBackpack.Value;
CancelPendingRemoval(value2);
Coroutine value3 = coroutineRunner.StartCoroutine(DelayedBackpackRemoval(value2));
pendingRemovals[value2] = value3;
}
}
}
public static void CancelBackpackRemoval(Guid backpackGuid)
{
if (CancelPendingRemoval(backpackGuid))
{
Plugin.Log.LogMessage((object)$"Cancelled backpack removal for: {backpackGuid}");
}
}
private static bool CancelPendingRemoval(Guid backpackGuid)
{
if (pendingRemovals.ContainsKey(backpackGuid))
{
if ((Object)(object)coroutineRunner != (Object)null)
{
coroutineRunner.StopCoroutine(pendingRemovals[backpackGuid]);
}
pendingRemovals.Remove(backpackGuid);
return true;
}
return false;
}
private static IEnumerator DelayedBackpackRemoval(Guid backpackGuid)
{
float startTime = Time.time;
yield return (object)new WaitForSeconds(Plugin.unregisterTime);
Plugin.Log.LogMessage((object)$"Time passed (actual: {Time.time - startTime:F2}s). Unregistering backpack: {backpackGuid}");
if (Plugin.RegisterBackpack == backpackGuid)
{
Plugin.RegisterBackpack = null;
Plugin.Log.LogMessage((object)" Clearing backpack item!");
Plugin.RegisterItem.Clear();
Plugin.Log.LogMessage((object)"Backpack successfully unregistered");
}
else
{
Plugin.Log.LogMessage((object)"Backpack was already changed, skipping unregister");
}
pendingRemovals.Remove(backpackGuid);
}
}
[HarmonyPatch(typeof(Player), "AddItem")]
public class AddItemPatch
{
private static Dictionary<Player, Queue<float>> NotificationTimes = new Dictionary<Player, Queue<float>>();
private static int MaxNotifications = 5;
private static float NotificationTimeWindow = 20f;
[HarmonyPostfix]
public static void Postfix(Player __instance, ushort itemID, ItemInstanceData instanceData, bool __result, ref ItemSlot slot)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.EnableBackpackAlert.Value || !PhotonNetwork.IsMasterClient || (Object)(object)__instance.character == (Object)(object)Character.localCharacter)
{
return;
}
string text = ((Object)__instance).name.Replace("Player: ", "");
InventorySyncData val = default(InventorySyncData);
((InventorySyncData)(ref val))..ctor(__instance.itemSlots, __instance.backpackSlot, __instance.tempFullSlot);
if (val.tempSlot.ItemID != ushort.MaxValue && val.tempSlot.Data != null)
{
string itemName = GetItemName(val.tempSlot.ItemID);
if (Plugin.RegisterItem.ContainsKey(val.tempSlot.Data.guid))
{
if (CanShowNotification(__instance))
{
if (Plugin.WarnList.Contains(__instance))
{
Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has a \"linked\" backpack with yours!", "FFFF00");
}
Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has taken the " + Plugin.AddColor(itemName, "00FFFF") + " from your backpack!", "FFFFFF", sound: true);
}
return;
}
}
for (int i = 0; i < val.slots.Length; i++)
{
SlotData val2 = val.slots[i];
if (val2.ItemID == ushort.MaxValue)
{
continue;
}
string itemName2 = GetItemName(val2.ItemID);
if (val2.Data != null && Plugin.RegisterItem.ContainsKey(val2.Data.guid))
{
if (!CanShowNotification(__instance))
{
break;
}
if (Plugin.WarnList.Contains(__instance))
{
Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has a \"linked\" backpack with yours!", "FFFF00");
}
Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has taken the " + Plugin.AddColor(itemName2, "00FFFF") + " from your backpack!", "FFFFFF", sound: true);
}
}
}
private static bool CanShowNotification(Player player)
{
float time = Time.time;
if (!NotificationTimes.ContainsKey(player))
{
NotificationTimes[player] = new Queue<float>();
}
Queue<float> queue = NotificationTimes[player];
while (queue.Count > 0 && time - queue.Peek() >= NotificationTimeWindow)
{
queue.Dequeue();
}
if (queue.Count < MaxNotifications)
{
queue.Enqueue(time);
return true;
}
return false;
}
}
public static string GetItemName(ushort itemID)
{
Item val = default(Item);
if (ItemDatabase.TryGetItem(itemID, ref val))
{
return ((Object)val).name ?? "Unknown";
}
return "Not Found";
}
}
[BepInPlugin("my.pahsiv.MyBackpackAlert", "MyBackpackAlert", "0.1.6")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource Log = null;
public static Guid? RegisterBackpack;
public static Dictionary<Guid, int> RegisterItem = new Dictionary<Guid, int>();
public static float unregisterTime = 30f;
private Coroutine backpackCheckCoroutine;
public static ConfigEntry<bool> EnableBackpackAlert;
public static ConfigEntry<bool> EnableBlowgunAlert;
public static ConfigEntry<bool> EnableExplosionAlert;
public static ConfigEntry<bool> BlockExplosion;
public static ConfigEntry<bool> EnableBeeAlert;
public static ConfigEntry<bool> EnableJumpAlert;
public static ConfigEntry<bool> EnableCrouchAlert;
public static ConfigEntry<bool> EnablePassoutAlert;
public static ConfigEntry<bool> EnableEmoteAlert;
public static ConfigEntry<bool> EnableDropItemAlert;
public static ConfigEntry<bool> EnableRemoveItemAlert;
public static ConfigEntry<bool> EnableOwnershipAlert;
public static HashSet<Player> WarnList = new HashSet<Player>();
public const string Id = "my.pahsiv.MyBackpackAlert";
internal static Plugin Instance { get; private set; } = null;
public static string Name => "MyBackpackAlert";
public static string Version => "0.1.6";
public Plugin()
{
Log = ((BaseUnityPlugin)this).Logger;
}
private void Awake()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
Instance = this;
Harmony val = new Harmony("my.pahsiv.MyBackpackAlert");
val.PatchAll();
OnEventPatch(val);
BindConfig();
SceneManager.sceneLoaded += OnSceneLoaded;
Log.LogMessage((object)(" Plugin " + Name + " is loaded!"));
}
private void BindConfig()
{
EnableBackpackAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Backpack Alert", true, "Enable or disable alerts for Backpack.");
EnableBlowgunAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Blowgun Alert", true, "Enable or disable alerts for Blowgun.");
EnableExplosionAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Explosion Alert", true, "Enable or disable alerts for Explosion Spawn.");
BlockExplosion = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Auto block Malicious Explosion", false, "Enable or disable blocking for Malicious Explosion.");
EnableBeeAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Bee Alert", true, "Enable or disable alerts for Forcing Bee.");
EnableJumpAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Jump Alert", true, "Enable or disable alerts for Forcing Jump.");
EnableCrouchAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Crouch Alert", true, "Enable or disable alerts for Forcing Crouch.");
EnablePassoutAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Pass Out Alert", true, "Enable or disable alerts for Forcing Pass Out.");
EnableEmoteAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Emote Alert", true, "Enable or disable alerts for Forcing Emote.");
EnableDropItemAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Drop Item Alert", true, "Enable or disable alerts for Forcing Item Drop.");
EnableRemoveItemAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Remove Item Alert", true, "Enable or disable alerts for Removing Item.");
EnableOwnershipAlert = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Ownership Alert", true, "Enable or disable alerts for Ownership Thief.");
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (((Scene)(ref scene)).name == "Airport")
{
StopBackpackCheck();
RegisterBackpack = null;
RegisterItem.Clear();
}
else if (((Scene)(ref scene)).name.Contains("Level_"))
{
StartBackpackCheck();
}
else if (((Scene)(ref scene)).name.Contains("Title"))
{
StopBackpackCheck();
RegisterBackpack = null;
RegisterItem.Clear();
}
}
public void StartBackpackCheck()
{
Log.LogMessage((object)"Backpack check coroutine started.");
backpackCheckCoroutine = ((MonoBehaviour)this).StartCoroutine(CheckBackpackRoutine());
}
public void StopBackpackCheck()
{
if (backpackCheckCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(backpackCheckCoroutine);
backpackCheckCoroutine = null;
Log.LogMessage((object)"Backpack check coroutine stopped.");
}
}
private IEnumerator CheckBackpackRoutine()
{
yield return (object)new WaitForSeconds(5f);
PerformBackpackCheck();
while (true)
{
yield return (object)new WaitForSeconds(20f);
if ((Object)(object)this == (Object)null)
{
break;
}
PerformBackpackCheck();
BackpackReferenceCheck();
}
}
private void PerformBackpackCheck()
{
//IL_013b: 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_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)Character.localCharacter == (Object)null)
{
Log.LogMessage((object)"Error: Character.localCharacter is null in PerformBackpackCheck()");
}
else if ((Object)(object)Character.localCharacter.player == (Object)null)
{
Log.LogMessage((object)"Error: Character.localCharacter.player is null in PerformBackpackCheck()");
}
else if (Character.localCharacter.player.backpackSlot == null)
{
Log.LogMessage((object)"Error: backpackSlot is null in PerformBackpackCheck()");
}
else
{
if (Character.localCharacter.data.isCarried || Character.localCharacter.data.passedOut || Character.localCharacter.data.fullyPassedOut || Character.localCharacter.data.dead)
{
return;
}
if (!RegisterBackpack.HasValue)
{
if (!Character.localCharacter.player.backpackSlot.hasBackpack)
{
return;
}
Guid? guid = ((ItemSlot)Character.localCharacter.player.backpackSlot).data.guid;
Log.LogFatal((object)$" Forceful Backpack Inject! : {guid}");
Log.LogMessage((object)" Clearing backpack item!");
RegisterItem.Clear();
RegisterBackpack = guid;
BackpackReference fromEquippedBackpack = BackpackReference.GetFromEquippedBackpack(Character.localCharacter);
if ((Object)(object)fromEquippedBackpack.view == (Object)null)
{
Log.LogMessage((object)"Error: BackpackReference.view is null in PerformBackpackCheck()");
return;
}
BackpackData data = ((BackpackReference)(ref fromEquippedBackpack)).GetData();
if (data == null)
{
Log.LogMessage((object)"Error: BackpackData is null in PerformBackpackCheck()");
return;
}
if (data.itemSlots == null)
{
Log.LogMessage((object)"Error: itemSlots array is null in PerformBackpackCheck()");
return;
}
for (int i = 0; i < data.itemSlots.Length; i++)
{
if (!data.itemSlots[i].IsEmpty())
{
Guid guid2 = data.itemSlots[i].data.guid;
if (!RegisterItem.ContainsKey(guid2))
{
Log.LogMessage((object)$" Add Item : [Slot {i}] {((Object)data.itemSlots[i].prefab).name} | {guid2}");
RegisterItem.Add(guid2, i);
}
}
}
}
else
{
if (!Character.localCharacter.player.backpackSlot.hasBackpack)
{
return;
}
Guid? guid3 = ((ItemSlot)Character.localCharacter.player.backpackSlot).data.guid;
if (!(RegisterBackpack != guid3))
{
return;
}
Log.LogFatal((object)$" Backpack Mismatch! : {RegisterBackpack} != {guid3}");
Log.LogMessage((object)" Clearing backpack item!");
RegisterItem.Clear();
RegisterBackpack = guid3;
BackpackReference fromEquippedBackpack2 = BackpackReference.GetFromEquippedBackpack(Character.localCharacter);
if ((Object)(object)fromEquippedBackpack2.view == (Object)null)
{
Log.LogMessage((object)"Error: BackpackReference.view is null in PerformBackpackCheck()");
return;
}
BackpackData data2 = ((BackpackReference)(ref fromEquippedBackpack2)).GetData();
if (data2 == null)
{
Log.LogMessage((object)"Error: BackpackData is null in PerformBackpackCheck()");
return;
}
if (data2.itemSlots == null)
{
Log.LogMessage((object)"Error: itemSlots array is null in PerformBackpackCheck()");
return;
}
for (int j = 0; j < data2.itemSlots.Length; j++)
{
if (!data2.itemSlots[j].IsEmpty())
{
Guid guid4 = data2.itemSlots[j].data.guid;
if (!RegisterItem.ContainsKey(guid4))
{
Log.LogMessage((object)$" Add Item : [Slot {j}] {((Object)data2.itemSlots[j].prefab).name} | {guid4}");
RegisterItem.Add(guid4, j);
}
}
}
}
}
}
catch (Exception ex)
{
Log.LogMessage((object)("Exception in PerformBackpackCheck(): " + ex.Message + "\n" + ex.StackTrace));
}
}
public static IEnumerator CheckBackpack()
{
yield return (object)new WaitForSeconds(5f);
try
{
if ((Object)(object)Character.localCharacter == (Object)null)
{
Log.LogMessage((object)"Error: Character.localCharacter is null in CheckBackpack()");
}
else if ((Object)(object)Character.localCharacter.player == (Object)null)
{
Log.LogMessage((object)"Error: Character.localCharacter.player is null in CheckBackpack()");
}
else if (Character.localCharacter.player.backpackSlot == null)
{
Log.LogMessage((object)"Error: backpackSlot is null in CheckBackpack()");
}
else
{
if (!Character.localCharacter.player.backpackSlot.hasBackpack)
{
yield break;
}
RegisterBackpack = ((ItemSlot)Character.localCharacter.player.backpackSlot).data.guid;
Log.LogMessage((object)$"Picking up backpack: {RegisterBackpack}");
BackpackReference fromEquippedBackpack = BackpackReference.GetFromEquippedBackpack(Character.localCharacter);
if ((Object)(object)fromEquippedBackpack.view == (Object)null)
{
Log.LogMessage((object)"Error: BackpackReference.view is null in CheckBackpack()");
yield break;
}
BackpackData data = ((BackpackReference)(ref fromEquippedBackpack)).GetData();
if (data == null)
{
Log.LogMessage((object)"Error: BackpackData is null in CheckBackpack()");
yield break;
}
if (data.itemSlots == null)
{
Log.LogMessage((object)"Error: itemSlots array is null in CheckBackpack()");
yield break;
}
for (int i = 0; i < data.itemSlots.Length; i++)
{
if (!data.itemSlots[i].IsEmpty())
{
Guid guid = data.itemSlots[i].data.guid;
if (!RegisterItem.ContainsKey(guid))
{
RegisterItem.Add(guid, i);
}
}
}
}
}
catch (Exception ex)
{
Log.LogMessage((object)("Exception in CheckBackpack(): " + ex.Message + "\n" + ex.StackTrace));
}
}
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<PlayerConnectionLog>();
if ((Object)(object)val == (Object)null)
{
return;
}
string text = "<color=#" + color + ">" + message + "</color>";
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
{
Log.LogWarning((object)"AddMessage method not found.");
}
}
public static string AddColor(string text, string color)
{
return "<color=#" + color + ">" + text + "</color>";
}
public static string RemoveTags(string input)
{
if (string.IsNullOrEmpty(input))
{
return input;
}
string text = Regex.Replace(input, "<[^>]+>", string.Empty, RegexOptions.Compiled);
return text.Normalize(NormalizationForm.FormC).Trim();
}
public static string GetItemName(ushort itemID)
{
Item val = default(Item);
if (ItemDatabase.TryGetItem(itemID, ref val))
{
return ((Object)val).name ?? "Unknown";
}
return "Not Found";
}
public static void BackpackReferenceCheck()
{
//IL_008a: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
HashSet<Guid> hashSet = new HashSet<Guid>();
HashSet<Guid> hashSet2 = new HashSet<Guid>();
if ((Object)(object)Character.localCharacter == (Object)null)
{
Log.LogMessage((object)"Error: Character.localCharacter is null in BackpackReferenceCheck()");
}
else if ((Object)(object)Character.localCharacter.player == (Object)null)
{
Log.LogMessage((object)"Error: Character.localCharacter.player is null in BackpackReferenceCheck()");
}
else if (Character.localCharacter.player.backpackSlot == null)
{
Log.LogMessage((object)"Error: backpackSlot is null in BackpackReferenceCheck()");
}
else
{
if (!Character.localCharacter.player.backpackSlot.hasBackpack)
{
return;
}
BackpackReference fromEquippedBackpack = BackpackReference.GetFromEquippedBackpack(Character.localCharacter);
BackpackData data = ((BackpackReference)(ref fromEquippedBackpack)).GetData();
Player player = Character.localCharacter.player;
if (data == null)
{
Log.LogMessage((object)"Error: BackpackData is null in BackpackReferenceCheck()");
return;
}
if (data.itemSlots == null)
{
Log.LogMessage((object)"Error: itemSlots array is null in BackpackReferenceCheck()");
return;
}
ItemSlot[] itemSlots = data.itemSlots;
foreach (ItemSlot val in itemSlots)
{
if (!val.IsEmpty())
{
hashSet.Add(val.data.guid);
}
}
if (hashSet.Count == 0)
{
return;
}
foreach (Character allCharacter in Character.AllCharacters)
{
if ((Object)(object)allCharacter == (Object)null || allCharacter.IsLocal || allCharacter.isScoutmaster || allCharacter.isZombie || allCharacter.isBot || (Object)(object)allCharacter.player == (Object)null)
{
continue;
}
Player player2 = allCharacter.player;
if ((Object)(object)player2 == (Object)(object)player || player2.backpackSlot == null || !player2.backpackSlot.hasBackpack)
{
continue;
}
hashSet2.Clear();
BackpackReference fromEquippedBackpack2 = BackpackReference.GetFromEquippedBackpack(allCharacter);
BackpackData data2 = ((BackpackReference)(ref fromEquippedBackpack2)).GetData();
string text = RemoveTags(allCharacter.characterName);
if (data2 == null || data2.itemSlots == null)
{
continue;
}
ItemSlot[] itemSlots2 = data2.itemSlots;
foreach (ItemSlot val2 in itemSlots2)
{
if (!val2.IsEmpty())
{
Guid guid = val2.data.guid;
hashSet2.Add(guid);
}
}
if (hashSet2.Count == 0)
{
continue;
}
if (hashSet.IsSupersetOf(hashSet2))
{
if (!WarnList.Contains(player2))
{
WarnList.Add(player2);
Log.LogFatal((object)(" Duplicate BackpackReference Detected! " + text));
Notification("Duplicate BackpackReference Detected!", "FF6B6B", sound: true);
Notification(AddColor(text, "FF6B6B") + " has a \"linked\" backpack with yours!", "FFFF00");
break;
}
}
else
{
WarnList.Remove(player2);
}
}
}
}
public static void OnEventPatch(Harmony harmony)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
MethodInfo method = typeof(PhotonNetwork).GetMethod("OnEvent", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[1] { typeof(EventData) }, null);
if (method == null)
{
Log.LogError((object)"Failed to find OnEvent method!");
return;
}
MethodInfo method2 = typeof(EventAlert).GetMethod("PreOnEvent", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
internal class RpcAlert
{
[HarmonyPatch(typeof(Action_RaycastDart), "RPC_DartImpact")]
public class Patch_DartImpact
{
private static int lastFrameLogged = -1;
private static Vector3 lastPosition = Vector3.zero;
[HarmonyPrefix]
private static void Prefix(Action_RaycastDart __instance, int characterID, Vector3 origin, Vector3 endpoint, PhotonMessageInfo info)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.EnableBlowgunAlert.Value || info.Sender.ActorNumber == PhotonNetwork.LocalPlayer.ActorNumber || (lastFrameLogged == Time.frameCount && Vector3.Distance(lastPosition, endpoint) < 0.1f))
{
return;
}
lastFrameLogged = Time.frameCount;
lastPosition = endpoint;
Player sender = info.Sender;
string text = ((sender != null) ? sender.NickName : "Unknown");
string text2 = "Miss";
bool flag = characterID != -1;
if (flag)
{
PhotonView photonView = PhotonNetwork.GetPhotonView(characterID);
Character val = ((photonView != null) ? ((Component)photonView).gameObject.GetComponent<Character>() : null);
text2 = (((Object)(object)val != (Object)null) ? val.characterName : "Unknown");
if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)Character.localCharacter)
{
Plugin.Notification(Plugin.AddColor("[Dart Shot]", "FF0000") + " Shooter: " + Plugin.AddColor(text, "FF6B6B") + " | Hit: " + Plugin.AddColor(text2, "00FFFF") + " | " + $"Position: {endpoint}", "FFFF00", sound: true);
}
else
{
Plugin.Notification("[Dart Shot] Shooter: " + Plugin.AddColor(text, "FF6B6B") + " | Hit: " + Plugin.AddColor(text2, "00FFFF") + " | " + $"Position: {endpoint}", "FFFF00");
}
}
else
{
Plugin.Notification("[Dart Shot] Shooter: " + Plugin.AddColor(text, "FF6B6B") + " | Hit: " + Plugin.AddColor(text2, "00FFFF") + " | " + $"Position: {endpoint}", "FFFF00");
}
Character shooter = default(Character);
if (!flag && (Object)(object)__instance != (Object)null && PlayerHandler.TryGetCharacter(info.Sender.ActorNumber, ref shooter))
{
CheckForNearMisses(endpoint, shooter);
}
}
private static void CheckForNearMisses(Vector3 impactPoint, Character shooter)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
Player[] playerList = PhotonNetwork.PlayerList;
HashSet<Character> hashSet = new HashSet<Character>();
Player[] array = playerList;
Character val2 = default(Character);
foreach (Player val in array)
{
int actorNumber = val.ActorNumber;
if (!PlayerHandler.TryGetCharacter(actorNumber, ref val2) || !((Object)(object)val2 != (Object)(object)shooter))
{
continue;
}
float num = Vector3.Distance(impactPoint, val2.Center);
if (num < 3f)
{
hashSet.Add(val2);
string text = $"{num:F2}m";
if ((Object)(object)val2 == (Object)(object)Character.localCharacter)
{
Plugin.Notification(Plugin.AddColor("[Near Miss]", "FF0000") + " Character: " + Plugin.AddColor(val2.characterName, "FF6B6B") + " | Distance: " + Plugin.AddColor(text, "00FFFF"), "FFFF00", sound: true);
}
else
{
Plugin.Notification("[Near Miss] Character: " + Plugin.AddColor(val2.characterName, "00FFFF") + " | Distance: " + Plugin.AddColor(text, "00FFFF"), "FFFF00");
}
}
}
}
}
[HarmonyPatch(typeof(Dynamite), "RPC_Explode")]
public class Patch_Dynamite_RPC_Explode
{
private static Dictionary<int, List<float>> explosionHistory = new Dictionary<int, List<float>>();
private static HashSet<int> blacklistedPlayers = new HashSet<int>();
private const float timeWindow = 5f;
private const int maxExplosionsPerWindow = 1;
public static bool Prefix(Dynamite __instance, ref PhotonMessageInfo info)
{
if (!Plugin.EnableExplosionAlert.Value)
{
return true;
}
if (info.Sender == null || info.Sender.IsMasterClient)
{
return true;
}
int actorNumber = info.Sender.ActorNumber;
float currentTime = Time.time;
string text = Plugin.RemoveTags(info.Sender.NickName);
if (blacklistedPlayers.Contains(actorNumber))
{
Plugin.Notification(Plugin.AddColor("[EXPLODE]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to spawn explosion!", "FFFF00", sound: true);
Plugin.Log.LogMessage((object)("[EXPLODE] Blacklisted player " + text + " attempted to spawn explosion!"));
return !Plugin.BlockExplosion.Value;
}
if (!explosionHistory.ContainsKey(actorNumber))
{
explosionHistory[actorNumber] = new List<float>();
}
List<float> list = explosionHistory[actorNumber];
list.RemoveAll((float time) => currentTime - time > 5f);
if (list.Count >= 1)
{
blacklistedPlayers.Add(actorNumber);
Plugin.Notification(Plugin.AddColor("[EXPLODE]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to spawn explosion!", "FFFF00", sound: true);
Plugin.Log.LogFatal((object)(text + " -> RPC_Explode (SPAM DETECTED - BLACKLISTED)"));
return !Plugin.BlockExplosion.Value;
}
list.Add(currentTime);
Plugin.Log.LogMessage((object)$"New RPC_Explode Record : {text} | {currentTime}");
return true;
}
}
[HarmonyPatch(typeof(BeeSwarm), "SetBeesAngryRPC")]
public class Patch_BeeSwarm_SetBeesAngryRPC
{
public static bool Prefix(BeeSwarm __instance, bool angry, ref PhotonMessageInfo info)
{
if (!Plugin.EnableBeeAlert.Value)
{
return true;
}
if (info.Sender == null || info.Sender.IsMasterClient)
{
return true;
}
string text = Plugin.RemoveTags(info.Sender.NickName);
Plugin.Notification(Plugin.AddColor("[BEE SWARM]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to force a bee swarm!", "FFFF00", sound: true);
Plugin.Log.LogFatal((object)(text + " -> SetBeesAngryRPC"));
return false;
}
}
[HarmonyPatch(typeof(CharacterMovement), "JumpRpc")]
public class Patch_CharacterMovement_JumpRpc
{
public static bool Prefix(CharacterMovement __instance, ref PhotonMessageInfo info)
{
if (!Plugin.EnableJumpAlert.Value)
{
return true;
}
Character component = ((Component)__instance).GetComponent<Character>();
PhotonView val = ((component != null) ? ((Component)component).GetComponent<PhotonView>() : null);
object obj;
if (val == null)
{
obj = null;
}
else
{
Player owner = val.Owner;
obj = ((owner != null) ? owner.NickName : null);
}
if (obj == null)
{
obj = "Unknown";
}
string text = (string)obj;
if (info.Sender == null || info.Sender.IsMasterClient)
{
return true;
}
if ((Object)(object)val != (Object)null && info.Sender.ActorNumber == val.Owner.ActorNumber)
{
return true;
}
Plugin.Notification(Plugin.AddColor("[FORCE JUMP]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to make " + Plugin.AddColor(text, "00FFFF") + " jump!", "FFFF00", sound: true);
string text2 = Plugin.RemoveTags(info.Sender.NickName);
string text3 = Plugin.RemoveTags(text);
Plugin.Log.LogFatal((object)(text2 + " -> JumpRpc -> " + text3));
return false;
}
}
[HarmonyPatch(typeof(CharacterMovement), "RPCA_SetCrouch")]
public class Patch_CharacterMovement_RPCA_SetCrouch
{
public static bool Prefix(CharacterMovement __instance, bool setCrouch, ref PhotonMessageInfo info)
{
if (!Plugin.EnableCrouchAlert.Value)
{
return true;
}
PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
object obj;
if (component == null)
{
obj = null;
}
else
{
Player owner = component.Owner;
obj = ((owner != null) ? owner.NickName : null);
}
if (obj == null)
{
obj = "Unknown";
}
string text = (string)obj;
if (info.Sender == null || info.Sender.IsMasterClient)
{
return true;
}
if ((Object)(object)component != (Object)null && info.Sender.ActorNumber == component.Owner.ActorNumber)
{
return true;
}
Plugin.Notification(Plugin.AddColor("[FORCE CROUCH]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to make " + Plugin.AddColor(text, "00FFFF") + " crouch!", "FFFF00", sound: true);
string text2 = Plugin.RemoveTags(info.Sender.NickName);
string text3 = Plugin.RemoveTags(text);
Plugin.Log.LogFatal((object)(text2 + " -> RPCA_SetCrouch -> " + text3));
return false;
}
}
[HarmonyPatch(typeof(Character), "RPCA_PassOut")]
public class Patch_RPCA_PassOut
{
public static bool Prefix(Character __instance, ref PhotonMessageInfo info)
{
if (!Plugin.EnablePassoutAlert.Value)
{
return true;
}
PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
object obj;
if (component == null)
{
obj = null;
}
else
{
Player owner = component.Owner;
obj = ((owner != null) ? owner.NickName : null);
}
if (obj == null)
{
obj = "Unknown";
}
string text = (string)obj;
if (info.Sender == null || info.Sender.IsMasterClient)
{
return true;
}
if ((Object)(object)component != (Object)null && info.Sender.ActorNumber == component.Owner.ActorNumber)
{
return true;
}
Plugin.Notification(Plugin.AddColor("[FORCE PASS OUT]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to make " + Plugin.AddColor(text, "00FFFF") + " pass out!", "FFFF00", sound: true);
string text2 = Plugin.RemoveTags(info.Sender.NickName);
string text3 = Plugin.RemoveTags(text);
Plugin.Log.LogFatal((object)(text2 + " -> RPCA_PassOut -> " + text3));
return false;
}
}
[HarmonyPatch(typeof(CharacterCustomization), "CharacterPassedOut")]
public class Patch_CharacterCustomization_CharacterPassedOut
{
public static bool Prefix(CharacterCustomization __instance, ref PhotonMessageInfo info)
{
if (!Plugin.EnablePassoutAlert.Value)
{
return true;
}
Character component = ((Component)__instance).GetComponent<Character>();
PhotonView val = ((component != null) ? ((Component)component).GetComponent<PhotonView>() : null);
object obj;
if (val == null)
{
obj = null;
}
else
{
Player owner = val.Owner;
obj = ((owner != null) ? owner.NickName : null);
}
if (obj == null)
{
obj = "Unknown";
}
string text = (string)obj;
if (info.Sender == null || info.Sender.IsMasterClient)
{
return true;
}
if ((Object)(object)val != (Object)null && info.Sender.ActorNumber == val.Owner.ActorNumber)
{
return true;
}
Plugin.Notification(Plugin.AddColor("[FORCE PASS OUT]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to render PassedOut on " + Plugin.AddColor(text, "00FFFF") + "!", "FFFF00", sound: true);
string text2 = Plugin.RemoveTags(info.Sender.NickName);
string text3 = Plugin.RemoveTags(text);
Plugin.Log.LogFatal((object)(text2 + " -> CharacterPassedOut -> " + text3));
return false;
}
}
[HarmonyPatch(typeof(Character), "RPCA_UnPassOut")]
public class Patch_RPCA_UnPassOut
{
public static bool Prefix(Character __instance, ref PhotonMessageInfo info)
{
if (!Plugin.EnablePassoutAlert.Value)
{
return true;
}
PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
object obj;
if (component == null)
{
obj = null;
}
else
{
Player owner = component.Owner;
obj = ((owner != null) ? owner.NickName : null);
}
if (obj == null)
{
obj = "Unknown";
}
string text = (string)obj;
if (info.Sender == null || info.Sender.IsMasterClient)
{
return true;
}
if ((Object)(object)component != (Object)null && info.Sender.ActorNumber == component.Owner.ActorNumber)
{
return true;
}
Plugin.Notification(Plugin.AddColor("[FORCE UNPASS OUT]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to make " + Plugin.AddColor(text, "00FFFF") + " unpass out!", "FFFF00", sound: true);
string text2 = Plugin.RemoveTags(info.Sender.NickName);
string text3 = Plugin.RemoveTags(text);
Plugin.Log.LogFatal((object)(text2 + " -> RPCA_UnPassOut -> " + text3));
return false;
}
}
[HarmonyPatch(typeof(CharacterAnimations), "RPCA_PlayRemove")]
public class Patch_CharacterAnimations_RPCA_PlayRemove
{
private static bool Prefix(string emoteName, ref bool succeeded, ref PhotonMessageInfo info, CharacterAnimations __instance)
{
if (!Plugin.EnableEmoteAlert.Value)
{
return true;
}
Character component = ((Component)__instance).GetComponent<Character>();
PhotonView val = ((component != null) ? ((Component)component).GetComponent<PhotonView>() : null);
object obj;
if (val == null)
{
obj = null;
}
else
{
Player owner = val.Owner;
obj = ((owner != null) ? owner.NickName : null);
}
if (obj == null)
{
obj = "Unknown";
}
string text = (string)obj;
if (info.Sender == null || info.Sender.IsMasterClient)
{
return true;
}
if ((Object)(object)val != (Object)null && info.Sender.ActorNumber == val.Owner.ActorNumber)
{
return true;
}
Plugin.Notification(Plugin.AddColor("[FORCE EMOTE]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to play emote " + Plugin.AddColor(emoteName, "FFB6C1") + " | " + Plugin.AddColor(succeeded.ToString(), "FFB6C1") + " on " + Plugin.AddColor(text, "00FFFF") + "!", "FFFF00", sound: true);
string text2 = Plugin.RemoveTags(info.Sender.NickName);
string text3 = Plugin.RemoveTags(text);
Plugin.Log.LogFatal((object)(text2 + " -> RPCA_PlayRemove -> " + text3));
return true;
}
}
[HarmonyPatch(typeof(CharacterItems), "DropItemFromSlotRPC")]
public class Patch_CharacterItems_DropItemFromSlotRPC
{
public static bool Prefix(CharacterItems __instance, byte slotID, Vector3 spawnPosition, ref PhotonMessageInfo info)
{
if (!Plugin.EnableDropItemAlert.Value)
{
return true;
}
Character component = ((Component)__instance).GetComponent<Character>();
PhotonView val = ((component != null) ? ((Component)component).GetComponent<PhotonView>() : null);
object obj;
if (val == null)
{
obj = null;
}
else
{
Player owner = val.Owner;
obj = ((owner != null) ? owner.NickName : null);
}
if (obj == null)
{
obj = "Unknown";
}
string text = (string)obj;
if (info.Sender == null || info.Sender.IsMasterClient)
{
return true;
}
if ((Object)(object)val != (Object)null && info.Sender.ActorNumber == val.Owner.ActorNumber)
{
return true;
}
Plugin.Notification(Plugin.AddColor("[FORCE DROP ITEM]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to drop item from " + string.Format("{0}'s slot {1}!", Plugin.AddColor(text, "00FFFF"), slotID), "FFFF00", sound: true);
string text2 = Plugin.RemoveTags(info.Sender.NickName);
string text3 = Plugin.RemoveTags(text);
Plugin.Log.LogFatal((object)(text2 + " -> DropItemFromSlotRPC -> " + text3));
return false;
}
}
[HarmonyPatch(typeof(Player), "RPCRemoveItemFromSlot")]
public class Patch_Player_RPCRemoveItemFromSlot
{
public static bool Prefix(Player __instance, byte slotID, ref PhotonMessageInfo info)
{
if (!Plugin.EnableRemoveItemAlert.Value)
{
return true;
}
Character character = __instance.character;
PhotonView val = ((character != null) ? ((Component)character).GetComponent<PhotonView>() : null);
object obj;
if (val == null)
{
obj = null;
}
else
{
Player owner = val.Owner;
obj = ((owner != null) ? owner.NickName : null);
}
if (obj == null)
{
obj = "Unknown";
}
string text = (string)obj;
if (info.Sender == null || info.Sender.IsMasterClient)
{
return true;
}
if ((Object)(object)val != (Object)null && info.Sender.ActorNumber == val.Owner.ActorNumber)
{
return true;
}
if (!PhotonNetwork.IsMasterClient)
{
Plugin.Notification(Plugin.AddColor("[FORCE REMOVE ITEM]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to remove item from " + string.Format("{0}'s slot {1}!", Plugin.AddColor(text, "00FFFF"), slotID), "FFFF00", sound: true);
string text2 = Plugin.RemoveTags(info.Sender.NickName);
string text3 = Plugin.RemoveTags(text);
Plugin.Log.LogFatal((object)(text2 + " -> RPCRemoveItemFromSlot -> " + text3));
}
return false;
}
}
[HarmonyPatch(typeof(CharacterItems), "DestroyHeldItemRpc")]
public class Patch_CharacterItems_DestroyHeldItemRpc
{
public static bool Prefix(CharacterItems __instance, ref PhotonMessageInfo info)
{
if (!Plugin.EnableRemoveItemAlert.Value)
{
return true;
}
Character component = ((Component)__instance).GetComponent<Character>();
PhotonView val = ((component != null) ? ((Component)component).GetComponent<PhotonView>() : null);
object obj;
if (val == null)
{
obj = null;
}
else
{
Player owner = val.Owner;
obj = ((owner != null) ? owner.NickName : null);
}
if (obj == null)
{
obj = "Unknown";
}
string text = (string)obj;
if (info.Sender == null || info.Sender.IsMasterClient)
{
return true;
}
if ((Object)(object)val != (Object)null && info.Sender.ActorNumber == val.Owner.ActorNumber)
{
return true;
}
Plugin.Notification(Plugin.AddColor("[FORCE DESTROY ITEM]", "FF0000") + " " + Plugin.AddColor(info.Sender.NickName, "00FFFF") + " attempted to destroy item held by " + Plugin.AddColor(text, "00FFFF") + "!", "FFFF00", sound: true);
string text2 = Plugin.RemoveTags(info.Sender.NickName);
string text3 = Plugin.RemoveTags(text);
Plugin.Log.LogFatal((object)(text2 + " -> DestroyHeldItemRpc -> " + text3));
return false;
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}