Decompiled source of ZonePermissions v1.0.1

plugins/ZonePermissions.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Utils;
using Steamworks;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ZonePermissions")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ZonePermissions")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1815f7f4-1df3-4e82-9365-033f3811675a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ZonePermissions;

public static class Client
{
	public struct Client_List
	{
		public ZDOID UID;

		public string SteamID;
	}

	public static class Ward
	{
		public static bool Damage;

		public static bool Pickup;

		public static bool Drop;
	}

	public static List<Client_List> CList = new List<Client_List>();

	public static bool IsZoneAdmin = false;

	public static bool EnforceZones = false;

	public static bool PVPEnforced = false;

	public static bool PVPMode = false;

	public static bool PositionEnforce = false;

	public static bool ShowPosition = false;

	public static bool NoItemLoss = false;

	public static float RespawnTimer = 10f;

	public static void _debug()
	{
		Debug.Log((object)"Loaded Client Data: ");
		Debug.Log((object)("  EnforceZones: " + EnforceZones));
		Debug.Log((object)("  PVPEnforced: " + PVPEnforced));
		Debug.Log((object)("  PVPMode: " + PVPMode));
		Debug.Log((object)("  ShowPosition: " + ShowPosition));
		Debug.Log((object)("  PositionEnforce: " + PositionEnforce));
	}

	public static ZPackage Serialize()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		ZPackage val = new ZPackage();
		if (PVPEnforced)
		{
			PVPMode = true;
		}
		else
		{
			PVPMode = false;
		}
		val.Write(EnforceZones);
		val.Write(PVPEnforced);
		val.Write(PVPMode);
		val.Write(PositionEnforce);
		val.Write(ShowPosition);
		val.Write(Ward.Damage);
		val.Write(Ward.Drop);
		val.Write(Ward.Pickup);
		val.Write(NoItemLoss);
		val.Write(RespawnTimer);
		return val;
	}

	public static void Deserialize(ZPackage data)
	{
		EnforceZones = data.ReadBool();
		PVPEnforced = data.ReadBool();
		PVPMode = data.ReadBool();
		PositionEnforce = data.ReadBool();
		ShowPosition = data.ReadBool();
		Ward.Damage = data.ReadBool();
		Ward.Drop = data.ReadBool();
		Ward.Pickup = data.ReadBool();
		NoItemLoss = data.ReadBool();
		RespawnTimer = data.ReadSingle();
	}

	public static void RPC(ZRpc rpc, ZPackage data)
	{
		Debug.Log((object)"S2C Client (RPC Call)");
		Debug.Log((object)"Before");
		_debug();
		Deserialize(data);
		Debug.Log((object)"After");
		_debug();
	}

	public static void RPC(long uid, ZPackage data)
	{
		Debug.Log((object)"S2C Client (RPC Call)");
		Debug.Log((object)"Before");
		_debug();
		Deserialize(data);
		Debug.Log((object)"After");
		_debug();
	}
}
[BepInPlugin("com.valkyrie.zonepermissions", "Zone Permissions", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class ZonePermissions : BaseUnityPlugin
{
	[HarmonyPatch(typeof(FejdStartup), "AwakePlayFab")]
	private static class FejdStartupAwakePlayfabPatch
	{
		private static void Postfix(FejdStartup __instance)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.isServer())
			{
				CSteamID steamID = SteamUser.GetSteamID();
				MySteamID = ((object)(CSteamID)(ref steamID)).ToString();
				Debug.Log((object)("Caching our SteamID as " + MySteamID));
			}
		}
	}

	[HarmonyPatch(typeof(ZNet), "Awake")]
	private static class ZNetAwakePatch
	{
		private static void Postfix(ZNet __instance)
		{
			//IL_0020: 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)
			if (Util.isServer())
			{
				Debug.Log((object)"Registering Server RPCs");
				AddServerRPC();
				return;
			}
			CSteamID steamID = SteamUser.GetSteamID();
			MySteamID = ((object)(CSteamID)(ref steamID)).ToString();
			Debug.Log((object)("Caching our SteamID as " + MySteamID));
			Debug.Log((object)"Registering Client RPCs");
			AddClientRPC();
		}
	}

	[HarmonyPatch(typeof(ZNet))]
	public class ZNetPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("OnNewConnection")]
		private static void ZNet_OnNewConnectionPrefix(ZNet __instance, ZNetPeer peer)
		{
			if (!Util.isServer())
			{
				Debug.Log((object)$"Server Zone Enforced: {Client.EnforceZones}");
				peer.m_rpc.Register<ZPackage>("ZP_ZoneHandler", (Action<ZRpc, ZPackage>)ZoneHandler.RPC);
				peer.m_rpc.Register<ZPackage>("ZP_Client", (Action<ZRpc, ZPackage>)Client.RPC);
				ZoneHandler.CurrentZoneID = -2;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("SendPeerInfo")]
		private static void ZNet_SendPeerInfo(ZNet __instance, ZRpc rpc)
		{
			if (Util.isServer())
			{
				Debug.Log((object)"SendPeerInfo");
				Debug.Log((object)"S2C ZoneHandler (SendPeerInfo)");
				ZoneHandler._debug();
				rpc.Invoke("ZP_ZoneHandler", new object[1] { ZoneHandler.Serialize(0L) });
				Debug.Log((object)"S2C ClientState (SendPeerInfo)");
				Client._debug();
				rpc.Invoke("ZP_Client", new object[1] { Client.Serialize() });
				Util.Connections.Add(new Util.ConnectionData
				{
					rpc = rpc
				});
			}
		}
	}

	[HarmonyPatch]
	public static class ZoneEnforcer
	{
		[HarmonyPatch(typeof(InventoryGui), "UpdateCharacterStats")]
		public static class PVP_Patch
		{
			private static void Postfix(InventoryGui __instance)
			{
				((Selectable)__instance.m_pvp).interactable = Client.IsZoneAdmin || !Client.PVPEnforced;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Game), "Update")]
		private static void Game__Update()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				return;
			}
			string text = "";
			bool changed;
			ZoneHandler.Zone z;
			ZoneHandler.ZoneTypes zt;
			bool flag = ZoneHandler.Detect(((Component)Player.m_localPlayer).transform.position, out changed, out z, out zt);
			if (changed)
			{
				if (flag)
				{
					Client.IsZoneAdmin = Util.IsZoneAdmin(z.ID);
					string text2 = ((!zt.PVPEnforce) ? NonEnforcedColor.Value : (zt.PVP ? PVPColor.Value : PVEColor.Value));
					string text3 = z.Name.Replace("_", " ");
					text = "<color=" + text2 + ">Now entering <b>" + text3 + "</b>.</color>";
					string text4 = ((!zt.PVPEnforce) ? string.Empty : (zt.PVP ? "PVP Enabled" : "PVP Disabled"));
					((Character)Player.m_localPlayer).Message((MessageType)2, text, 0, (Sprite)null);
					if (Client.EnforceZones && zt.PVPEnforce && zt.PVP != ((Character)Player.m_localPlayer).IsPVPEnabled() && BiomePVPAnnouncement.Value)
					{
						MessageHud.instance.ShowBiomeFoundMsg(text4, true);
					}
				}
				else
				{
					Client.IsZoneAdmin = Util.IsZoneAdmin(-1);
					string text5 = ((!zt.PVPEnforce) ? NonEnforcedColor.Value : (zt.PVP ? PVPColor.Value : PVEColor.Value));
					string text6 = "The Wilderness";
					text = "<color=" + text5 + ">Now entering <b>" + text6 + "</b>.</color>";
					string text7 = ((!zt.PVPEnforce) ? string.Empty : (zt.PVP ? "PVP Enabled" : "PVP Disabled"));
					((Character)Player.m_localPlayer).Message((MessageType)2, text, 0, (Sprite)null);
					if (Client.EnforceZones && zt.PVPEnforce && zt.PVP != ((Character)Player.m_localPlayer).IsPVPEnabled() && BiomePVPAnnouncement.Value)
					{
						MessageHud.instance.ShowBiomeFoundMsg(text7, true);
					}
				}
				if (!Client.IsZoneAdmin && Client.EnforceZones)
				{
					Client.PVPEnforced = zt.PVPEnforce;
					if (zt.PVPEnforce)
					{
						Client.PVPMode = zt.PVP;
					}
					Client.PositionEnforce = zt.PositionEnforce;
					if (zt.PositionEnforce)
					{
						Client.ShowPosition = zt.ShowPosition;
					}
					Player.m_localPlayer.SetPVP(Client.PVPMode);
					InventoryGui.instance.m_pvp.isOn = Client.PVPMode;
					((Selectable)InventoryGui.instance.m_pvp).interactable = !Client.PVPEnforced;
					ZNet.instance.SetPublicReferencePosition(Client.ShowPosition);
					((Character)Player.m_localPlayer).Message((MessageType)2, text, 0, (Sprite)null);
				}
				ZoneHandler._debug(zt);
				Client._debug();
				return;
			}
			if (!Client.IsZoneAdmin && Client.PVPEnforced && ((Character)Player.m_localPlayer).IsPVPEnabled() != Client.PVPMode)
			{
				Player.m_localPlayer.SetPVP(Client.PVPMode);
			}
			if (!Client.IsZoneAdmin && Client.PositionEnforce)
			{
				ZNet instance = ZNet.instance;
				if (((instance != null) ? new bool?(instance.IsReferencePositionPublic()) : null) != Client.ShowPosition)
				{
					ZNet.instance.SetPublicReferencePosition(Client.ShowPosition);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Minimap), "Update")]
		public static void Minimap_Start(Toggle ___m_publicPosition)
		{
			((Selectable)___m_publicPosition).interactable = Client.IsZoneAdmin || !Client.PositionEnforce;
		}
	}

	private static string ConfigFileName = "com.valkyrie.zonepermissions.cfg";

	private static string ConfigFileFullPath;

	public static ConfigEntry<string> ZonePath;

	public static ConfigEntry<int> NexusID;

	public static ConfigEntry<bool> BiomePVPAnnouncement;

	public static ConfigEntry<bool> NoItemLoss;

	public static ConfigEntry<float> RespawnTimer;

	public static ConfigEntry<string> PVPColor;

	public static ConfigEntry<string> PVEColor;

	public static ConfigEntry<string> NonEnforcedColor;

	public static ConfigEntry<bool> WardProtectItemDrop;

	public static ConfigEntry<bool> WardProtectItemPickup;

	public static ConfigEntry<bool> WardProtectDamage;

	public static ConfigEntry<bool> ReloadDetection;

	public static readonly WaitForSeconds OneSecondWait;

	public static readonly WaitForSeconds HalfSecondWait;

	public static CustomRPC RPC_ZoneHandler;

	private static readonly ZonePermissions instance;

	public const string PluginGUID = "com.valkyrie.zonepermissions";

	public const string PluginName = "Zone Permissions";

	public const string PluginVersion = "1.0.0";

	public static string ZoneDir;

	public static string DefaultZonePath;

	public const int AreaRange = 100;

	public static int HealTick;

	public static int DamageTick;

	public static int EffectTick;

	public static Harmony harm;

	public static string MySteamID;

	private void ReadConfigValues(object sender, FileSystemEventArgs e)
	{
		if (!File.Exists(ConfigFileFullPath))
		{
			return;
		}
		try
		{
			Logger.LogDebug((object)"Attempting to reload configuration...");
			((BaseUnityPlugin)this).Config.Reload();
		}
		catch
		{
			Logger.LogError((object)("There was an issue loading " + ConfigFileName));
		}
	}

	private void SetupConfigWatcher()
	{
		FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
		fileSystemWatcher.Changed += ReadConfigValues;
		fileSystemWatcher.Created += ReadConfigValues;
		fileSystemWatcher.Renamed += ReadConfigValues;
		fileSystemWatcher.IncludeSubdirectories = true;
		fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
		fileSystemWatcher.EnableRaisingEvents = true;
	}

	private void CreateConfigValues()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
		ConfigurationManagerAttributes val = new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		};
		if (Util.isServer())
		{
			ReloadDetection = ((BaseUnityPlugin)this).Config.Bind<bool>("Config", "ReloadDetection", false, "SERVER ONLY: Should the server auto reload if the config file is changed? (May cause DeSync)");
			NoItemLoss = ((BaseUnityPlugin)this).Config.Bind<bool>("Death", "NoItemLoss", false, "SERVER ONLY: Should we prevent a user from losing items/skills on death globally?");
			RespawnTimer = ((BaseUnityPlugin)this).Config.Bind<float>("Death", "RespawnTimer", 10f, "SERVER ONLY: How fast should the clients respawn?");
			ZonePath = ((BaseUnityPlugin)this).Config.Bind<string>("WorldofValheimZones", "ZonePath", DefaultZonePath, "SERVER ONLY: The file path to the zone file. If it does not exist, it will be created with a default zone.");
			WardProtectDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Ward", "Building_ProtectDamage", false, "SERVER ONLY: Protect buildings from being damaged inside Warded Areas?");
			WardProtectItemPickup = ((BaseUnityPlugin)this).Config.Bind<bool>("Ward", "Item_Pickup", false, "SERVER ONLY: Protect Picking up items in Warded Areas?");
			WardProtectItemDrop = ((BaseUnityPlugin)this).Config.Bind<bool>("Ward", "Item_Drop", false, "SERVER ONLY: Protect Dropping items in Warded Areas?");
		}
		else
		{
			Debug.Log((object)"[ZonePermissions - Client Mode]");
			BiomePVPAnnouncement = ((BaseUnityPlugin)this).Config.Bind<bool>("Biome", "BiomePVPAnnouncement", true, "Should we announce changing PVP in a Biome Announcement? true or false");
			PVPColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "PVPColor", "Red", "What color should our 'Now Entering' message be if the zone type has PVP on");
			PVEColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "PVEColor", "White", "What color should our 'Now Entering' message be if the zone type has PVE off");
			NonEnforcedColor = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "NonEnforcedColor", "Yellow", "What color should our 'Now Entering' message be if the zone type has No PVP Enforcement");
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Player), "OnRespawn")]
	private static void Player__OnRespawn(Player __instance)
	{
		if (!ZNet.instance.IsServer())
		{
			ZoneHandler.CurrentZoneID = -2;
		}
	}

	private static IEnumerator SRPC_Null(long sender, ZPackage package)
	{
		yield return null;
	}

	private static IEnumerator CRPC_ZoneHandler(long sender, ZPackage package)
	{
		Debug.Log((object)"CRPC ZoneHandler");
		ZoneHandler.RPC(sender, package);
		yield return null;
	}

	private void Awake()
	{
		CreateConfigValues();
		if (Util.isServer())
		{
			CreateFiles();
			SetupZoneWatcher();
			Client.Ward.Damage = WardProtectDamage.Value;
			Client.Ward.Pickup = WardProtectItemPickup.Value;
			Client.Ward.Drop = WardProtectItemDrop.Value;
			Client.NoItemLoss = NoItemLoss.Value;
			Client.RespawnTimer = RespawnTimer.Value;
			ZoneHandler.LoadZoneData(DefaultZonePath);
		}
		Client.EnforceZones = true;
		harm.PatchAll();
	}

	private void FixedUpdate()
	{
		ZonePatches.FixedUpdate();
	}

	private static void SetupZoneWatcher()
	{
		Debug.Log((object)"Creating file watcher for Zones");
		FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(ZoneDir);
		fileSystemWatcher.Changed += OnZoneConfigChange;
		fileSystemWatcher.Created += OnZoneConfigChange;
		fileSystemWatcher.Renamed += OnZoneConfigChange;
		fileSystemWatcher.IncludeSubdirectories = true;
		fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
		fileSystemWatcher.EnableRaisingEvents = true;
	}

	private static void OnZoneConfigChange(object sender, FileSystemEventArgs e)
	{
		Debug.Log((object)"ZONES FILE CHANGED!");
		ZoneHandler.LoadZoneData(DefaultZonePath);
		SendAllUpdate();
	}

	private static void AddServerRPC()
	{
		ZRoutedRpc.instance.Register<ZPackage>("ZonePermissions_AddZone", (Action<long, ZPackage>)AddZone);
		ZRoutedRpc.instance.Register<ZPackage>("ZonePermissions_ReloadZones", (Action<long, ZPackage>)ReloadZones);
		ZRoutedRpc.instance.Register<ZPackage>("ZonePermissions_ZoneHandler", (Action<long, ZPackage>)ZoneHandler.RPC);
	}

	private static void AddClientRPC()
	{
		ZRoutedRpc.instance.Register<ZPackage>("ZonePermissions_AddZone", (Action<long, ZPackage>)AddZone);
		ZRoutedRpc.instance.Register<ZPackage>("ZonePermissions_ReloadZones", (Action<long, ZPackage>)ReloadZones);
		ZRoutedRpc.instance.Register<ZPackage>("ZonePermissions_ZoneHandler", (Action<long, ZPackage>)ZoneHandler.RPC);
		ZRoutedRpc.instance.Register<ZPackage>("ZonePermissions_ChatMessage", (Action<long, ZPackage>)Util.ShowChatMessage);
		ZRoutedRpc.instance.Register<int, string>("ZonePermissions_ShowMessage", (Action<long, int, string>)RPC_ShowMessage);
		ZRoutedRpc.instance.Register<ZPackage>("ZonePermissions_Client", (Action<long, ZPackage>)Client.RPC);
	}

	private void CreateFiles()
	{
		if (!Directory.Exists(ZoneDir))
		{
			Directory.CreateDirectory(ZoneDir);
		}
		if (!File.Exists(DefaultZonePath))
		{
			File.Create(DefaultZonePath);
		}
	}

	public static void ReloadZones(long sender, ZPackage pkg)
	{
		ZNetPeer peer = ZNet.instance.GetPeer(sender);
		if (peer != null)
		{
			string text = "HackShardGaming.WoV-Zones.Reload";
			string text2 = peer.m_uid.ToString();
			if (true)
			{
				ZoneHandler.LoadZoneData(DefaultZonePath);
				Util.Broadcast("Reloading Zone");
				Debug.Log((object)"S2C ZoneHandler (SendPeerInfo)");
				SendAllUpdate();
			}
			else
			{
				Util.RoutedBroadcast(sender, "Sorry! You do not have the permission to use !ReloadZones (Required Permission: " + text + ")");
			}
		}
	}

	public static void SendAllUpdate()
	{
		Debug.Log((object)"SendAllUpdate");
		foreach (ZNetPeer peer in ZNet.instance.GetPeers())
		{
			ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "ZonePermissions_ZoneHandler", new object[1] { ZoneHandler.Serialize(peer.m_uid) });
			Debug.Log((object)("Sent update to " + peer.m_uid));
		}
		Debug.Log((object)"Broadcast Reloading Zone");
		Util.Broadcast("Reloading Zones");
	}

	public static void RPC_ShowMessage(long uid, int type, string msg)
	{
		Util.ShowMessage(type, msg);
	}

	public static void AddZone(long sender, ZPackage pkg)
	{
		if (pkg == null || pkg.Size() <= 0)
		{
			return;
		}
		ZNetPeer peer = ZNet.instance.GetPeer(sender);
		if (peer == null)
		{
			return;
		}
		string text = "HackShardGaming.WoV-Zones.Add";
		string text2 = peer.m_uid.ToString();
		if (false)
		{
			string text3 = pkg.ReadString();
			string[] array = text3.Split(new char[1] { ' ' });
			string text4 = array[0];
			Debug.Log((object)"C-<S AddZone (RPC Call)");
			string text5 = array[1];
			ZoneHandler.ZoneTypes zoneTypes = ZoneHandler.FindZoneType(array[1]);
			if (zoneTypes.Name != text5)
			{
				text3 = "ERROR: The requested Zone Type " + text5 + " does not exist!";
				Util.RoutedBroadcast(sender, text3);
				return;
			}
			int num = int.Parse(array[2]);
			if (num < 1 || num > 5)
			{
				text3 = $"ERROR: The requested Priority {num} is out of bounds! (Priorities are ranged from 1-5)!";
				Util.RoutedBroadcast(sender, text3);
				return;
			}
			string text6 = array[3];
			if (text6.ToLower() != "circle" && text6.ToLower() != "square")
			{
				text3 = "ERROR: The requested Shape: " + text6 + " is incorrectly formated! (Shapes can either be circle or square only)";
				Util.RoutedBroadcast(sender, text3);
				return;
			}
			float result = 0f;
			string text7 = array[4];
			if (!float.TryParse(text7, out result))
			{
				text3 = "ERROR: The requested X " + text7 + " is incorrectly formated! (Correct Format is 0.0)!";
				Util.RoutedBroadcast(sender, text3);
				return;
			}
			string text8 = array[5];
			if (!float.TryParse(text8, out result))
			{
				text3 = "ERROR: The requested Y " + text8 + " is incorrectly formated! (Correct Format is 0.0)!";
				Util.RoutedBroadcast(sender, text3);
				return;
			}
			string text9 = array[6];
			if (!float.TryParse(text9, out result))
			{
				text3 = "ERROR: The requested Radius " + text9 + " is incorrectly formated! (Correct Format is 0.0)!";
				Util.RoutedBroadcast(sender, text3);
				return;
			}
			string text10 = text4 + " " + text5 + " " + num + " " + text6 + " " + text7 + " " + text8 + " " + text9;
			File.AppendAllText(DefaultZonePath, text10 + Environment.NewLine);
		}
		else
		{
			Util.RoutedBroadcast(sender, "Sorry! You do not have the permission to use !AddZone (Required Permission: " + text + ")");
			Debug.Log((object)("An unauthorized user " + text2 + " attempted to use the AddZone RPC!"));
			string text11 = pkg.ReadString();
			Debug.Log((object)("Here is a log of the attempted AddZone " + text11));
		}
	}

	static ZonePermissions()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Expected O, but got Unknown
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Expected O, but got Unknown
		string configPath = Paths.ConfigPath;
		char directorySeparatorChar = Path.DirectorySeparatorChar;
		ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
		OneSecondWait = new WaitForSeconds(1f);
		HalfSecondWait = new WaitForSeconds(0.5f);
		ZoneDir = Path.Combine(Paths.ConfigPath, "ZonePermissions");
		DefaultZonePath = Path.Combine(ZoneDir, "Zones.txt");
		HealTick = 0;
		DamageTick = 0;
		EffectTick = 0;
		harm = new Harmony("ZonePermissions");
		MySteamID = "";
	}
}
public class Util
{
	public class ConnectionData
	{
		public ZRpc rpc;
	}

	public static BindingFlags NonPublicFlags = BindingFlags.Instance | BindingFlags.NonPublic;

	public static List<ConnectionData> Connections = new List<ConnectionData>();

	public static IEnumerator ZoneHandler2(ZRpc rpc)
	{
		Debug.Log((object)"ZoneHandler2");
		rpc.Invoke("ZP_ZoneHandler", new object[1] { ZoneHandler.Serialize(0L) });
		yield return (object)new WaitForSeconds(1f);
	}

	public static IEnumerator Client2(ZRpc rpc)
	{
		Debug.Log((object)"Client2");
		rpc.Invoke("ZP_Client", new object[1] { Client.Serialize() });
		yield return (object)new WaitForSeconds(1f);
	}

	public static void InsertChatMessage(string Message)
	{
		((Terminal)Chat.instance).AddString("<color=grey><b>[Zone Permissions]</b></color> " + Message);
	}

	public static float RestrictionCheckFloatReturn(string restriction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		CSteamID steamID = SteamUser.GetSteamID();
		string text = ((object)(CSteamID)(ref steamID)).ToString();
		Player localPlayer = Player.m_localPlayer;
		ZoneHandler.Zone zone = default(ZoneHandler.Zone);
		ZoneHandler.ZoneTypes zoneTypes = new ZoneHandler.ZoneTypes();
		List<ZoneHandler.Zone> list = ZoneHandler.ListOccupiedZones(((Component)localPlayer).transform.position);
		zoneTypes = ((list.Count != 0) ? ZoneHandler.FindZoneType(ZoneHandler.TopZone(list).Type) : ZoneHandler.FindZoneType("wilderness"));
		string text2 = "";
		string text3 = "";
		text3 = zoneTypes.Admins;
		text2 = zoneTypes.Configurations;
		if (text3.Contains(ZonePermissions.MySteamID))
		{
			return 1f;
		}
		if (text2.ToLower().Contains(restriction))
		{
			string text4 = text2.ToLower();
			string text5 = restriction + "(";
			int num = text4.IndexOf(text5) + text5.Length;
			string text6 = "";
			for (int i = num; i < num + 20 && text4[i] != ')'; i++)
			{
				text6 += text4[i];
			}
			float num2 = 1f;
			return Convert.ToSingle(text6, new CultureInfo("en-US"));
		}
		return 1f;
	}

	public static float RestrictionCheckFloatReturnCharacter(Character __instance, string restriction)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		ZNet instance = ZNet.instance;
		ZDOID zDOID = __instance.GetZDOID();
		string hostName = instance.GetPeer(((ZDOID)(ref zDOID)).UserID).m_socket.GetHostName();
		ZoneHandler.Zone zone = default(ZoneHandler.Zone);
		ZoneHandler.ZoneTypes zoneTypes = new ZoneHandler.ZoneTypes();
		List<ZoneHandler.Zone> list = ZoneHandler.ListOccupiedZones(((Component)__instance).transform.position);
		zoneTypes = ((list.Count != 0) ? ZoneHandler.FindZoneType(ZoneHandler.TopZone(list).Type) : ZoneHandler.FindZoneType("wilderness"));
		string text = "";
		string text2 = "";
		text2 = zoneTypes.Admins;
		text = zoneTypes.Configurations;
		if (text2.Contains(hostName))
		{
			return 1f;
		}
		if (text.ToLower().Contains(restriction))
		{
			string text3 = text.ToLower();
			string text4 = restriction + "(";
			int num = text3.IndexOf(text4) + text4.Length;
			string text5 = "";
			for (int i = num; i < num + 20 && text3[i] != ')'; i++)
			{
				text5 += text3[i];
			}
			float num2 = 1f;
			return Convert.ToSingle(text5, new CultureInfo("en-US"));
		}
		return 1f;
	}

	public static float RestrictionCheckFloatReturnNone(Character __instance, string restriction)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		ZoneHandler.Zone zone = default(ZoneHandler.Zone);
		ZoneHandler.ZoneTypes zoneTypes = new ZoneHandler.ZoneTypes();
		List<ZoneHandler.Zone> list = ZoneHandler.ListOccupiedZones(((Component)__instance).transform.position);
		zoneTypes = ((list.Count != 0) ? ZoneHandler.FindZoneType(ZoneHandler.TopZone(list).Type) : ZoneHandler.FindZoneType("wilderness"));
		string text = "";
		string text2 = "";
		text2 = zoneTypes.Admins;
		text = zoneTypes.Configurations;
		if (text.ToLower().Contains(restriction))
		{
			string text3 = text.ToLower();
			string text4 = restriction + "(";
			int num = text3.IndexOf(text4) + text4.Length;
			string text5 = "";
			for (int i = num; i < num + 20 && text3[i] != ')'; i++)
			{
				text5 += text3[i];
			}
			float num2 = 1f;
			return Convert.ToSingle(text5, new CultureInfo("en-US"));
		}
		return 1f;
	}

	public static bool RestrictionCheckCharacter(Character __instance, string restriction)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		ZNet instance = ZNet.instance;
		ZDOID zDOID = __instance.GetZDOID();
		string hostName = instance.GetPeer(((ZDOID)(ref zDOID)).UserID).m_socket.GetHostName();
		if (ZoneHandler.Zones.Count() == 0)
		{
			return false;
		}
		ZoneHandler.Zone zone = default(ZoneHandler.Zone);
		ZoneHandler.ZoneTypes zoneTypes = new ZoneHandler.ZoneTypes();
		List<ZoneHandler.Zone> list = ZoneHandler.ListOccupiedZones(((Component)__instance).transform.position);
		zoneTypes = ((list.Count != 0) ? ZoneHandler.FindZoneType(ZoneHandler.TopZone(list).Type) : ZoneHandler.FindZoneType("wilderness"));
		string text = "";
		string text2 = "";
		text2 = zoneTypes.Admins;
		text = zoneTypes.Configurations;
		if (text2.Contains(hostName))
		{
			return false;
		}
		if (text.ToLower().Contains(restriction))
		{
			return true;
		}
		return false;
	}

	public static bool RestrictionCheckTerrain(TerrainComp __instance, string restriction)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		if (ZoneHandler.Zones.Count() == 0)
		{
			return false;
		}
		ZoneHandler.Zone zone = default(ZoneHandler.Zone);
		ZoneHandler.ZoneTypes zoneTypes = new ZoneHandler.ZoneTypes();
		List<ZoneHandler.Zone> list = ZoneHandler.ListOccupiedZones(((Component)__instance).transform.position);
		zoneTypes = ((list.Count != 0) ? ZoneHandler.FindZoneType(ZoneHandler.TopZone(list).Type) : ZoneHandler.FindZoneType("wilderness"));
		string text = "";
		string text2 = "";
		text2 = zoneTypes.Admins;
		text = zoneTypes.Configurations;
		if (text.ToLower().Contains(restriction))
		{
			return true;
		}
		return false;
	}

	public static bool RestrictionCheckNone(Character __instance, string restriction)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		if (ZoneHandler.Zones.Count() == 0)
		{
			return false;
		}
		ZoneHandler.Zone zone = default(ZoneHandler.Zone);
		ZoneHandler.ZoneTypes zoneTypes = new ZoneHandler.ZoneTypes();
		List<ZoneHandler.Zone> list = ZoneHandler.ListOccupiedZones(((Component)__instance).transform.position);
		zoneTypes = ((list.Count != 0) ? ZoneHandler.FindZoneType(ZoneHandler.TopZone(list).Type) : ZoneHandler.FindZoneType("wilderness"));
		string text = "";
		text = zoneTypes.Configurations;
		if (text.ToLower().Contains(restriction))
		{
			return true;
		}
		return false;
	}

	public static bool RestrictionCheck(string restriction)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		Player localPlayer = Player.m_localPlayer;
		if (ZoneHandler.Zones.Count() == 0)
		{
			return false;
		}
		ZoneHandler.Zone zone = default(ZoneHandler.Zone);
		ZoneHandler.ZoneTypes zoneTypes = new ZoneHandler.ZoneTypes();
		List<ZoneHandler.Zone> list = ZoneHandler.ListOccupiedZones(((Component)localPlayer).transform.position);
		zoneTypes = ((list.Count != 0) ? ZoneHandler.FindZoneType(ZoneHandler.TopZone(list).Type) : ZoneHandler.FindZoneType("wilderness"));
		string text = "";
		string text2 = "";
		text2 = zoneTypes.Admins;
		text = zoneTypes.Configurations;
		if (text2.Contains(ZonePermissions.MySteamID))
		{
			return false;
		}
		if (text.ToLower().Contains(restriction))
		{
			return true;
		}
		return false;
	}

	public static void DoPrivateAreaEffect(Vector3 pos)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		GameObject prefab = ZNetScene.instance.GetPrefab("vfx_lootspawn");
		GameObject val = Object.Instantiate<GameObject>(prefab, pos, Quaternion.identity);
		if (!((Object)(object)Player.m_localPlayer == (Object)null))
		{
			ShowChatMessage(Player.m_localPlayer.GetPlayerID(), "Zone Permissions", "PRIVATE AREA", inWorld: true, pos, (Type)1);
		}
	}

	public static void DoWardedAreaEffect(Vector3 pos)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		GameObject prefab = ZNetScene.instance.GetPrefab("vfx_lootspawn");
		GameObject val = Object.Instantiate<GameObject>(prefab, pos, Quaternion.identity);
		if (!((Object)(object)Player.m_localPlayer == (Object)null))
		{
			ShowChatMessage(Player.m_localPlayer.GetPlayerID(), "Zone Permissions", "WARDED AREA", inWorld: true, pos, (Type)1);
		}
	}

	public static void ShowMessage(int type, string msg)
	{
		((Character)Player.m_localPlayer).Message((MessageType)type, msg, 0, (Sprite)null);
	}

	public static void ShowChatMessage(long uid, ZPackage pkg)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: 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)
		UserInfo val = new UserInfo
		{
			Name = pkg.ReadString(),
			Gamertag = null,
			NetworkUserId = uid.ToString()
		};
		string text = pkg.ReadString();
		bool flag = pkg.ReadBool();
		Vector3 val2 = pkg.ReadVector3();
		Type type = ((object)Chat.instance).GetType();
		if (flag)
		{
			type.GetMethod("AddInworldText", NonPublicFlags).Invoke(Chat.instance, new object[6]
			{
				null,
				uid,
				val2,
				(object)(Type)2,
				val,
				text
			});
		}
		type.GetField("m_hideTimer", NonPublicFlags).SetValue(Chat.instance, 0f);
		((Terminal)Chat.instance).AddString("Zone Permissions", text, (Type)2, false);
	}

	public static void ShowChatMessage(long uid, string username, string msg, bool inWorld = false, Vector3 pos = default(Vector3), Type type = 1)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		UserInfo val = new UserInfo
		{
			Name = username,
			Gamertag = null,
			NetworkUserId = uid.ToString()
		};
		Type type2 = ((object)Chat.instance).GetType();
		if (inWorld)
		{
			type2.GetMethod("AddInworldText", NonPublicFlags).Invoke(Chat.instance, new object[6] { null, uid, pos, type, val, msg });
		}
		type2.GetField("m_hideTimer", NonPublicFlags).SetValue(Chat.instance, 0f);
		((Terminal)Chat.instance).AddString("Zone Permissions", msg, (Type)2, false);
	}

	public static void Broadcast(string text, string username = "Zone Permissions", bool inWorld = false)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		ZPackage val = new ZPackage();
		val.Write(username);
		val.Write(text);
		val.Write(inWorld);
		val.Write(new Vector3(0f, 100f, 0f));
		ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "ZonePermissions_ChatMessage", new object[1] { val });
	}

	public static void RoutedBroadcast(long peer, string text, string username = "Zone Permissions")
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		WorldTextInstance val = Chat.instance.FindExistingWorldText(peer);
		ZRoutedRpc.instance.InvokeRoutedRPC(peer, "ChatMessage", new object[6]
		{
			(object)new Vector3(0f, 100f, 0f),
			(object)(Type)2,
			username,
			val.m_userInfo,
			text,
			val.m_userInfo.NetworkUserId
		});
	}

	public static bool isServer()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Invalid comparison between Unknown and I4
		return (int)SystemInfo.graphicsDeviceType == 4;
	}

	public static bool isAdmin(long sender)
	{
		ZNetPeer peer = ZNet.instance.GetPeer(sender);
		string text = sender.ToString();
		if (ZNet.instance.m_adminList != null && ZNet.instance.m_adminList.Contains(text))
		{
			return true;
		}
		return false;
	}

	public static bool IsZoneAdmin(int zoneID)
	{
		ZoneHandler.ZoneTypes zoneTypes;
		if (zoneID < 0)
		{
			zoneTypes = ZoneHandler.FindZoneType("wilderness");
		}
		else
		{
			Debug.Log((object)$"Checking admin for zone id {zoneID}");
			ZoneHandler.Zone zone = ZoneHandler.Zones.Find((ZoneHandler.Zone z) => z.ID == zoneID);
			Debug.Log((object)("Got Zone: " + zone.Name));
			zoneTypes = ZoneHandler.FindZoneType(zone.Type);
		}
		return zoneTypes.Admins.Contains(ZonePermissions.MySteamID);
	}

	public static ConnectionData GetServer()
	{
		return Connections[0];
	}
}
internal class ZonePatches
{
	[HarmonyPatch(typeof(Player), "OnDeath")]
	public static class Death_Patch
	{
		private static bool Prefix(Player __instance)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected I4, but got Unknown
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			if (Util.RestrictionCheck("noitemloss") || Client.NoItemLoss)
			{
				Type type = ((object)__instance).GetType();
				bool flag = (bool)type.GetMethod("HardDeath", Util.NonPublicFlags).Invoke(__instance, new object[0]);
				ZNetView val = (ZNetView)type.GetField("m_nview", Util.NonPublicFlags).GetValue(__instance);
				HitData val2 = (HitData)type.GetField("m_lastHit", Util.NonPublicFlags).GetValue(__instance);
				List<Food> list = (List<Food>)type.GetField("m_foods", Util.NonPublicFlags).GetValue(__instance);
				Skills val3 = (Skills)type.GetField("m_skills", Util.NonPublicFlags).GetValue(__instance);
				SEMan val4 = (SEMan)type.GetField("m_seman", Util.NonPublicFlags).GetValue(__instance);
				val.GetZDO().Set(ZDOVars.s_dead, true);
				Game.instance.IncrementPlayerStat((PlayerStatType)0, 1f);
				HitType hitType = val2.m_hitType;
				HitType val5 = hitType;
				switch ((int)val5)
				{
				case 0:
					Game.instance.IncrementPlayerStat((PlayerStatType)55, 1f);
					break;
				case 1:
					Game.instance.IncrementPlayerStat((PlayerStatType)56, 1f);
					break;
				case 2:
					Game.instance.IncrementPlayerStat((PlayerStatType)57, 1f);
					break;
				case 3:
					Game.instance.IncrementPlayerStat((PlayerStatType)58, 1f);
					break;
				case 4:
					Game.instance.IncrementPlayerStat((PlayerStatType)59, 1f);
					break;
				case 5:
					Game.instance.IncrementPlayerStat((PlayerStatType)60, 1f);
					break;
				case 6:
					Game.instance.IncrementPlayerStat((PlayerStatType)61, 1f);
					break;
				case 7:
					Game.instance.IncrementPlayerStat((PlayerStatType)62, 1f);
					break;
				case 8:
					Game.instance.IncrementPlayerStat((PlayerStatType)64, 1f);
					break;
				case 9:
					Game.instance.IncrementPlayerStat((PlayerStatType)63, 1f);
					break;
				case 10:
					Game.instance.IncrementPlayerStat((PlayerStatType)65, 1f);
					break;
				case 11:
					Game.instance.IncrementPlayerStat((PlayerStatType)66, 1f);
					break;
				case 12:
					Game.instance.IncrementPlayerStat((PlayerStatType)67, 1f);
					break;
				case 13:
					Game.instance.IncrementPlayerStat((PlayerStatType)68, 1f);
					break;
				case 14:
					Game.instance.IncrementPlayerStat((PlayerStatType)69, 1f);
					break;
				case 15:
					Game.instance.IncrementPlayerStat((PlayerStatType)70, 1f);
					break;
				case 16:
					Game.instance.IncrementPlayerStat((PlayerStatType)71, 1f);
					break;
				case 17:
					Game.instance.IncrementPlayerStat((PlayerStatType)72, 1f);
					break;
				case 18:
					Game.instance.IncrementPlayerStat((PlayerStatType)73, 1f);
					break;
				default:
					ZLog.LogWarning((object)("Not implemented death type " + ((object)(HitType)(ref val2.m_hitType)).ToString()));
					break;
				}
				Game.instance.GetPlayerProfile().SetDeathPoint(((Component)__instance).transform.position);
				type.GetMethod("CreateDeathEffects", Util.NonPublicFlags).Invoke(__instance, new object[0]);
				list.Clear();
				if (ZoneSystem.instance.GetGlobalKey((GlobalKeys)17))
				{
					val3.Clear();
				}
				else if (flag)
				{
					val3.OnDeath();
				}
				val4.RemoveAllStatusEffects(false);
				Game.instance.RequestRespawn(10f, true);
				type.GetField("m_timeSinceDeath", Util.NonPublicFlags).SetValue(__instance, 0f);
				if (!flag)
				{
					Util.ShowMessage(1, "$msg_softdeath");
				}
				((Character)__instance).Message((MessageType)2, "$msg_youdied", 0, (Sprite)null);
				Minimap.instance.AddPin(((Component)__instance).transform.position, (PinType)4, $"$hud_mapday {EnvMan.instance.GetDay(ZNet.instance.GetTimeSeconds())}", true, false, 0L, "");
				if (((Character)__instance).m_onDeath != null)
				{
					((Character)__instance).m_onDeath();
				}
				Biome currentBiome = __instance.GetCurrentBiome();
				string text = "biome:" + ((object)(Biome)(ref currentBiome)).ToString();
				Gogan.LogEvent("Game", "Death", text, 0L);
				return false;
			}
			ZoneHandler.CurrentZoneID = -2;
			return true;
		}
	}

	[HarmonyPatch(typeof(Attack), "SpawnOnHitTerrain")]
	public static class Attack_Patch
	{
		private static bool Prefix(Vector3 hitPoint)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			if (Util.isServer())
			{
				return true;
			}
			if (Util.RestrictionCheck("nopickaxe") || Util.RestrictionCheck("noterrain"))
			{
				flag = true;
				Util.DoPrivateAreaEffect(hitPoint + ((Component)Player.m_localPlayer).transform.forward * 1f);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
			}
			return !flag;
		}
	}

	[HarmonyPatch(typeof(TerrainOp), "Awake")]
	public static class TerrainComp_Patch
	{
		private static bool Prefix(TerrainOp __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Util.RestrictionCheck("noterrain"))
			{
				Util.DoPrivateAreaEffect(((Component)__instance).transform.position);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Container), "Interact")]
	public static class Container_Patch
	{
		private static bool Prefix(Container __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			if (Util.isServer())
			{
				return true;
			}
			if (Util.RestrictionCheck("nochest"))
			{
				flag = true;
				Util.DoPrivateAreaEffect(((Component)__instance).transform.position);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
			}
			return !flag;
		}
	}

	[HarmonyPatch(typeof(Door), "Interact")]
	public static class Door_Patch
	{
		private static bool Prefix(Door __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (Util.isServer())
			{
				return true;
			}
			bool flag = false;
			if (Util.RestrictionCheck("nodoors"))
			{
				flag = true;
				Util.DoPrivateAreaEffect(((Component)__instance).transform.position);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
			}
			return !flag;
		}
	}

	[HarmonyPatch(typeof(Sign), "Interact")]
	public static class Sign_Patch
	{
		private static bool Prefix(Door __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (Util.isServer())
			{
				return true;
			}
			bool flag = false;
			if (Util.RestrictionCheck("nosigns"))
			{
				flag = true;
				Util.DoPrivateAreaEffect(((Component)__instance).transform.position);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
			}
			return !flag;
		}
	}

	[HarmonyPatch(typeof(Player), "PlacePiece")]
	public static class NoBuild_Patch
	{
		private static bool Prefix(Player __instance)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (Util.isServer())
			{
				return true;
			}
			bool flag = false;
			if (Util.RestrictionCheck("nobuilding"))
			{
				flag = true;
				Type type = ((object)__instance).GetType();
				GameObject val = (GameObject)type.GetField("m_placementGhost", Util.NonPublicFlags).GetValue(__instance);
				Util.DoPrivateAreaEffect(val.transform.position);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
			}
			return !flag;
		}
	}

	[HarmonyPatch(typeof(Player), "RemovePiece")]
	public static class NoBuild_Patch2
	{
		private static bool Prefix(Player __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (Util.isServer())
			{
				return true;
			}
			bool flag = false;
			if (Util.RestrictionCheck("nobuilding"))
			{
				flag = true;
				Util.DoPrivateAreaEffect(((Component)__instance).transform.position);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
			}
			return !flag;
		}
	}

	[HarmonyPatch(typeof(WearNTear), "Damage")]
	public static class Building_Wear_N_Tear_Patch
	{
		private static bool Prefix(WearNTear __instance, HitData hit)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			if (Util.isServer())
			{
				return true;
			}
			bool flag = false;
			bool flag2 = false;
			Debug.Log((object)"pre allPrivateAreas");
			List<PrivateArea> list = (List<PrivateArea>)typeof(PrivateArea).GetField("m_allAreas", BindingFlags.Static | BindingFlags.NonPublic).GetValue((object?)new PrivateArea());
			Debug.Log((object)"post allPrivateAreas");
			foreach (PrivateArea item in list)
			{
				Debug.Log((object)"privateArea");
				Type type = ((object)item).GetType();
				Debug.Log((object)"privateArea type");
				bool flag3 = (bool)type.GetMethod("IsEnabled", Util.NonPublicFlags).Invoke(item, new object[0]);
				Debug.Log((object)"privateArea reflection 1");
				bool flag4 = (bool)type.GetMethod("IsInside", Util.NonPublicFlags).Invoke(item, new object[2]
				{
					((Component)__instance).transform.position,
					0
				});
				Debug.Log((object)"privateArea reflection 2");
				if (flag3 && flag4)
				{
					flag = true;
					break;
				}
			}
			Debug.Log((object)"wnt check iswarded");
			if (Client.Ward.Damage && flag)
			{
				ZDOID attacker = hit.m_attacker;
				bool flag5 = false;
				List<Character> list2 = new List<Character>();
				foreach (Character allCharacter in Character.GetAllCharacters())
				{
					if (allCharacter.GetZDOID() == attacker && Object.op_Implicit((Object)(object)((Component)allCharacter).GetComponent<Player>()))
					{
						flag5 = true;
					}
				}
				if (!flag5)
				{
					PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, true, false);
					flag2 = true;
					return !flag2;
				}
				if (!PrivateArea.CheckAccess(((Component)Player.m_localPlayer).transform.position, 0f, true, false))
				{
					Util.DoWardedAreaEffect(((Component)__instance).transform.position);
					MessageHud.instance.ShowMessage((MessageType)1, "This is a Warded Area", 0, (Sprite)null);
					flag2 = true;
					return !flag2;
				}
			}
			Debug.Log((object)"wnt check nobuilddamage");
			if (Util.RestrictionCheck("nobuilddamage"))
			{
				flag2 = true;
				Util.DoPrivateAreaEffect(((Component)__instance).transform.position + Vector3.up * 0.5f);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
			}
			return !flag2;
		}
	}

	[HarmonyPatch(typeof(ItemDrop), "Interact")]
	public static class NoDropInteraction_Patch
	{
		private static bool Prefix(ItemDrop __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (Util.isServer())
			{
				return true;
			}
			bool flag = false;
			if (Client.Ward.Drop && PrivateArea.CheckAccess(((Component)Player.m_localPlayer).transform.position, 0f, true, false) && !PrivateArea.CheckAccess(((Component)Player.m_localPlayer).transform.position, 0f, true, false))
			{
				Util.DoWardedAreaEffect(((Component)__instance).transform.position);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Warded Area", 0, (Sprite)null);
				flag = true;
				return !flag;
			}
			if (Util.RestrictionCheck("noitempickup"))
			{
				flag = true;
				Util.DoPrivateAreaEffect(((Component)__instance).transform.position + Vector3.up * 0.5f);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
			}
			return !flag;
		}
	}

	[HarmonyPatch(typeof(Player), "AutoPickup")]
	public static class NoAutoPickup_Patch
	{
		private static bool Prefix(Player __instance)
		{
			//IL_0019: 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_0030: 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)
			if (Util.isServer())
			{
				return true;
			}
			bool flag = false;
			Vector3 position = ((Component)__instance).transform.position;
			if (Client.Ward.Pickup && PrivateArea.CheckAccess(((Component)Player.m_localPlayer).transform.position, 0f, true, false) && !PrivateArea.CheckAccess(((Component)Player.m_localPlayer).transform.position, 0f, false, false))
			{
				flag = true;
				return !flag;
			}
			if (Util.RestrictionCheck("noitempickup"))
			{
				flag = true;
			}
			return !flag;
		}
	}

	[HarmonyPatch(typeof(InventoryGrid), "OnLeftClick")]
	public static class No_Inventory_Ctrl_Left_Click
	{
		private static bool Prefix(InventoryGrid __instance)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			if (Util.isServer())
			{
				return true;
			}
			bool flag = false;
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)))
			{
				if (Client.Ward.Drop && PrivateArea.CheckAccess(((Component)Player.m_localPlayer).transform.position, 0f, true, false) && !PrivateArea.CheckAccess(((Component)Player.m_localPlayer).transform.position, 0f, true, false))
				{
					Util.DoWardedAreaEffect(((Component)Player.m_localPlayer).transform.position);
					MessageHud.instance.ShowMessage((MessageType)1, "This is a Warded Area", 0, (Sprite)null);
					flag = true;
					return !flag;
				}
				if (Util.RestrictionCheck("noitemdrop") && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)))
				{
					flag = true;
					Util.DoPrivateAreaEffect(((Component)Player.m_localPlayer).transform.position + Vector3.up * 0.5f);
					MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
				}
			}
			return !flag;
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "OnDropOutside")]
	public static class InventoryGui_No_Drop_Patch
	{
		private static bool Prefix(InventoryGui __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (Util.isServer())
			{
				return true;
			}
			bool flag = false;
			if (Client.Ward.Drop && PrivateArea.CheckAccess(((Component)Player.m_localPlayer).transform.position, 0f, true, false) && !PrivateArea.CheckAccess(((Component)Player.m_localPlayer).transform.position, 0f, true, false))
			{
				bool flag2 = PrivateArea.CheckAccess(((Component)Player.m_localPlayer).transform.position, 0f, true, false);
				long playerID = Player.m_localPlayer.GetPlayerID();
				Util.DoWardedAreaEffect(((Component)Player.m_localPlayer).transform.position);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Warded Area", 0, (Sprite)null);
				flag = true;
				return !flag;
			}
			if (Util.RestrictionCheck("noitemdrop"))
			{
				flag = true;
				Util.DoPrivateAreaEffect(((Component)Player.m_localPlayer).transform.position + Vector3.up * 0.5f);
				MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
			}
			return !flag;
		}
	}

	[HarmonyPatch(typeof(Character), "Damage")]
	public static class Damage_Modifier
	{
		public static void Prefix(Character __instance, HitData hit, ZNetView ___m_nview)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between Unknown and I4
			if ((int)__instance.m_faction > 0)
			{
				Debug.Log((object)"A monster is being attacked!");
				if (Util.RestrictionCheckNone(__instance, "damagemultipliertomobs") && (int)__instance.m_faction > 0)
				{
					float num = Util.RestrictionCheckFloatReturnNone(__instance, "damagemultipliertomobs");
					Debug.Log((object)$"Multiplier: {num}");
					hit.m_damage.m_damage *= num;
					hit.m_damage.m_blunt *= num;
					hit.m_damage.m_slash *= num;
					hit.m_damage.m_pierce *= num;
					hit.m_damage.m_chop *= num;
					hit.m_damage.m_pickaxe *= num;
					hit.m_damage.m_fire *= num;
					hit.m_damage.m_frost *= num;
					hit.m_damage.m_lightning *= num;
					hit.m_damage.m_poison *= num;
					hit.m_damage.m_spirit *= num;
				}
			}
			else if ((int)__instance.m_faction == 0)
			{
				Debug.Log((object)"A player is being Attacked!");
				if (Util.RestrictionCheckNone(__instance, "damagemultipliertoplayers"))
				{
					float num2 = Util.RestrictionCheckFloatReturnNone(__instance, "damagemultipliertoplayers");
					Debug.Log((object)$"Mutliplier: {num2}");
					hit.m_damage.m_damage *= num2;
					hit.m_damage.m_blunt *= num2;
					hit.m_damage.m_slash *= num2;
					hit.m_damage.m_pierce *= num2;
					hit.m_damage.m_chop *= num2;
					hit.m_damage.m_pickaxe *= num2;
					hit.m_damage.m_fire *= num2;
					hit.m_damage.m_frost *= num2;
					hit.m_damage.m_lightning *= num2;
					hit.m_damage.m_poison *= num2;
					hit.m_damage.m_spirit *= num2;
				}
			}
		}
	}

	[HarmonyPatch(typeof(Destructible), "Damage")]
	public static class Destructible_Modifier
	{
		public static void Prefix(Destructible __instance, HitData hit)
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.isServer())
			{
				if (Util.RestrictionCheck("nodamagetotrees"))
				{
					float num = 0f;
					hit.m_damage.m_damage *= num;
					hit.m_damage.m_blunt *= num;
					hit.m_damage.m_slash *= num;
					hit.m_damage.m_pierce *= num;
					hit.m_damage.m_chop *= num;
					hit.m_damage.m_pickaxe *= num;
					hit.m_damage.m_fire *= num;
					hit.m_damage.m_frost *= num;
					hit.m_damage.m_lightning *= num;
					hit.m_damage.m_poison *= num;
					hit.m_damage.m_spirit *= num;
					Util.DoPrivateAreaEffect(((Component)Player.m_localPlayer).transform.position + Vector3.up * 0.5f);
					MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
				}
				else if (Util.RestrictionCheck("damagemultipliertotrees"))
				{
					float num2 = Util.RestrictionCheckFloatReturn("damagemultipliertotrees");
					hit.m_damage.m_damage *= num2;
					hit.m_damage.m_blunt *= num2;
					hit.m_damage.m_slash *= num2;
					hit.m_damage.m_pierce *= num2;
					hit.m_damage.m_chop *= num2;
					hit.m_damage.m_pickaxe *= num2;
					hit.m_damage.m_fire *= num2;
					hit.m_damage.m_frost *= num2;
					hit.m_damage.m_lightning *= num2;
					hit.m_damage.m_poison *= num2;
					hit.m_damage.m_spirit *= num2;
				}
			}
		}
	}

	[HarmonyPatch(typeof(TreeBase), "Damage")]
	public static class TreeBase_Modifier
	{
		public static void Prefix(TreeBase __instance, HitData hit)
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.isServer())
			{
				if (Util.RestrictionCheck("nodamagetotrees"))
				{
					float num = 0f;
					hit.m_damage.m_damage *= num;
					hit.m_damage.m_blunt *= num;
					hit.m_damage.m_slash *= num;
					hit.m_damage.m_pierce *= num;
					hit.m_damage.m_chop *= num;
					hit.m_damage.m_pickaxe *= num;
					hit.m_damage.m_fire *= num;
					hit.m_damage.m_frost *= num;
					hit.m_damage.m_lightning *= num;
					hit.m_damage.m_poison *= num;
					hit.m_damage.m_spirit *= num;
					Util.DoPrivateAreaEffect(((Component)Player.m_localPlayer).transform.position + Vector3.up * 0.5f);
					MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
				}
				else if (Util.RestrictionCheck("damagemultipliertotrees"))
				{
					float num2 = Util.RestrictionCheckFloatReturn("damagemultipliertotrees");
					hit.m_damage.m_damage *= num2;
					hit.m_damage.m_blunt *= num2;
					hit.m_damage.m_slash *= num2;
					hit.m_damage.m_pierce *= num2;
					hit.m_damage.m_chop *= num2;
					hit.m_damage.m_pickaxe *= num2;
					hit.m_damage.m_fire *= num2;
					hit.m_damage.m_frost *= num2;
					hit.m_damage.m_lightning *= num2;
					hit.m_damage.m_poison *= num2;
					hit.m_damage.m_spirit *= num2;
				}
			}
		}
	}

	[HarmonyPatch(typeof(TreeLog), "Damage")]
	public static class TreeLog_Modifier
	{
		public static void Prefix(TreeLog __instance, HitData hit)
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.isServer())
			{
				if (Util.RestrictionCheck("nodamagetotrees"))
				{
					float num = 0f;
					hit.m_damage.m_damage *= num;
					hit.m_damage.m_blunt *= num;
					hit.m_damage.m_slash *= num;
					hit.m_damage.m_pierce *= num;
					hit.m_damage.m_chop *= num;
					hit.m_damage.m_pickaxe *= num;
					hit.m_damage.m_fire *= num;
					hit.m_damage.m_frost *= num;
					hit.m_damage.m_lightning *= num;
					hit.m_damage.m_poison *= num;
					hit.m_damage.m_spirit *= num;
					Util.DoPrivateAreaEffect(((Component)Player.m_localPlayer).transform.position + Vector3.up * 0.5f);
					MessageHud.instance.ShowMessage((MessageType)1, "This is a Private Area", 0, (Sprite)null);
				}
				else if (Util.RestrictionCheck("damagemultipliertotrees"))
				{
					float num2 = Util.RestrictionCheckFloatReturn("damagemultipliertotrees");
					hit.m_damage.m_damage *= num2;
					hit.m_damage.m_blunt *= num2;
					hit.m_damage.m_slash *= num2;
					hit.m_damage.m_pierce *= num2;
					hit.m_damage.m_chop *= num2;
					hit.m_damage.m_pickaxe *= num2;
					hit.m_damage.m_fire *= num2;
					hit.m_damage.m_frost *= num2;
					hit.m_damage.m_lightning *= num2;
					hit.m_damage.m_poison *= num2;
					hit.m_damage.m_spirit *= num2;
				}
			}
		}
	}

	public static void FixedUpdate()
	{
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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_013f: 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_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Expected O, but got Unknown
		if (ZonePermissions.EffectTick > 0)
		{
			ZonePermissions.EffectTick--;
		}
		if (ZonePermissions.HealTick > 0)
		{
			ZonePermissions.HealTick--;
		}
		if (ZonePermissions.DamageTick > 0)
		{
			ZonePermissions.DamageTick--;
		}
		Player localPlayer = Player.m_localPlayer;
		if (!((Object)(object)localPlayer != (Object)null))
		{
			return;
		}
		ZoneHandler.Zone zone = default(ZoneHandler.Zone);
		ZoneHandler.ZoneTypes zoneTypes = new ZoneHandler.ZoneTypes();
		List<ZoneHandler.Zone> list = ZoneHandler.ListOccupiedZones(((Component)localPlayer).transform.position);
		if (list.Count == 0)
		{
			zoneTypes = ZoneHandler.FindZoneType("wilderness");
		}
		else
		{
			zone = ZoneHandler.TopZone(list);
			zoneTypes = ZoneHandler.FindZoneType(zone.Type);
		}
		string admins = zoneTypes.Admins;
		string configurations = zoneTypes.Configurations;
		if (admins.Contains(ZonePermissions.MySteamID))
		{
			return;
		}
		if (configurations.ToLower().Contains("pushaway"))
		{
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(zone.Position.x, ((Component)localPlayer).transform.position.y, zone.Position.y);
			Vector3 position = ((Component)localPlayer).transform.position;
			Vector3 val2 = ((Component)localPlayer).transform.position - val;
			Vector3 val3 = position + ((Vector3)(ref val2)).normalized * 0.15f;
			((Component)localPlayer).transform.position = new Vector3(val3.x, ((Component)localPlayer).transform.position.y, val3.z);
		}
		if (configurations.ToLower().Contains("periodicdamage") && ZonePermissions.DamageTick <= 0)
		{
			ZonePermissions.DamageTick = 100;
			string text = configurations.ToLower();
			int num = text.IndexOf("periodicdamage(") + "periodicdamage(".Length;
			string text2 = "";
			for (int i = num; i < num + 30 && text[i] != ')'; i++)
			{
				text2 += text[i];
			}
			int result = 0;
			HitData val4 = new HitData();
			string[] array = text2.Split(new char[1] { ',' });
			if (array.Count() == 2)
			{
				int.TryParse(array[1], out result);
				if (array[0].ToLower() == "fire")
				{
					val4.m_damage.m_fire = result;
				}
				else if (array[0].ToLower() == "frost")
				{
					val4.m_damage.m_frost = result;
				}
				else if (array[0].ToLower() == "poison")
				{
					val4.m_damage.m_poison = result;
				}
				else if (array[0].ToLower() == "lightning")
				{
					val4.m_damage.m_lightning = result;
				}
				else if (array[0].ToLower() == "pierce")
				{
					val4.m_damage.m_pierce = result;
				}
				else if (array[0].ToLower() == "blunt")
				{
					val4.m_damage.m_blunt = result;
				}
				else if (array[0].ToLower() == "slash")
				{
					val4.m_damage.m_slash = result;
				}
				else if (array[0].ToLower() == "damage")
				{
					val4.m_damage.m_damage = result;
				}
				else
				{
					val4.m_damage.m_fire = result;
				}
			}
			else
			{
				int.TryParse(text2, out result);
				val4.m_damage.m_fire = result;
			}
			((Character)localPlayer).Damage(val4);
		}
		if (configurations.ToLower().Contains("periodicheal") && ZonePermissions.HealTick <= 0)
		{
			ZonePermissions.HealTick = 50;
			string text3 = configurations.ToLower();
			int num2 = text3.IndexOf("periodicheal(") + "periodicheal(".Length;
			string text4 = "";
			for (int j = num2; j < num2 + 20 && text3[j] != ')'; j++)
			{
				text4 += text3[j];
			}
			int result2 = 0;
			int.TryParse(text4, out result2);
			((Character)localPlayer).Heal((float)result2, true);
		}
	}
}
public static class ZoneHandler
{
	public class ZoneTypes
	{
		public string Name = "Unknown";

		public bool PVP = false;

		public bool PVPEnforce = false;

		public bool ShowPosition = true;

		public bool PositionEnforce = false;

		public string Admins = "null";

		public string Configurations = "none";
	}

	public struct Zone
	{
		public int ID;

		public string Name;

		public string Type;

		public int Priority;

		public string Shape;

		public Vector2 Position;

		public float Radius;

		public Zone(int _ID, string _Name, string _Type, int _Priority, string _Shape, Vector2 _Position, float _Radius)
		{
			//IL_0027: 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)
			ID = _ID;
			Name = _Name;
			Type = _Type;
			Priority = _Priority;
			Shape = _Shape;
			Position = _Position;
			Radius = _Radius;
		}
	}

	public static int CurrentZoneID = -2;

	public static List<Zone> Zones = new List<Zone>();

	public static List<ZoneTypes> ZoneT = new List<ZoneTypes>();

	public static void _debug(Zone z)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)$"   {z.ID} ({z.Name}, {z.Type}, {z.Priority}, {z.Position}, {z.Radius})");
	}

	public static void _debug(List<Zone> z)
	{
		Debug.Log((object)"Loaded Zone Data: ");
		Debug.Log((object)("  Zone Cnt: " + z.Count));
		foreach (Zone item in z)
		{
			_debug(item);
		}
	}

	public static void _debug(ZoneTypes zt)
	{
		Debug.Log((object)$"  Type: {zt.Name} -> [ {zt.PVP}, {zt.PVPEnforce}, {zt.ShowPosition}, {zt.PositionEnforce}, [{zt.Admins}], [{zt.Configurations}] ]");
	}

	public static void _debug(List<ZoneTypes> zt)
	{
		Debug.Log((object)"Loaded Zone Type Data: ");
		Debug.Log((object)("  Zone Type Cnt: " + zt.Count));
		foreach (ZoneTypes item in zt)
		{
			_debug(item);
		}
	}

	public static void _debug()
	{
		_debug(ZoneT);
		_debug(Zones);
	}

	public static List<Zone> ListOccupiedZones(Vector3 point)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: 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_0092: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(point.x, point.z);
		List<Zone> list = new List<Zone>();
		foreach (Zone zone in Zones)
		{
			string shape = zone.Shape;
			string text = shape;
			if (text == "square")
			{
				float radius = zone.Radius;
				if (zone.Position.x + radius > val.x && zone.Position.x - radius < val.x && zone.Position.y + radius > val.y && zone.Position.y - radius < val.y)
				{
					list.Add(zone);
				}
			}
			else if (Vector2.Distance(val, zone.Position) <= zone.Radius)
			{
				list.Add(zone);
			}
		}
		return list;
	}

	public static Zone TopZone(List<Zone> z)
	{
		z.Sort((Zone a, Zone b) => a.Priority.CompareTo(b.Priority));
		return z[0];
	}

	public static ZoneTypes FindZoneType(string ztType)
	{
		if (!ZoneT.Any((ZoneTypes b) => b.Name == ztType))
		{
			return new ZoneTypes();
		}
		return ZoneT.Find((ZoneTypes a) => a.Name == ztType) ?? new ZoneTypes();
	}

	public static bool Detect(Vector3 position, out bool changed, out Zone z, out ZoneTypes zt)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		List<Zone> list = ListOccupiedZones(position);
		if (list.Count == 0)
		{
			z = default(Zone);
			zt = new ZoneTypes();
			if (CurrentZoneID != -1)
			{
				CurrentZoneID = -1;
				zt = FindZoneType("wilderness");
				changed = true;
			}
			else
			{
				changed = false;
			}
			return false;
		}
		z = TopZone(list);
		zt = new ZoneTypes();
		if (CurrentZoneID != z.ID)
		{
			zt = FindZoneType(z.Type);
			CurrentZoneID = z.ID;
			changed = true;
		}
		else
		{
			changed = false;
		}
		return true;
	}

	public static ZPackage Serialize(long SteamID = 0L)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		ZPackage val = new ZPackage();
		val.Write(ZoneT.Count);
		foreach (ZoneTypes item in ZoneT)
		{
			val.Write(item.Name);
			val.Write(item.PVP);
			val.Write(item.PVPEnforce);
			val.Write(item.ShowPosition);
			val.Write(item.PositionEnforce);
			val.Write(item.Admins);
			val.Write(item.Configurations);
		}
		val.Write(Zones.Count);
		foreach (Zone zone in Zones)
		{
			val.Write(zone.ID);
			val.Write(zone.Name);
			val.Write(zone.Type);
			val.Write(zone.Priority);
			val.Write(zone.Shape);
			val.Write(zone.Position.x);
			val.Write(zone.Position.y);
			val.Write(zone.Radius);
		}
		return val;
	}

	public static void Deserialize(ZPackage package)
	{
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		ZoneT.Clear();
		int num = package.ReadInt();
		for (int i = 0; i < num; i++)
		{
			ZoneT.Add(new ZoneTypes
			{
				Name = package.ReadString(),
				PVP = package.ReadBool(),
				PVPEnforce = package.ReadBool(),
				ShowPosition = package.ReadBool(),
				PositionEnforce = package.ReadBool(),
				Admins = package.ReadString(),
				Configurations = package.ReadString()
			});
		}
		Zones.Clear();
		int num2 = package.ReadInt();
		for (int j = 0; j < num2; j++)
		{
			Zones.Add(new Zone
			{
				ID = package.ReadInt(),
				Name = package.ReadString(),
				Type = package.ReadString(),
				Priority = package.ReadInt(),
				Shape = package.ReadString(),
				Position = new Vector2(package.ReadSingle(), package.ReadSingle()),
				Radius = package.ReadSingle()
			});
		}
	}

	public static void RPC(ZRpc rpc, ZPackage data)
	{
		Debug.Log((object)"S2C Zone (RPC Call)");
		Debug.Log((object)"Before");
		_debug();
		Deserialize(data);
		Debug.Log((object)"After");
		_debug();
	}

	public static void RPC(long rpc, ZPackage data)
	{
		Debug.Log((object)"S2C Zone (RPC Call)");
		Debug.Log((object)"Before");
		_debug();
		Deserialize(data);
		Debug.Log((object)"After");
		_debug();
	}

	public static void LoadZoneData(string ZonePath)
	{
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)("Loading zone file: " + ZonePath));
		ZoneT.Clear();
		Zones.Clear();
		int num = 0;
		string[] array = File.ReadAllLines(ZonePath);
		foreach (string text in array)
		{
			if (string.IsNullOrWhiteSpace(text) || text[0] == '#')
			{
				continue;
			}
			string[] array2 = text.Split(new char[1] { ' ' });
			if (array2[0].ToLower() == "type:")
			{
				Debug.Log((object)("Loading Type: " + array2[1]));
				ZoneTypes zoneTypes = new ZoneTypes
				{
					Name = array2[1]
				};
				if (array2.Length >= 3)
				{
					zoneTypes.PVP = bool.Parse(array2[2]);
				}
				if (array2.Length >= 4)
				{
					zoneTypes.PVPEnforce = bool.Parse(array2[3]);
				}
				if (array2.Length >= 5)
				{
					zoneTypes.ShowPosition = bool.Parse(array2[4]);
				}
				if (array2.Length >= 6)
				{
					zoneTypes.PositionEnforce = bool.Parse(array2[5]);
				}
				ZoneT.Add(zoneTypes);
			}
			else if (array2[0].ToLower() == "configuration:")
			{
				string text2 = text.Replace(": ", "|");
				string[] array3 = text2.Replace(" | ", "|").Split(new char[1] { '|' });
				ZoneTypes zoneTypes2 = FindZoneType(array3[1]);
				if (zoneTypes2.Name.ToLower() != array3[1].ToString().ToLower())
				{
					Debug.Log((object)("ERROR: While applying custom configuration for the Zone Type: " + array3[1] + ","));
					Debug.Log((object)("Zone Type: " + array3[1] + " Does not exist in the " + ZonePermissions.DefaultZonePath + " file!"));
					return;
				}
				zoneTypes2.Admins = array3[2];
				zoneTypes2.Configurations = array3[3];
			}
			else if (array2.Length != 7)
			{
				Debug.Log((object)("Zone " + text + " is not correctly formated!"));
			}
			else
			{
				Debug.Log((object)("Loading Zone: " + array2[0]));
				Zone item = default(Zone);
				item.Name = array2[0];
				item.Type = array2[1];
				item.Priority = int.Parse(array2[2]);
				item.Shape = array2[3];
				Vector2 val = Vector2.op_Implicit(default(Vector3));
				CultureInfo provider = new CultureInfo("en-US");
				item.Position = new Vector2(Convert.ToSingle(array2[4], provider), Convert.ToSingle(array2[5], provider));
				item.Radius = Convert.ToSingle(array2[6], provider);
				item.ID = num;
				Zones.Add(item);
				num++;
			}
		}
		_debug();
	}
}