Decompiled source of ScarletTeleports v1.1.1

ScarletTeleports.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Microsoft.CodeAnalysis;
using ProjectM.Network;
using ScarletCore.Data;
using ScarletCore.Events;
using ScarletCore.Services;
using ScarletCore.Systems;
using ScarletCore.Utils;
using ScarletTeleports.Data;
using ScarletTeleports.Services;
using ScarletTeleports.Utils;
using Stunlock.Core;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using VampireCommandFramework;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ScarletTeleports")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Teleportation mod")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+56ce6db65beffa5ef256e25339031c1a4c58b290")]
[assembly: AssemblyProduct("ScarletTeleports")]
[assembly: AssemblyTitle("ScarletTeleports")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 ScarletTeleports
{
	public static class ECSExtensions
	{
		public static EntityManager EntityManager => GameSystems.EntityManager;

		public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			byte[] array = StructureToByteArray(componentData);
			int num = Marshal.SizeOf<T>();
			fixed (byte* ptr = array)
			{
				EntityManager entityManager = EntityManager;
				((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num);
			}
		}

		public static byte[] StructureToByteArray<T>(T structure) where T : struct
		{
			int num = Marshal.SizeOf(structure);
			byte[] array = new byte[num];
			IntPtr intPtr = Marshal.AllocHGlobal(num);
			Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true);
			Marshal.Copy(intPtr, array, 0, num);
			Marshal.FreeHGlobal(intPtr);
			return array;
		}

		public unsafe static T Read<T>(this Entity entity) where T : struct
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = EntityManager;
			void* componentDataRawRO = ((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex);
			return Marshal.PtrToStructure<T>(new IntPtr(componentDataRawRO));
		}

		public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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)
			EntityManager entityManager = EntityManager;
			return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity, false);
		}

		public static bool Has<T>(this Entity entity)
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = EntityManager;
			return ((EntityManager)(ref entityManager)).HasComponent(entity, val);
		}

		public static void Add<T>(this Entity entity)
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = EntityManager;
			((EntityManager)(ref entityManager)).AddComponent(entity, val);
		}

		public static void Remove<T>(this Entity entity)
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = EntityManager;
			((EntityManager)(ref entityManager)).RemoveComponent(entity, val);
		}

		public static float3 GetPosition(this Entity entity)
		{
			//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_0009: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = EntityManager;
			if (!((EntityManager)(ref entityManager)).HasComponent<Translation>(entity))
			{
				return float3.zero;
			}
			entityManager = EntityManager;
			return ((EntityManager)(ref entityManager)).GetComponentData<Translation>(entity).Value;
		}
	}
	[BepInPlugin("ScarletTeleports", "ScarletTeleports", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		private static Harmony _harmony;

		public static Harmony Harmony => _harmony;

		public static Plugin Instance { get; private set; }

		public static ManualLogSource LogInstance { get; private set; }

		public static Settings Settings { get; private set; }

		public static Database Database { get; private set; }

		public override void Load()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			Instance = this;
			LogInstance = ((BasePlugin)this).Log;
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ScarletTeleports");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.1.1");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			_harmony = new Harmony("ScarletTeleports");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			Settings = new Settings("ScarletTeleports", (BasePlugin)(object)Instance);
			Database = new Database("ScarletTeleports");
			LoadSettings();
			if (GameSystems.Initialized)
			{
				TeleportManager.Initialize(null, null);
			}
			else
			{
				EventManager.OnInitialize += TeleportManager.Initialize;
			}
			CommandRegistry.RegisterAll();
		}

		public override bool Unload()
		{
			CommandRegistry.UnregisterAssembly();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			return true;
		}

		public static void LoadSettings()
		{
			Settings.Section("General").Add<bool>("EnablePersonalTeleports", true, "If enabled, allows players to create personal teleports.").Add<bool>("EnablePersonalCooldown", true, "Enables cooldown for personal teleports.")
				.Add<bool>("EnableGlobalCooldown", true, "Enables cooldown for global teleports.")
				.Add<bool>("EnableDraculaRoom", false, "Enables teleporting from and to the Dracula's room.")
				.Add<bool>("EnableTeleportInCombat", false, "Enables teleporting while in combat globally.")
				.Add<bool>("EnableTeleportBetweenPlayers", true, "Enables teleporting between players.")
				.Add<int>("DefaultMaximumPersonalTeleports", 3, "The maximum number of personal teleports a player can have.");
			Settings.Section("Timers").Add<int>("TeleportRequestExpiration", 30, "The expiration time in seconds of a teleport request.").Add<int>("DefaultPersonalCooldown", 30, "The cooldown in seconds for personal teleports.")
				.Add<int>("DefaultGlobalCooldown", 30, "The cooldown in seconds for global teleports.");
			Settings.Section("Prefabs").Add<string>("DefaultPersonalPrefabName", "Blood Essence", "The name of the prefab that will be consumed when teleporting to a personal teleport.").Add<int>("DefaultPersonalPrefabGUID", 862477668, "The prefab that will be consumed when teleporting to a personal teleport.")
				.Add<int>("DefaultGlobalPrefabGUID", 862477668, "The prefab that will be consumed when teleporting to a global teleport.")
				.Add<string>("DefaultGlobalPrefabName", "Blood Essence", "The name of the prefab that will be consumed when teleporting to a global teleport.");
			Settings.Section("Costs").Add<int>("DefaultPersonalCost", 100, "The amount of the prefab that will be consumed when teleporting to a personal teleport.").Add<int>("DefaultGlobalCost", 50, "The amount of the prefab that will be consumed when teleporting to a global teleport.");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ScarletTeleports";

		public const string PLUGIN_NAME = "ScarletTeleports";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace ScarletTeleports.Utils
{
	public static class StringExtensions
	{
		public static string HighlightColor = "#a963ff";

		public static string HighlightErrorColor = "#ff4040";

		public static string HighlightWarningColor = "#ffff00";

		public static string TextColor = "#ffffff";

		public static string ErrorTextColor = "#ff8f8f";

		public static string WarningTextColor = "#ffff9e";

		public static string Bold(this string text)
		{
			return "<b>" + text + "</b>";
		}

		public static string Italic(this string text)
		{
			return "<i>" + text + "</i>";
		}

		public static string Underline(this string text)
		{
			return "<u>" + text + "</u>";
		}

		public static string Red(this string text)
		{
			return "<color=red>" + text + "</color>";
		}

		public static string Green(this string text)
		{
			return "<color=green>" + text + "</color>";
		}

		public static string Blue(this string text)
		{
			return "<color=blue>" + text + "</color>";
		}

		public static string Yellow(this string text)
		{
			return "<color=yellow>" + text + "</color>";
		}

		public static string White(this string text)
		{
			return "<color=white>" + text + "</color>";
		}

		public static string Black(this string text)
		{
			return "<color=black>" + text + "</color>";
		}

		public static string Orange(this string text)
		{
			return "<color=orange>" + text + "</color>";
		}

		public static string Lime(this string text)
		{
			return "<color=#00FF00>" + text + "</color>";
		}

		public static string Gray(this string text)
		{
			return "<color=#cccccc>" + text + "</color>";
		}

		public static string Hex(this string hex, string text)
		{
			return $"<color={hex}>{text}</color>";
		}

		public static string Format(this string text, List<string> highlightColors = null)
		{
			if (highlightColors == null)
			{
				highlightColors = new List<string>(1) { HighlightColor };
			}
			return ApplyFormatting(text, TextColor, highlightColors);
		}

		public static string FormatError(this string text)
		{
			return ApplyFormatting(text, ErrorTextColor, new List<string>(1) { HighlightErrorColor });
		}

		public static string FormatWarning(this string text)
		{
			return ApplyFormatting(text, WarningTextColor, new List<string>(1) { HighlightWarningColor });
		}

		private static string ApplyFormatting(string text, string baseColor, List<string> highlightColors)
		{
			string pattern = "\\*\\*(.*?)\\*\\*";
			string pattern2 = "\\*(.*?)\\*";
			string pattern3 = "__(.*?)__";
			string pattern4 = "~(.*?)~";
			string input = Regex.Replace(text, pattern, (Match m) => m.Groups[1].Value.Bold());
			input = Regex.Replace(input, pattern2, (Match m) => m.Groups[1].Value.Italic());
			input = Regex.Replace(input, pattern3, (Match m) => m.Groups[1].Value.Underline());
			int highlightIndex = 0;
			input = Regex.Replace(input, pattern4, delegate(Match m)
			{
				string text2 = ((highlightIndex < highlightColors.Count) ? highlightColors[highlightIndex] : HighlightColor);
				if (text2 == null)
				{
					text2 = HighlightColor;
				}
				highlightIndex++;
				return text2.Hex(m.Groups[1].Value);
			});
			return baseColor.Hex(input);
		}
	}
}
namespace ScarletTeleports.Services
{
	public class TeleportManager
	{
		private static Settings Settings => Plugin.Settings;

		private static Database Database => Plugin.Database;

		public static HashSet<TeleportData> PersonalTeleports { get; private set; } = new HashSet<TeleportData>();


		public static Dictionary<string, TeleportData> GlobalTeleports { get; private set; } = new Dictionary<string, TeleportData>();


		public static Dictionary<ulong, PlayerTeleportData> PlayerTeleports { get; private set; } = new Dictionary<ulong, PlayerTeleportData>();


		public static Dictionary<string, ZoneData> RestrictedZones { get; private set; } = new Dictionary<string, ZoneData>();


		public static void Initialize(object _, object __)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			EventManager.OnInitialize -= Initialize;
			LoadGlobalTeleports();
			LoadRestrictedZones();
			ActionScheduler.Repeating((Action)CheckForExpiredRequests, 20f, -1);
			LoadPersonalTeleports();
			EventManager.OnUserConnected += LoadPersonalTeleportEvent;
		}

		public static void LoadPersonalTeleportEvent(object _, UserConnectedEventArgs args)
		{
			PlayerData player = args.Player;
			LoadPersonalTeleports(player);
		}

		public static void AddPersonalTeleport(TeleportData teleportData)
		{
			TeleportData teleportData2 = PersonalTeleports.FirstOrDefault((TeleportData t) => t.Name.Equals(teleportData.Name, StringComparison.OrdinalIgnoreCase) && t.PlatformID == teleportData.PlatformID);
			if (teleportData2 != null && !teleportData2.Equals(null))
			{
				PersonalTeleports.Remove(teleportData2);
			}
			PersonalTeleports.Add(teleportData);
		}

		public static void AddGlobalTeleport(TeleportData teleportData)
		{
			GlobalTeleports[teleportData.Name] = teleportData;
		}

		public static bool IsPlayerInCombat(Entity player)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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)
			return BuffService.HasBuff(player, new PrefabGUID(581443919)) || BuffService.HasBuff(player, new PrefabGUID(697095869));
		}

		public static bool IsInDraculaRoom(Entity player)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			float3 position = player.GetPosition();
			float3 val = default(float3);
			((float3)(ref val))..ctor(720f, 15f, -2827f);
			float num = math.distance(position, val);
			return num < 80f;
		}

		public static void CreateGlobalTeleport(TeleportData teleportData)
		{
			if (HasGlobalTeleport(teleportData.Name))
			{
				Log.Warning((object)("Teleport " + teleportData.Name + " already exists."));
				return;
			}
			AddGlobalTeleport(teleportData);
			SaveGlobalTeleports();
		}

		public static PlayerTeleportData GetCustomPlayerData(PlayerData player)
		{
			PlayerTeleportData playerTeleportData = PlayerTeleports.GetValueOrDefault(player.PlatformId);
			if (playerTeleportData == null)
			{
				playerTeleportData = new PlayerTeleportData();
				PlayerTeleports[player.PlatformId] = playerTeleportData;
			}
			return playerTeleportData;
		}

		public static void CreatePersonalTeleport(PlayerData player, TeleportData teleportData)
		{
			PlayerTeleportData customPlayerData = GetCustomPlayerData(player);
			customPlayerData.AddTeleport(teleportData);
			AddPersonalTeleport(teleportData);
			SavePersonalTeleport(player);
		}

		public static void SaveGlobalTeleports()
		{
			Database.Save<List<TeleportData>>("GlobalTeleports", GlobalTeleports.Values.ToList());
		}

		public static void SaveAllPersonalTeleports()
		{
			foreach (PlayerData allPlayer in PlayerService.AllPlayers)
			{
				SavePersonalTeleport(allPlayer);
			}
		}

		public static void SavePersonalTeleport(PlayerData player)
		{
			Database.Save<PlayerTeleportData>($"PersonalTeleports/{player.PlatformId}", GetCustomPlayerData(player));
		}

		public static TeleportData GetGlobalTeleport(string name)
		{
			return GlobalTeleports[name];
		}

		public static bool HasGlobalTeleport(string name)
		{
			return GlobalTeleports.ContainsKey(name);
		}

		public static void LoadGlobalTeleports()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			List<TeleportData> list = Database.Load<List<TeleportData>>("GlobalTeleports") ?? new List<TeleportData>();
			if (list == null)
			{
				return;
			}
			foreach (TeleportData item in list)
			{
				if (item.IsDefaultCost)
				{
					item.Cost = Settings.Get<int>("DefaultGlobalCost");
				}
				if (item.IsDefaultPrefab)
				{
					item.PrefabGUID = new PrefabGUID(Settings.Get<int>("DefaultGlobalPrefabGUID"));
				}
				if (item.IsDefaultCooldown)
				{
					item.Cooldown = Settings.Get<int>("DefaultGlobalCooldown");
				}
				AddGlobalTeleport(item);
			}
			SaveGlobalTeleports();
		}

		public static void LoadPersonalTeleports()
		{
			foreach (PlayerData allPlayer in PlayerService.AllPlayers)
			{
				LoadPersonalTeleports(allPlayer);
			}
		}

		public static bool LoadPersonalTeleports(PlayerData player)
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			PlayerTeleportData customPlayerData = GetCustomPlayerData(player);
			customPlayerData.Teleports.Clear();
			PlayerTeleportData playerTeleportData = Database.Load<PlayerTeleportData>($"PersonalTeleports/{player.PlatformId}");
			if (playerTeleportData == null)
			{
				return false;
			}
			HashSet<TeleportData> teleports = playerTeleportData.Teleports;
			customPlayerData.MaxTeleports = playerTeleportData.MaxTeleports;
			customPlayerData.BypassCost = playerTeleportData.BypassCost;
			customPlayerData.BypassCooldown = playerTeleportData.BypassCooldown;
			customPlayerData.BypassDraculaRoom = playerTeleportData.BypassDraculaRoom;
			customPlayerData.BypassCombat = playerTeleportData.BypassCombat;
			if (teleports == null)
			{
				return false;
			}
			foreach (TeleportData item in teleports)
			{
				if (item.IsDefaultCost)
				{
					item.Cost = Settings.Get<int>("DefaultPersonalCost");
				}
				if (item.IsDefaultPrefab)
				{
					item.PrefabGUID = new PrefabGUID(Settings.Get<int>("DefaultPersonalPrefabGUID"));
				}
				if (item.IsDefaultCooldown)
				{
					item.Cooldown = Settings.Get<int>("DefaultPersonalCooldown");
				}
				customPlayerData.AddTeleport(item);
				AddPersonalTeleport(item);
			}
			SavePersonalTeleport(player);
			return true;
		}

		public static bool RemovePersonalTeleport(PlayerData player, string name)
		{
			PlayerTeleportData customPlayerData = GetCustomPlayerData(player);
			if (!customPlayerData.HasTeleport(name))
			{
				return false;
			}
			TeleportData teleport = customPlayerData.GetTeleport(name);
			customPlayerData.RemoveTeleport(name);
			PersonalTeleports.Remove(teleport);
			SavePersonalTeleport(player);
			return true;
		}

		public static bool RemoveGlobalTeleport(string name)
		{
			TeleportData globalTeleport = GetGlobalTeleport(name);
			if (!globalTeleport.Equals(null))
			{
				GlobalTeleports.Remove(globalTeleport.Name);
				SaveGlobalTeleports();
				return true;
			}
			Log.Warning((object)("Teleport " + name + " not found."));
			return false;
		}

		public static HashSet<TeleportData> GetAllTeleports()
		{
			HashSet<TeleportData> first = new HashSet<TeleportData>();
			return first.Union(GlobalTeleports.Values.ToHashSet()).Union(PersonalTeleports).ToHashSet();
		}

		public static void CheckForExpiredRequests()
		{
			foreach (PlayerData allPlayer in PlayerService.AllPlayers)
			{
				PlayerTeleportData customPlayerData = GetCustomPlayerData(allPlayer);
				customPlayerData.PendingRequests.RemoveWhere(delegate(TeleportRequestData request)
				{
					bool flag = request.ExpirationTime <= DateTime.Now;
					PlayerData player = default(PlayerData);
					if (flag && PlayerService.TryGetById(request.PlatformID, ref player))
					{
						PlayerTeleportData customPlayerData2 = GetCustomPlayerData(player);
						customPlayerData2.CanResquestTeleports = true;
					}
					return flag;
				});
			}
		}

		public static void CreateRestrictedZone(ZoneData zone)
		{
			RestrictedZones.Add(zone.Name, zone);
			SaveRestrictedZones();
		}

		public static void LoadRestrictedZones()
		{
			Dictionary<string, ZoneData> dictionary = Database.Load<Dictionary<string, ZoneData>>("RestrictedZones");
			if (dictionary != null)
			{
				RestrictedZones.Clear();
				RestrictedZones = dictionary;
			}
		}

		public static ZoneData GetRestrictedZone(float3 position)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			float3 val = default(float3);
			foreach (ZoneData value in RestrictedZones.Values)
			{
				((float3)(ref val))..ctor(value.Position[0], value.Position[1], value.Position[2]);
				if (math.distance(position, val) < value.Radius)
				{
					return value;
				}
			}
			return null;
		}

		public static void SaveRestrictedZones()
		{
			Database.Save<Dictionary<string, ZoneData>>("RestrictedZones", RestrictedZones);
		}

		public static bool RemoveRestrictedZone(string name)
		{
			bool result = RestrictedZones.Remove(name);
			SaveRestrictedZones();
			return result;
		}
	}
}
namespace ScarletTeleports.Data
{
	public class PlayerTeleportData
	{
		public int MaxTeleports { get; set; } = Plugin.Settings.Get<int>("DefaultMaximumPersonalTeleports");


		public bool BypassCost { get; set; } = false;


		public bool BypassCooldown { get; set; } = false;


		public bool BypassDraculaRoom { get; set; } = false;


		public bool BypassCombat { get; set; } = false;


		[JsonIgnore]
		public bool CanResquestTeleports { get; set; } = true;


		public bool BypassRestrictedZones { get; set; } = false;


		public HashSet<TeleportData> Teleports { get; set; } = new HashSet<TeleportData>();


		[JsonIgnore]
		public HashSet<TeleportRequestData> PendingRequests { get; set; } = new HashSet<TeleportRequestData>();


		[JsonIgnore]
		public DateTime LastTeleportTime { get; set; } = DateTime.Now.AddHours(-1.0);


		[JsonIgnore]
		public bool LoadedTeleports { get; set; } = false;


		public void AddTeleport(TeleportData teleport)
		{
			if (teleport != null)
			{
				TeleportData teleportData = Teleports.FirstOrDefault((TeleportData t) => t.Name.Equals(teleport.Name, StringComparison.OrdinalIgnoreCase));
				if (teleportData != null && !teleportData.Equals(null))
				{
					Teleports.Remove(teleportData);
				}
				Teleports.Add(teleport);
			}
		}

		public TeleportData GetTeleport(string name)
		{
			return Teleports.FirstOrDefault((TeleportData t) => t.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
		}

		public bool HasTeleport(string name)
		{
			return Teleports.Any((TeleportData t) => t.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
		}

		public int RemoveTeleport(string name)
		{
			return Teleports.RemoveWhere((TeleportData t) => t.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
		}

		public void ClearTeleports()
		{
			Teleports.Clear();
		}
	}
	[JsonSerializable(typeof(TeleportData))]
	public class TeleportData
	{
		public string Name { get; set; }

		public string CharacterName { get; set; }

		[JsonIgnore]
		public float3 Position { get; set; }

		[JsonPropertyName("Position")]
		public List<float> PositionSerialized
		{
			get
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				return new List<float>(3) { Position.x, Position.y, Position.z };
			}
			set
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				if (value != null && value.Count == 3)
				{
					Position = new float3(value[0], value[1], value[2]);
				}
			}
		}

		[JsonIgnore]
		public PrefabGUID PrefabGUID { get; set; }

		[JsonPropertyName("PrefabGUID")]
		public int PrefabGUIDSerialized
		{
			get
			{
				//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)
				PrefabGUID prefabGUID = PrefabGUID;
				return ((PrefabGUID)(ref prefabGUID)).GuidHash;
			}
			set
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				PrefabGUID = new PrefabGUID(value);
			}
		}

		public string PrefabName { get; set; }

		public int Cost { get; set; }

		public int Cooldown { get; set; }

		public bool IsDefaultCost { get; set; } = true;


		public bool IsDefaultPrefab { get; set; } = true;


		public bool IsDefaultCooldown { get; set; } = true;


		public ulong PlatformID { get; set; }

		public override bool Equals(object obj)
		{
			if (!(obj is TeleportData teleportData))
			{
				return false;
			}
			return Name.Equals(teleportData.Name, StringComparison.OrdinalIgnoreCase);
		}

		public override int GetHashCode()
		{
			return Name.ToLowerInvariant().GetHashCode();
		}
	}
	public class TeleportRequestData
	{
		public ulong PlatformID { get; set; }

		public DateTime ExpirationTime { get; set; } = DateTime.Now.AddSeconds(Plugin.Settings.Get<int>("TeleportRequestExpiration"));


		public TeleportRequestData(ulong platformID)
		{
			PlatformID = platformID;
		}
	}
	public class ZoneData
	{
		public string Name { get; set; }

		public List<float> Position { get; set; }

		public float Radius { get; set; }

		public bool CanTeleportTo { get; set; }

		public bool CanTeleportFrom { get; set; }

		public ZoneData(string name, List<float> position, float radius, bool canTeleportTo = false, bool canTeleportFrom = false)
		{
			Name = name;
			Position = position;
			Radius = radius;
			CanTeleportTo = canTeleportTo;
			CanTeleportFrom = canTeleportFrom;
			base..ctor();
		}
	}
}
namespace ScarletTeleports.Commands
{
	[CommandGroup("stp", null)]
	public static class AdminCommands
	{
		private static Settings Settings => Plugin.Settings;

		[Command("goto", null, "<x> <y> <z>", null, null, true)]
		public static void GotoTeleport(ChatCommandContext ctx, int x, int y, int z)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetPlayerById(ctx, out var player))
			{
				TeleportService.TeleportToPosition(player.CharacterEntity, new float3((float)x, (float)y, (float)z), true);
				ctx.Reply($"Teleported you to ~({x}, {y}, {z})~.".Format());
			}
		}

		[Command("goto", null, "<player-name>", null, null, true)]
		public static void GotoTeleport(ChatCommandContext ctx, string playerName)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			if (TryGetPlayerById(ctx, out var player) && TryGetPlayerByName(ctx, playerName, out var player2))
			{
				TeleportService.TeleportToPosition(player.CharacterEntity, player2.CharacterEntity.GetPosition(), true);
				ctx.Reply(("Teleported you to ~" + playerName + "~.").Format());
			}
		}

		[Command("summon all", null, null, null, null, true)]
		public static void SummonAllPlayers(ChatCommandContext ctx)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (!TryGetPlayerById(ctx, out var player))
			{
				return;
			}
			List<PlayerData> allPlayers = PlayerService.AllPlayers;
			foreach (PlayerData item in allPlayers)
			{
				if (item.IsOnline)
				{
					TeleportService.TeleportToPosition(item.CharacterEntity, player.CharacterEntity.GetPosition(), true);
				}
			}
			ctx.Reply("Teleported ~All~ players to you.".Format());
		}

		[Command("summon", null, "<player-name>", null, null, true)]
		public static void SummonPlayer(ChatCommandContext ctx, string playerName)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			if (TryGetPlayerById(ctx, out var player) && TryGetPlayerByName(ctx, playerName, out var player2))
			{
				TeleportService.TeleportToPosition(player2.CharacterEntity, player.CharacterEntity.GetPosition(), true);
				ctx.Reply(("Teleported ~" + playerName + "~ to you.").Format());
			}
		}

		[Command("add global", null, "<teleport-name> <x> <y> <z>", null, null, true)]
		public static void AddTeleport(ChatCommandContext ctx, string teleportName, float x, float y, float z)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			CreateGlobalTeleport(ctx, teleportName, x, y, z);
		}

		[Command("add global", null, "<teleport-name>", null, null, true)]
		public static void AddTeleport(ChatCommandContext ctx, string teleportName)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			float3 position = ctx.Event.SenderCharacterEntity.GetPosition();
			CreateGlobalTeleport(ctx, teleportName, position.x, position.y, position.z);
		}

		[Command("make global", null, "<teleport-name> <prefab-name> <prefab-guid> <cost> <cooldown> <x> <y> <z>", null, null, true)]
		public static void MakeTeleportGlobal(ChatCommandContext ctx, string teleportName, string perfabName, int prefabGUID, int cost, int cooldown, int x, int y, int z)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			PrefabGUID prefabGUID2 = default(PrefabGUID);
			if (!PrefabGUID.TryParse(prefabGUID.ToString(), ref prefabGUID2))
			{
				ctx.Reply($"Prefab {prefabGUID} is invalid.".FormatError());
			}
			else
			{
				CreateGlobalTeleport(ctx, teleportName, x, y, z, perfabName, prefabGUID2, cost, cooldown);
			}
		}

		[Command("make global", null, "<teleport-name> <prefab-name> <prefab-guid> <cost> <cooldown>", null, null, true)]
		public static void MakeTeleportGlobal(ChatCommandContext ctx, string teleportName, string perfabName, int prefabGUID, int cost, int cooldown)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			PrefabGUID prefabGUID2 = default(PrefabGUID);
			if (!PrefabGUID.TryParse(prefabGUID.ToString(), ref prefabGUID2))
			{
				ctx.Reply($"Prefab {prefabGUID} is invalid.".FormatError());
			}
			else
			{
				float3 position = ctx.Event.SenderCharacterEntity.GetPosition();
				CreateGlobalTeleport(ctx, teleportName, position.x, position.y, position.z, perfabName, prefabGUID2, cost, cooldown);
			}
		}

		[Command("remove global", null, "<teleport-name>", null, null, true)]
		public static void RemoveTeleport(ChatCommandContext ctx, string teleportName)
		{
			if (TeleportManager.RemoveGlobalTeleport(teleportName))
			{
				ctx.Reply(("Global Teleport ~" + teleportName + "~ removed successfully.").Format());
			}
			else
			{
				ctx.Reply(("Global Teleport ~" + teleportName + "~ not found.").FormatError());
			}
		}

		[Command("add personal", null, "<player-name> <teleport-name> <x> <y> <z>", null, null, true)]
		public static void AddTeleport(ChatCommandContext ctx, string playerName, string teleportName, int x, int y, int z)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetPlayerByName(ctx, playerName, out var player))
			{
				CreatePersonalTeleport(ctx, player, playerName, teleportName, x, y, z);
			}
		}

		[Command("add personal", null, "<player-name> <teleport-name>", null, null, true)]
		public static void AddTeleport(ChatCommandContext ctx, string playerName, string teleportName)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetPlayerByName(ctx, playerName, out var player))
			{
				float3 position = ctx.Event.SenderCharacterEntity.GetPosition();
				CreatePersonalTeleport(ctx, player, playerName, teleportName, position.x, position.y, position.z);
			}
		}

		[Command("make personal", null, "<player-name> <teleport-name> <prefab-name> <prefab-guid> <cost> <cooldown> <x> <y> <z>", null, null, true)]
		public static void MakeTeleport(ChatCommandContext ctx, string playerName, string teleportName, string prefabName, int prefabGUID, int cost, int cooldown, int x, int y, int z)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetPlayerByName(ctx, playerName, out var player))
			{
				PrefabGUID prefabGUID2 = default(PrefabGUID);
				if (!PrefabGUID.TryParse(prefabGUID.ToString(), ref prefabGUID2))
				{
					ctx.Reply($"Prefab {prefabGUID} is invalid.".FormatError());
				}
				else
				{
					CreatePersonalTeleport(ctx, player, playerName, teleportName, x, y, z, prefabName, prefabGUID2, cost, cooldown);
				}
			}
		}

		[Command("make personal", null, "<player-name> <teleport-name> <prefab-name> <prefab-guid> <cost> <cooldown>", null, null, true)]
		public static void MakeTeleport(ChatCommandContext ctx, string playerName, string teleportName, string perfabName, int prefabGUID, int cost, int cooldown)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_008c: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetPlayerByName(ctx, playerName, out var player))
			{
				float3 position = ctx.Event.SenderCharacterEntity.GetPosition();
				PrefabGUID prefabGUID2 = default(PrefabGUID);
				if (!PrefabGUID.TryParse(prefabGUID.ToString(), ref prefabGUID2))
				{
					ctx.Reply($"Prefab {prefabGUID} is invalid.".FormatError());
				}
				else
				{
					CreatePersonalTeleport(ctx, player, playerName, teleportName, position.x, position.y, position.z, perfabName, prefabGUID2, cost, cooldown);
				}
			}
		}

		[Command("remove personal", null, "<player-name> <teleport-name>", null, null, true)]
		public static void RemoveTeleport(ChatCommandContext ctx, string playerName, string teleportName)
		{
			if (TryGetPlayerByName(ctx, playerName, out var player))
			{
				if (TeleportManager.RemovePersonalTeleport(player, teleportName))
				{
					ctx.Reply(("Teleport ~" + teleportName + "~ removed successfully.").Format());
				}
				else
				{
					ctx.Reply(("Teleport ~" + teleportName + "~ not found.").FormatError());
				}
			}
		}

		[Command("add restricted", null, "<name> <radius> <x> <y> <z>", null, null, true)]
		public static void AddRestrictedZone(ChatCommandContext ctx, string name, float radius, int x, int y, int z)
		{
			CreateRestrictedZone(ctx, name, radius, x, y, z);
		}

		[Command("add restricted", null, "<name> <radius>", null, null, true)]
		public static void AddRestrictedZone(ChatCommandContext ctx, string name, float radius)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetPlayerById(ctx, out var player))
			{
				float3 position = player.CharacterEntity.GetPosition();
				CreateRestrictedZone(ctx, name, radius, position.x, position.y, position.z);
			}
		}

		[Command("make restricted", null, "<name> <radius> <can-teleport-to> <can-teleport-from> <x> <y> <z>", null, null, true)]
		public static void MakeRestrictedZone(ChatCommandContext ctx, string name, float radius, bool canTeleportTo, bool canTeleportFrom, int x, int y, int z)
		{
			CreateRestrictedZone(ctx, name, radius, x, y, z, canTeleportTo, canTeleportFrom);
		}

		[Command("make restricted", null, "<name> <radius> <can-teleport-to> <can-teleport-from>", null, null, true)]
		public static void MakeRestrictedZone(ChatCommandContext ctx, string name, float radius, bool canTeleportTo, bool canTeleportFrom)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetPlayerById(ctx, out var player))
			{
				float3 position = player.CharacterEntity.GetPosition();
				CreateRestrictedZone(ctx, name, radius, position.x, position.y, position.z, canTeleportTo, canTeleportFrom);
			}
		}

		[Command("remove restricted", null, "<name>", null, null, true)]
		public static void RemoveRestricted(ChatCommandContext ctx, string name)
		{
			if (TeleportManager.RemoveRestrictedZone(name))
			{
				ctx.Reply(("Restricted area ~" + name + "~ removed successfully.").Format());
			}
			else
			{
				ctx.Reply(("Restricted area ~" + name + "~ not found.").FormatError());
			}
		}

		[Command("list all", null, null, null, null, true)]
		public static void ListAll(ChatCommandContext ctx)
		{
			HashSet<TeleportData> allTeleports = TeleportManager.GetAllTeleports();
			ctx.Reply("__**~All Teleports:~**__".Format());
			foreach (TeleportData item in allTeleports)
			{
				ctx.Reply((" • ~" + item.Name + "~ " + ((item.CharacterName != null) ? ("- Owned by ~" + item.CharacterName + "~") : "- ~Global~")).Format());
			}
			ctx.Reply($"Total: ~{allTeleports.Count}~ teleports.".Format());
		}

		[Command("list restricted", null, null, null, null, true)]
		public static void ListRestrictedZones(ChatCommandContext ctx)
		{
			Dictionary<string, ZoneData> restrictedZones = TeleportManager.RestrictedZones;
			ctx.Reply("__**~Restricted Zones:~**__".Format());
			foreach (ZoneData value in restrictedZones.Values)
			{
				ctx.Reply($" • ~{value.Name}~ - Radius: ~{value.Radius}~ ({value.Position[0]}, {value.Position[1]}, {value.Position[2]})".Format());
			}
			ctx.Reply($"Total: ~{restrictedZones.Count}~ zones.".Format());
		}

		[Command("list global", null, null, null, null, true)]
		public static void ListTeleports(ChatCommandContext ctx)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			Dictionary<string, TeleportData> globalTeleports = TeleportManager.GlobalTeleports;
			ctx.Reply("__**~Global Teleports:~**__".Format());
			foreach (TeleportData value in globalTeleports.Values)
			{
				ctx.Reply($" • ~{value.Name}~ ({value.Position.x}, {value.Position.y}, {value.Position.z})".Format());
			}
			ctx.Reply($"Total: ~{globalTeleports.Count}~ teleports.".Format());
		}

		[Command("list", null, null, null, null, true)]
		public static void ListPlayerTeleports(ChatCommandContext ctx, string playerName)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			if (!TryGetPlayerByName(ctx, playerName, out var player))
			{
				return;
			}
			ctx.Reply(("**Teleports for ~" + playerName + "~:**").Format());
			PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
			HashSet<TeleportData> teleports = customPlayerData.Teleports;
			foreach (TeleportData item in teleports)
			{
				ctx.Reply($" • ~{item.Name}~ ({item.Position.x}, {item.Position.y}, {item.Position.z})".Format());
			}
			ctx.Reply($"Total: ~{teleports.Count}~ teleports.".Format());
		}

		[Command("bypass", null, "<player-name> <cost|cooldown|dracularoom|combat|restricted> <true|false>", null, null, true)]
		public static void SetBypassOption(ChatCommandContext ctx, string playerName, string option, bool value)
		{
			if (TryGetPlayerByName(ctx, playerName, out var player))
			{
				PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
				switch (option.ToLower())
				{
				case "cost":
					customPlayerData.BypassCost = value;
					break;
				case "cooldown":
					customPlayerData.BypassCooldown = value;
					break;
				case "dracularoom":
					customPlayerData.BypassDraculaRoom = value;
					break;
				case "combat":
					customPlayerData.BypassCombat = value;
					break;
				case "restricted":
					customPlayerData.BypassRestrictedZones = value;
					break;
				default:
					ctx.Reply("~Invalid option.~ Use: cost, cooldown, dracularoom, or combat.".FormatError());
					return;
				}
				TeleportManager.SavePersonalTeleport(player);
				ctx.Reply($"Bypass ~{option.ToLower()}~ for ~{playerName}~ set to ~{value}~.".Format());
			}
		}

		[Command("set default", null, "<global|personal> <prefabname|prefabguid|cost|cooldown> <value>", null, null, true)]
		public static void SetDefaults(ChatCommandContext ctx, string teleportType, string defaultType, string defaultValue)
		{
			teleportType = teleportType.ToLower();
			defaultType = defaultType.ToLower();
			defaultValue = defaultValue.ToLower();
			if (teleportType != "global" && teleportType != "personal")
			{
				ctx.Reply(("Invalid teleport type ~" + teleportType + "~.").FormatError());
				return;
			}
			if (defaultType != "prefabname" && defaultType != "prefabguid" && defaultType != "cost" && defaultType != "cooldown")
			{
				ctx.Reply(("Invalid default type ~" + defaultType + "~.").FormatError());
				return;
			}
			if (teleportType == "global")
			{
				switch (defaultType)
				{
				case "prefabname":
					Settings.Set<string>("DefaultGlobalPrefabName", defaultValue);
					break;
				case "prefabguid":
					Settings.Set<int>("DefaultGlobalPrefabGUID", int.Parse(defaultValue));
					break;
				case "cost":
					Settings.Set<int>("DefaultGlobalCost", int.Parse(defaultValue));
					break;
				case "cooldown":
					Settings.Set<int>("DefaultGlobalCooldown", int.Parse(defaultValue));
					break;
				}
			}
			if (teleportType == "personal")
			{
				switch (defaultType)
				{
				case "prefabname":
					Settings.Set<string>("DefaultPersonalPrefabName", defaultValue);
					break;
				case "prefabguid":
					Settings.Set<int>("DefaultPersonalPrefabGUID", int.Parse(defaultValue));
					break;
				case "cost":
					Settings.Set<int>("DefaultPersonalCost", int.Parse(defaultValue));
					break;
				case "cooldown":
					Settings.Set<int>("DefaultPersonalCooldown", int.Parse(defaultValue));
					break;
				}
			}
		}

		[Command("set maxteleports", null, "<player-name> <max-teleports>", null, null, true)]
		public static void SetMaxTeleports(ChatCommandContext ctx, string playerName, int maxTeleports)
		{
			if (TryGetPlayerByName(ctx, playerName, out var player))
			{
				if (maxTeleports < 0)
				{
					ctx.Reply("Max teleports cannot be negative.".FormatError());
					return;
				}
				PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
				customPlayerData.MaxTeleports = maxTeleports;
				TeleportManager.SavePersonalTeleport(player);
				ctx.Reply($"Max teleports for ~{playerName}~ set to ~{maxTeleports}~.".Format());
			}
		}

		[Command("set cost", null, "<player-name> <teleport-name> <cost>", null, null, true)]
		public static void SetTeleportCost(ChatCommandContext ctx, string playerName, string teleportName, int cost)
		{
			if (TryGetPlayerByName(ctx, playerName, out var player))
			{
				PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
				TeleportData teleport = customPlayerData.GetTeleport(teleportName);
				if (teleport.Equals(null))
				{
					ctx.Reply(("Teleport ~" + teleportName + "~ not found.").FormatError());
					return;
				}
				teleport.Cost = cost;
				teleport.IsDefaultCost = false;
				TeleportManager.SavePersonalTeleport(player);
				ctx.Reply($"Teleport ~{teleportName}~ cost set to ~{cost}~.".Format());
			}
		}

		[Command("set cost", null, "<global-teleport-name> <cost>", null, null, true)]
		public static void SetTeleportCost(ChatCommandContext ctx, string teleportName, int cost)
		{
			TeleportData globalTeleport = TeleportManager.GetGlobalTeleport(teleportName);
			if (globalTeleport.Equals(null))
			{
				ctx.Reply(("Teleport ~" + teleportName + "~ not found.").FormatError());
				return;
			}
			globalTeleport.Cost = cost;
			TeleportManager.SaveGlobalTeleports();
			ctx.Reply($"Teleport ~{teleportName}~ cost set to ~{cost}~.".Format());
		}

		[Command("set cooldown", null, "<player-name> <teleport-name> <cooldown>", null, null, true)]
		public static void SetTeleportCooldown(ChatCommandContext ctx, string playerName, string teleportName, int cooldown)
		{
			if (TryGetPlayerByName(ctx, playerName, out var player))
			{
				PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
				TeleportData teleport = customPlayerData.GetTeleport(teleportName);
				if (teleport.Equals(null))
				{
					ctx.Reply(("Teleport ~" + teleportName + "~ not found.").FormatError());
					return;
				}
				teleport.Cooldown = cooldown;
				teleport.IsDefaultCooldown = false;
				TeleportManager.SavePersonalTeleport(player);
				ctx.Reply($"Teleport ~{teleportName}~ cooldown set to ~{cooldown}~.".Format());
			}
		}

		[Command("set cooldown", null, "<teleport-name> <cooldown>", null, null, true)]
		public static void SetTeleportCooldown(ChatCommandContext ctx, string teleportName, int cooldown)
		{
			TeleportData globalTeleport = TeleportManager.GetGlobalTeleport(teleportName);
			if (globalTeleport.Equals(null))
			{
				ctx.Reply(("Teleport ~" + teleportName + "~ not found.").FormatError());
				return;
			}
			globalTeleport.Cooldown = cooldown;
			globalTeleport.IsDefaultCooldown = false;
			TeleportManager.SaveGlobalTeleports();
			ctx.Reply($"Teleport ~{teleportName}~ cooldown set to ~{cooldown}~.".Format());
		}

		[Command("set prefab", null, "<player-name> <teleport-name> <prefab-name> <prefab-guid>", null, null, true)]
		public static void SetTeleportPrefab(ChatCommandContext ctx, string playerName, string teleportName, string prefabName, string prefabGUID)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetPlayerByName(ctx, playerName, out var player))
			{
				PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
				TeleportData teleport = customPlayerData.GetTeleport(teleportName);
				if (teleport.Equals(null))
				{
					ctx.Reply(("Teleport ~" + teleportName + "~ not found.").FormatError());
					return;
				}
				PrefabGUID prefabGUID2 = default(PrefabGUID);
				if (!PrefabGUID.TryParse(prefabGUID, ref prefabGUID2))
				{
					ctx.Reply(("Prefab " + prefabGUID + " is invalid.").FormatError());
					return;
				}
				teleport.PrefabName = prefabName;
				teleport.PrefabGUID = prefabGUID2;
				teleport.IsDefaultPrefab = false;
				TeleportManager.SavePersonalTeleport(player);
				ctx.Reply($"Teleport ~{teleportName}~ prefab set to ~{prefabGUID}~.".Format());
			}
		}

		[Command("set prefab", null, "<teleport-name> <prefab-name> <prefab-guid>", null, null, true)]
		public static void SetTeleportPrefab(ChatCommandContext ctx, string teleportName, string prefabName, string prefabGUID)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			TeleportData globalTeleport = TeleportManager.GetGlobalTeleport(teleportName);
			if (globalTeleport.Equals(null))
			{
				ctx.Reply(("Teleport ~" + teleportName + "~ not found.").FormatError());
				return;
			}
			PrefabGUID prefabGUID2 = default(PrefabGUID);
			if (!PrefabGUID.TryParse(prefabGUID, ref prefabGUID2))
			{
				ctx.Reply(("Prefab " + prefabGUID + " is invalid.").FormatError());
				return;
			}
			globalTeleport.PrefabName = prefabName;
			globalTeleport.PrefabGUID = prefabGUID2;
			globalTeleport.IsDefaultPrefab = false;
			TeleportManager.SaveGlobalTeleports();
			ctx.Reply($"Teleport ~{teleportName}~ prefab set to ~{prefabName}~ (~{prefabGUID}~).".Format());
		}

		[Command("get info", null, "<player-name> <teleport-name>", null, null, true)]
		public static void GetTeleportInfo(ChatCommandContext ctx, string playerName, string teleportName)
		{
			//IL_00a6: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetPlayerByName(ctx, playerName, out var player))
			{
				PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
				TeleportData teleport = customPlayerData.GetTeleport(teleportName);
				if (teleport.Equals(null))
				{
					ctx.Reply(("Teleport ~" + teleportName + "~ not found.").FormatError());
					return;
				}
				ctx.Reply("Info for teleport ~" + teleport.Name + "~:");
				ctx.Reply($" • Prefab: ~{teleport.PrefabName}~ (~{teleport.PrefabGUID}~)".Format());
				ctx.Reply($" • Cost: ~{teleport.Cost}~".Format());
				ctx.Reply($" • Cooldown: ~{teleport.Cooldown}~".Format());
				ctx.Reply($" • Position: (~{teleport.Position.x}~, ~{teleport.Position.y}~, ~{teleport.Position.z}~)".Format());
			}
		}

		[Command("get info", null, "<teleport-name>", null, null, true)]
		public static void GetGlobalTeleportInfo(ChatCommandContext ctx, string teleportName)
		{
			//IL_0087: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			TeleportData globalTeleport = TeleportManager.GetGlobalTeleport(teleportName);
			if (globalTeleport.Equals(null))
			{
				ctx.Reply(("Teleport ~" + teleportName + "~ not found.").FormatError());
				return;
			}
			ctx.Reply("Info for global teleport ~" + globalTeleport.Name + "~:");
			ctx.Reply($" • Prefab: ~{globalTeleport.PrefabName}~ (~{globalTeleport.PrefabGUID}~)".Format());
			ctx.Reply($" • Cost: ~{globalTeleport.Cost}~".Format());
			ctx.Reply($" • Cooldown: ~{globalTeleport.Cooldown}~".Format());
			ctx.Reply($" • Position: (~{globalTeleport.Position.x}~, ~{globalTeleport.Position.y}~, ~{globalTeleport.Position.z}~)".Format());
		}

		[Command("whereami", "wai", null, null, null, true)]
		public static void WhereAmI(ChatCommandContext ctx)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetPlayerById(ctx, out var player))
			{
				float3 position = player.CharacterEntity.GetPosition();
				ctx.Reply($"You are at (~{position.x}~, ~{position.y}~, ~{position.z}~).".Format());
			}
		}

		[Command("iwanttoclearallglobalteleports", null, null, null, null, true)]
		public static void ClearAllGlobalTeleports(ChatCommandContext ctx)
		{
			TeleportManager.GlobalTeleports.Clear();
			TeleportManager.SaveGlobalTeleports();
			ctx.Reply("All global teleports cleared.".Format());
		}

		[Command("iwanttoclearallplayerteleports", null, null, null, null, true)]
		public static void ClearAllPlayerTeleports(ChatCommandContext ctx)
		{
			PlayerService.AllPlayers.ForEach(delegate(PlayerData p)
			{
				PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(p);
				customPlayerData.Teleports.Clear();
			});
			TeleportManager.PersonalTeleports.Clear();
			TeleportManager.SaveAllPersonalTeleports();
			ctx.Reply("All global teleports cleared.".Format());
		}

		public static bool TryGetPlayerById(ChatCommandContext ctx, out PlayerData player)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			player = null;
			PlayerData val = default(PlayerData);
			if (!PlayerService.TryGetById(ctx.User.PlatformId, ref val))
			{
				ctx.Reply("Unable to find your player data.".FormatError());
				return false;
			}
			player = val;
			return true;
		}

		public static bool TryGetPlayerByName(ChatCommandContext ctx, string name, out PlayerData player)
		{
			player = null;
			PlayerData val = default(PlayerData);
			if (!PlayerService.TryGetByName(name, ref val))
			{
				ctx.Reply(("Player ~" + name + "~ not found.").FormatError());
				return false;
			}
			player = val;
			return true;
		}

		public static void CreateRestrictedZone(ChatCommandContext ctx, string name, float radius, float x, float y, float z, bool canTeleportTo = false, bool canTeleportFrom = false)
		{
			TeleportManager.CreateRestrictedZone(new ZoneData(name, new List<float>(3) { x, y, z }, radius, canTeleportTo, canTeleportFrom));
			ctx.Reply(("Restricted area ~" + name + "~ added successfully.").Format());
		}

		private static void CreatePersonalTeleport(ChatCommandContext ctx, PlayerData player, string name, string teleportName, float x, float y, float z, string prefabName = null, PrefabGUID prefabGUID = default(PrefabGUID), int? cost = null, int? cooldown = null)
		{
			//IL_0080: 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)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
			if (customPlayerData.HasTeleport(teleportName))
			{
				ctx.Reply(("Teleport ~" + teleportName + "~ already exists.").FormatError());
				return;
			}
			if (float.IsNaN(x) || float.IsNaN(y) || float.IsNaN(z))
			{
				ctx.Reply("Invalid coordinates.".FormatError());
				return;
			}
			TeleportData teleportData = new TeleportData
			{
				Name = teleportName,
				Position = new float3(x, y, z),
				PrefabName = (prefabName ?? Settings.Get<string>("DefaultPersonalPrefabName")),
				PrefabGUID = (PrefabGUID)((prefabGUID == default(PrefabGUID)) ? new PrefabGUID(Settings.Get<int>("DefaultPersonalPrefabGUID")) : prefabGUID),
				Cost = (cost ?? Settings.Get<int>("DefaultPersonalCost")),
				Cooldown = (cooldown ?? Settings.Get<int>("DefaultPersonalCooldown")),
				CharacterName = player.Name
			};
			TeleportManager.CreatePersonalTeleport(player, teleportData);
			ctx.Reply($"Teleport ~{teleportName}~ added successfully for ~{name}~.".Format());
		}

		public static void CreateGlobalTeleport(ChatCommandContext ctx, string teleportName, float x, float y, float z, string prefabName = null, PrefabGUID prefabGUID = default(PrefabGUID), int? cost = null, int? cooldown = null)
		{
			//IL_0074: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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)
			if (TeleportManager.HasGlobalTeleport(teleportName))
			{
				ctx.Reply(("Teleport ~" + teleportName + "~ already exists.").FormatError());
				return;
			}
			if (float.IsNaN(x) || float.IsNaN(y) || float.IsNaN(z))
			{
				ctx.Reply("Invalid coordinates.".FormatError());
				return;
			}
			TeleportData teleportData = new TeleportData
			{
				Name = teleportName,
				Position = new float3(x, y, z),
				PrefabName = (prefabName ?? Settings.Get<string>("DefaultGlobalPrefabName")),
				PrefabGUID = (PrefabGUID)((prefabGUID == default(PrefabGUID)) ? new PrefabGUID(Settings.Get<int>("DefaultGlobalPrefabGUID")) : prefabGUID),
				Cost = (cost ?? Settings.Get<int>("DefaultGlobalCost")),
				Cooldown = (cooldown ?? Settings.Get<int>("DefaultGlobalCooldown"))
			};
			TeleportManager.CreateGlobalTeleport(teleportData);
			ctx.Reply(("Global Teleport ~" + teleportName + "~ added successfully.").Format());
		}
	}
	public static class Constants
	{
		public const string Prefix = "stp";
	}
	[CommandGroup("stp", null)]
	public static class UserCommands
	{
		private static readonly string Prefix = "stp";

		private static Settings Settings => Plugin.Settings;

		[Command("setteleport", "stp", "<teleport-name>", null, null, false)]
		public static void SetTeleport(ChatCommandContext ctx, string teleportName)
		{
			//IL_0042: 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_013c: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			if (Settings.Get<bool>("EnablePersonalTeleports") && TryGetPlayerById(ctx, out var player))
			{
				ZoneData restrictedZone = TeleportManager.GetRestrictedZone(player.CharacterEntity.GetPosition());
				PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
				if (!player.IsAdmin && restrictedZone != null && !restrictedZone.CanTeleportTo && !customPlayerData.BypassRestrictedZones)
				{
					ctx.Reply("You cannot set a teleport while in a restricted zone.".FormatError());
					return;
				}
				if (!player.IsAdmin && customPlayerData.Teleports.Count >= customPlayerData.MaxTeleports)
				{
					ctx.Reply($"You have reached the maximum number of teleports ({customPlayerData.MaxTeleports}). Please remove one before adding a new one.".White());
					return;
				}
				if (customPlayerData.Teleports.Any((TeleportData t) => t.Name.Equals(teleportName)))
				{
					ctx.Reply("You already have a teleport with that name. Please choose a different one.".FormatError());
					return;
				}
				float3 position = player.CharacterEntity.GetPosition();
				TeleportData teleportData = new TeleportData
				{
					Name = teleportName,
					Position = position,
					PrefabGUID = new PrefabGUID(Settings.Get<int>("DefaultPersonalPrefabGUID")),
					PrefabName = Settings.Get<string>("DefaultPersonalPrefabName"),
					Cost = Settings.Get<int>("DefaultPersonalCost"),
					Cooldown = Settings.Get<int>("DefaultPersonalCooldown"),
					CharacterName = player.Name
				};
				TeleportManager.CreatePersonalTeleport(player, teleportData);
				ctx.Reply(("Teleport ~" + teleportName + "~ set at your position.").Format());
			}
		}

		[Command("teleport", "tp", "<teleport-name>", null, null, false)]
		public static void Teleport(ChatCommandContext ctx, string teleportName)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			if (!TryGetPlayerById(ctx, out var player))
			{
				return;
			}
			PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
			if (!player.IsAdmin && !Settings.Get<bool>("EnableTeleportInCombat") && !customPlayerData.BypassCombat && TeleportManager.IsPlayerInCombat(player.CharacterEntity))
			{
				ctx.Reply("You cannot teleport while in combat.".FormatError());
				return;
			}
			if (!player.IsAdmin && !Settings.Get<bool>("EnableDraculaRoom") && !customPlayerData.BypassDraculaRoom && TeleportManager.IsInDraculaRoom(player.CharacterEntity))
			{
				ctx.Reply("You cannot teleport while in the ~Dracula~'s room.".FormatError());
				return;
			}
			ZoneData restrictedZone = TeleportManager.GetRestrictedZone(player.CharacterEntity.GetPosition());
			if (!player.IsAdmin && restrictedZone != null && !restrictedZone.CanTeleportFrom && !customPlayerData.BypassRestrictedZones)
			{
				ctx.Reply("You cannot teleport while in a restricted zone.".FormatError());
				return;
			}
			if (customPlayerData.HasTeleport(teleportName))
			{
				TeleportData teleport = customPlayerData.GetTeleport(teleportName);
				ZoneData restrictedZone2 = TeleportManager.GetRestrictedZone(teleport.Position);
				if (!player.IsAdmin && restrictedZone2 != null && !restrictedZone2.CanTeleportTo && !customPlayerData.BypassRestrictedZones)
				{
					ctx.Reply("You cannot teleport to a restricted zone.".FormatError());
					return;
				}
				if (TryTeleport(ctx, player, teleport, teleportName))
				{
					return;
				}
			}
			if (TeleportManager.GlobalTeleports.TryGetValue(teleportName, out var value))
			{
				ZoneData restrictedZone3 = TeleportManager.GetRestrictedZone(value.Position);
				if (restrictedZone3 != null && !player.IsAdmin && !restrictedZone3.CanTeleportTo && !customPlayerData.BypassRestrictedZones)
				{
					ctx.Reply("You cannot teleport to a restricted zone.".FormatError());
					return;
				}
				if (TryTeleport(ctx, player, value, teleportName))
				{
					return;
				}
			}
			ctx.Reply(("Teleport ~" + teleportName + "~ not found.").Format());
		}

		private static bool TryTeleport(ChatCommandContext ctx, PlayerData player, TeleportData teleport, string name)
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			int cooldown = teleport.Cooldown;
			PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
			TimeSpan timeSpan = customPlayerData.LastTeleportTime.AddSeconds(cooldown) - DateTime.Now;
			if (!player.IsAdmin && !customPlayerData.BypassCooldown && timeSpan > TimeSpan.Zero)
			{
				ctx.Reply($"You must wait ~{timeSpan.Minutes}~ minutes and ~{timeSpan.Seconds}~ seconds before teleporting again.".FormatError());
				return true;
			}
			if (!player.IsAdmin && !InventoryService.HasAmount(player.CharacterEntity, teleport.PrefabGUID, teleport.Cost))
			{
				ctx.Reply($"You do not have enough ~{teleport.PrefabName}~ to teleport to ~{name}~.".FormatError());
				return true;
			}
			customPlayerData.LastTeleportTime = DateTime.Now;
			TeleportService.TeleportToPosition(player.CharacterEntity, teleport.Position, true);
			if (!customPlayerData.BypassCost)
			{
				InventoryService.RemoveItem(player.CharacterEntity, teleport.PrefabGUID, teleport.Cost);
			}
			ctx.Reply(("Teleported to ~" + name + "~ successfully.").Format());
			return true;
		}

		[Command("removeteleport", "rtp", "<teleport-name>", null, null, false)]
		public static void RemoveTeleport(ChatCommandContext ctx, string teleportName)
		{
			if (TryGetPlayerById(ctx, out var player))
			{
				if (TeleportManager.RemovePersonalTeleport(player, teleportName))
				{
					ctx.Reply(("Teleport ~" + teleportName + "~ removed successfully.").Format());
				}
				else
				{
					ctx.Reply(("Teleport ~" + teleportName + "~ not found.").FormatError());
				}
			}
		}

		[Command("listteleport", "ltp", null, null, null, false)]
		public static void TeleportList(ChatCommandContext ctx)
		{
			if (!TryGetPlayerById(ctx, out var player))
			{
				return;
			}
			PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
			HashSet<TeleportData> teleports = customPlayerData.Teleports;
			Dictionary<string, TeleportData> globalTeleports = TeleportManager.GlobalTeleports;
			if (teleports.Count == 0 && globalTeleports.Count == 0)
			{
				ctx.Reply("No teleports available.".Format());
				return;
			}
			ctx.Reply("~Available Teleports:~".Underline().Bold().Format());
			if (teleports.Count > 0)
			{
				ctx.Reply("Personal".Format().Bold());
				foreach (TeleportData item in teleports)
				{
					ctx.Reply((" • ~" + item.Name + "~").Format());
				}
			}
			if (globalTeleports.Count <= 0)
			{
				return;
			}
			ctx.Reply("Global".Bold().Format());
			foreach (TeleportData value in TeleportManager.GlobalTeleports.Values)
			{
				ctx.Reply((" • ~" + value.Name + "~").Format());
			}
		}

		[Command("teleportrequest", "tpr", "<player-name>", null, null, false)]
		public static void TeleportRequest(ChatCommandContext ctx, string playerName)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			if (!Settings.Get<bool>("EnableTeleportBetweenPlayers"))
			{
				ctx.Reply("Teleport between players are disabled.".FormatError());
			}
			else
			{
				if (!TryGetPlayerById(ctx, out var player) || !TryGetPlayerByName(ctx, playerName, out var player2))
				{
					return;
				}
				PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
				if (!customPlayerData.CanResquestTeleports)
				{
					ctx.Reply("You already have a pending teleport request.".FormatError());
					return;
				}
				string value = Settings.Get<string>("DefaultGlobalPrefabName");
				PrefabGUID val = default(PrefabGUID);
				((PrefabGUID)(ref val))..ctor(Settings.Get<int>("DefaultGlobalPrefabGUID"));
				int num = Settings.Get<int>("DefaultGlobalCost");
				if (!player.IsAdmin && !InventoryService.HasAmount(player.CharacterEntity, val, num))
				{
					ctx.Reply($"You do not have enough ~{value}~ to teleport to ~{playerName}~.".FormatError());
					return;
				}
				PlayerTeleportData customPlayerData2 = TeleportManager.GetCustomPlayerData(player2);
				customPlayerData2.PendingRequests.Add(new TeleportRequestData(player.PlatformId));
				customPlayerData.CanResquestTeleports = false;
				User val2 = player2.UserEntity.Read<User>();
				MessageService.Send(val2, $"~{player.Name}~ has requested to teleport to you, you have ~{Settings.Get<int>("TeleportRequestExpiration")}~ seconds to respond.".Format());
				MessageService.Send(val2, $"Use ~.{Prefix} tpa {player.Name}~ to ~accept~ the request.".Format(new List<string>(2) { null, "green" }));
				MessageService.Send(val2, $"Use ~.{Prefix} tpd {player.Name}~ to ~deny~ the request.".Format(new List<string>(2) { null, "#ff4d4d" }));
				ctx.Reply(("Teleport request sent to ~" + playerName + "~.").Format());
			}
		}

		[Command("teleportaccept", "tpa", "<player-name>", null, null, false)]
		public static void TeleportAccept(ChatCommandContext ctx, string playerName)
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			if (!TryGetPlayerById(ctx, out var player) || !TryGetPlayerByName(ctx, playerName, out var playerTarget))
			{
				return;
			}
			PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
			PlayerTeleportData customPlayerData2 = TeleportManager.GetCustomPlayerData(playerTarget);
			if (!customPlayerData.PendingRequests.Any((TeleportRequestData r) => r.PlatformID == playerTarget.PlatformId))
			{
				ctx.Reply(("You do not have a pending request from ~" + playerName + "~.").FormatError());
				return;
			}
			string text = Settings.Get<string>("DefaultGlobalPrefabName");
			PrefabGUID val = default(PrefabGUID);
			((PrefabGUID)(ref val))..ctor(Settings.Get<int>("DefaultGlobalPrefabGUID"));
			int num = Settings.Get<int>("DefaultGlobalCost");
			if (!playerTarget.IsAdmin && !InventoryService.HasAmount(player.CharacterEntity, val, num))
			{
				MessageService.Send(playerTarget.UserEntity.Read<User>(), $"You do not have enough ~{Settings.Get<string>("DefaultGlobalPrefabName")}~ to teleport to ~{playerName}~.".FormatError());
				return;
			}
			if (!playerTarget.IsAdmin && !Settings.Get<bool>("EnableTeleportInCombat") && !customPlayerData2.BypassCombat && TeleportManager.IsPlayerInCombat(playerTarget.CharacterEntity))
			{
				ctx.Reply(("Player ~" + player.Name + "~ is currently in combat and cannot teleport.").FormatError());
				MessageService.Send(playerTarget.UserEntity.Read<User>(), ("Your teleport request to ~" + player.Name + "~ was denied because you're in combat.").FormatError());
				return;
			}
			if (!playerTarget.IsAdmin && !Settings.Get<bool>("EnableDraculaRoom") && !customPlayerData2.BypassDraculaRoom && TeleportManager.IsInDraculaRoom(playerTarget.CharacterEntity))
			{
				ctx.Reply(("Player ~" + playerTarget.Name + "~ is in Dracula's room and cannot teleport.").FormatError());
				MessageService.Send(playerTarget.UserEntity.Read<User>(), ("Your teleport request to ~" + player.Name + "~ was denied because you're in Dracula's room.").FormatError());
				return;
			}
			if (!playerTarget.IsAdmin && !Settings.Get<bool>("EnableDraculaRoom") && !customPlayerData2.BypassDraculaRoom && TeleportManager.IsInDraculaRoom(player.CharacterEntity))
			{
				ctx.Reply("Teleport failed: you are in Dracula's room, which blocks incoming teleports.".FormatError());
				MessageService.Send(playerTarget.UserEntity.Read<User>(), ("Your teleport request to ~" + player.Name + "~ was denied because they are in Dracula's room.").FormatError());
				return;
			}
			ZoneData restrictedZone = TeleportManager.GetRestrictedZone(player.CharacterEntity.GetPosition());
			if (!playerTarget.IsAdmin && !customPlayerData2.BypassRestrictedZones && restrictedZone != null && !restrictedZone.CanTeleportTo)
			{
				ctx.Reply("Teleport failed: you are in a restricted zone, which blocks incoming teleports.".FormatError());
				MessageService.Send(playerTarget.UserEntity.Read<User>(), ("Your teleport request to ~" + player.Name + "~ was denied because they are in a restricted zone.").FormatError());
				return;
			}
			float3 position = player.CharacterEntity.GetPosition();
			TeleportService.TeleportToPosition(playerTarget.CharacterEntity, position, true);
			customPlayerData2.CanResquestTeleports = true;
			if (!customPlayerData2.BypassCost)
			{
				InventoryService.RemoveItem(playerTarget.CharacterEntity, val, num);
			}
			ctx.Reply(("Player ~" + playerTarget.Name + "~ has teleported to you.").Format());
			MessageService.Send(playerTarget.UserEntity.Read<User>(), ("Your teleport request to ~" + player.Name + "~ was accepted. Teleporting now...").Format());
		}

		[Command("teleportdeny", "tpd", "<player-name>", null, null, false)]
		public static void TeleportDeny(ChatCommandContext ctx, string playerName)
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			if (!TryGetPlayerById(ctx, out var player) || !TryGetPlayerByName(ctx, playerName, out var playerTarget))
			{
				return;
			}
			PlayerTeleportData customPlayerData = TeleportManager.GetCustomPlayerData(player);
			if (!customPlayerData.PendingRequests.Any((TeleportRequestData r) => r.PlatformID == playerTarget.PlatformId))
			{
				ctx.Reply(("You do not have a pending request from ~" + playerName + "~.").FormatError());
				return;
			}
			PlayerTeleportData customPlayerData2 = TeleportManager.GetCustomPlayerData(playerTarget);
			customPlayerData.PendingRequests.RemoveWhere((TeleportRequestData r) => r.PlatformID == playerTarget.PlatformId);
			customPlayerData2.CanResquestTeleports = true;
			ctx.Reply(("Player ~" + playerName + "~ has been denied your teleport request.").Format());
			MessageService.Send(playerTarget.UserEntity.Read<User>(), ("Your teleport request to ~" + player.Name + "~ was denied.").Format());
		}

		public static bool TryGetPlayerById(ChatCommandContext ctx, out PlayerData player)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			player = null;
			PlayerData val = default(PlayerData);
			if (!PlayerService.TryGetById(ctx.User.PlatformId, ref val))
			{
				ctx.Reply("Unable to find your player data.".FormatError());
				return false;
			}
			player = val;
			return true;
		}

		public static bool TryGetPlayerByName(ChatCommandContext ctx, string name, out PlayerData player)
		{
			player = null;
			PlayerData val = default(PlayerData);
			if (!PlayerService.TryGetByName(name, ref val))
			{
				ctx.Reply(("Player ~" + name + "~ not found.").FormatError());
				return false;
			}
			player = val;
			return true;
		}
	}
}