Decompiled source of BrigadierForLethalCompany v2.1.0

Brigadier for Lethal Company.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using Brigadier.NET;
using Brigadier.NET.ArgumentTypes;
using Brigadier.NET.Builder;
using Brigadier.NET.Context;
using Brigadier.NET.Exceptions;
using Brigadier.NET.Suggestion;
using Brigadier.NET.Tree;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Rumi.BrigadierForLethalCompany.API;
using Rumi.BrigadierForLethalCompany.API.ArgumentTypes;
using Rumi.BrigadierForLethalCompany.API.ArgumentTypes.Selectors;
using Rumi.BrigadierForLethalCompany.API.ArgumentTypes.Selectors.Options;
using Rumi.BrigadierForLethalCompany.Components;
using StaticNetcodeLib;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Count;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Count;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Count;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyList(List<T> items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return _items.Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		_items.CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return _items.IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
	{
		object IEnumerator.Current => _item;

		T IEnumerator<T>.Current => _item;

		public Enumerator(T item)
		{
			_item = item;
		}

		bool IEnumerator.MoveNext()
		{
			if (!_moveNextCalled)
			{
				return _moveNextCalled = true;
			}
			return false;
		}

		void IEnumerator.Reset()
		{
			_moveNextCalled = false;
		}

		void IDisposable.Dispose()
		{
		}
	}

	int ICollection.Count => 1;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => 1;

	T IReadOnlyList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
	}

	int ICollection<T>.Count => 1;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlySingleElementList(T item)
	{
		_item = item;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection.CopyTo(Array array, int index)
	{
		array.SetValue(_item, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return EqualityComparer<T>.Default.Equals(_item, (T)value);
	}

	int IList.IndexOf(object value)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
		{
			return -1;
		}
		return 0;
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return EqualityComparer<T>.Default.Equals(_item, item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		array[arrayIndex] = _item;
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, item))
		{
			return -1;
		}
		return 0;
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class ParamCollectionAttribute : Attribute
	{
	}
	[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 Rumi.BrigadierForLethalCompany
{
	public static class BFLCPatches
	{
		public static void Patch()
		{
			Debug.Log("HUDManager Patch...");
			try
			{
				BFLCPlugin.harmony.PatchAll(typeof(BFLCPatches));
				Debug.Log("HUDManager Patched!");
			}
			catch (Exception data)
			{
				Debug.LogError(data);
				Debug.Log("HUDManager Patch Fail!");
			}
		}

		[HarmonyPatch(typeof(HUDManager), "Start")]
		[HarmonyPostfix]
		private static void HUDManager_Start_Postfix(HUDManager __instance)
		{
			CommandIntelliSense.Create(__instance);
			__instance.chatTextField.characterLimit = 0;
		}

		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		[HarmonyPrefix]
		private static bool HUDManager_SubmitChat_performed_Prefix(HUDManager __instance)
		{
			string text = __instance.chatTextField.text;
			if (!text.StartsWith("/"))
			{
				return true;
			}
			text = text.Remove(0, 1);
			ServerCommand.ExecuteCommand(text);
			__instance.chatTextField.text = "";
			__instance.localPlayer.isTypingChat = false;
			((Behaviour)__instance.typingIndicator).enabled = false;
			EventSystem.current.SetSelectedGameObject((GameObject)null);
			return false;
		}
	}
	[BepInPlugin("Rumi.BrigadierForLethalCompany", "Brigadier for Lethal Company", "2.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class BFLCPlugin : BaseUnityPlugin
	{
		public const string modGuid = "Rumi.BrigadierForLethalCompany";

		public const string modName = "Brigadier for Lethal Company";

		public const string modVersion = "2.1.0";

		internal static ManualLogSource? logger { get; private set; } = null;


		internal static Harmony harmony { get; } = new Harmony("Rumi.BrigadierForLethalCompany");


		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			Debug.Log("Start loading plugin...");
			BFLCPatches.Patch();
			NetworkManager.OnInstantiated += delegate(NetworkManager x)
			{
				ReflectionManager.Refresh();
				x.OnServerStarted += delegate
				{
					ServerCommand.Reset();
					ServerCommand.AllRegister();
				};
			};
			ServerCommand.AllRegister();
			Debug.Log("Plugin Brigadier for Lethal Company is loaded!");
		}
	}
	[StaticNetcode]
	public static class BFLCUtility
	{
		public static void SendChat(string text, PlayerControllerB? targetPlayer)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsServer)
			{
				InternalChatClientRpc(text, targetPlayer.ToRpc());
			}
		}

		public static void SendChat(string text, [ParamCollection] IEnumerable<PlayerControllerB?> targetPlayers)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsServer && targetPlayers.Any())
			{
				InternalChatClientRpc(text, targetPlayers.ToRpc());
			}
		}

		[ClientRpc]
		private static void InternalChatClientRpc(string text, ClientRpcParams rpcParams = default(ClientRpcParams))
		{
			AddChatClient(text);
		}

		public static void AddChatClient(string text)
		{
			HUDManager instance = HUDManager.Instance;
			if (instance.ChatMessageHistory.Count >= 4)
			{
				instance.ChatMessageHistory.Remove(instance.ChatMessageHistory[0]);
			}
			instance.ChatMessageHistory.Add("<color=white>" + text + "</color>");
			((TMP_Text)instance.chatText).text = string.Empty;
			for (int i = 0; i < instance.ChatMessageHistory.Count; i++)
			{
				TextMeshProUGUI chatText = instance.chatText;
				((TMP_Text)chatText).text = ((TMP_Text)chatText).text + "\n" + instance.ChatMessageHistory[i];
			}
		}

		public static string GetEntityName(this NetworkBehaviour entity)
		{
			return Enumerable.Repeat<NetworkBehaviour>(entity, 1).GetEntityName(1);
		}

		public static string GetEntityName(this IEnumerable<NetworkBehaviour> entitys, int count = -1)
		{
			if (entitys.CountIsOne())
			{
				NetworkBehaviour val = entitys.First();
				PlayerControllerB val2 = (PlayerControllerB)(object)((val is PlayerControllerB) ? val : null);
				if (val2 != null)
				{
					return val2.playerUsername;
				}
				EnemyAI val3 = (EnemyAI)(object)((val is EnemyAI) ? val : null);
				if (val3 != null)
				{
					return val3.enemyType.enemyName;
				}
				Anomaly val4 = (Anomaly)(object)((val is Anomaly) ? val : null);
				if (val4 != null)
				{
					return val4.anomalyType.anomalyName;
				}
				GrabbableObject val5 = (GrabbableObject)(object)((val is GrabbableObject) ? val : null);
				if (val5 != null)
				{
					return val5.itemProperties.itemName;
				}
				return ((Object)val).name;
			}
			if (count < 0)
			{
				return $"{entitys.Count()} entities";
			}
			return $"{count} entities";
		}

		public static string GetPlayerName(this IEnumerable<PlayerControllerB> entitys, int count = -1)
		{
			if (entitys.CountIsOne())
			{
				NetworkBehaviour val = (NetworkBehaviour)(object)entitys.First();
				PlayerControllerB val2 = (PlayerControllerB)(object)((val is PlayerControllerB) ? val : null);
				if (val2 != null)
				{
					return val2.playerUsername;
				}
				return ((Object)val).name;
			}
			if (count < 0)
			{
				return $"{entitys.Count()} players";
			}
			return $"{count} players";
		}

		public static async Task<NetworkIntelliSenseArray> GetIntelliSenseText<TSource>(this CommandDispatcher<TSource> dispatcher, string input, TSource source, int cursor)
		{
			TSource source2 = source;
			if (cursor < 0 || cursor > input.Length)
			{
				return default(NetworkIntelliSenseArray);
			}
			StringReader val = new StringReader(input);
			ParseResults<TSource> parseResults = dispatcher.Parse(val, source2);
			List<Suggestion> list = (await dispatcher.GetCompletionSuggestions(parseResults, cursor)).List;
			SuggestionContext<TSource> suggestionContext = parseResults.Context.FindSuggestionContext(cursor);
			if (suggestionContext.Parent == dispatcher.Root)
			{
				list.RemoveAll(delegate(Suggestion suggestion)
				{
					Suggestion suggestion2 = suggestion;
					LiteralCommandNode<TSource> val3 = suggestionContext.Parent.Children.OfType<LiteralCommandNode<TSource>>().FirstOrDefault((Func<LiteralCommandNode<TSource>, bool>)((LiteralCommandNode<TSource> c) => ((CommandNode<TSource>)(object)c).Name == suggestion2.Text));
					return val3 != null && !((CommandNode<TSource>)(object)val3).CanUse(source2);
				});
			}
			if (list.Count > 0)
			{
				return new NetworkIntelliSenseArray(NetworkIntelliSenseArray.Type.suggestion, ((IEnumerable<Suggestion>)list).Select((Func<Suggestion, NetworkIntelliSenseArray.Suggestion>)((Suggestion x) => x)).ToArray());
			}
			ICollection<CommandSyntaxException> values = parseResults.Exceptions.Values;
			if (values.Count > 0)
			{
				return new NetworkIntelliSenseArray(NetworkIntelliSenseArray.Type.exception, new NetworkIntelliSenseArray.Suggestion[1] { ((Exception)(object)values.Last()).Message });
			}
			SuggestionContext<TSource> val2 = parseResults.Context.FindSuggestionContext(cursor);
			if (val2.Parent.Children.Any((CommandNode<TSource> x) => x is ArgumentCommandNode<TSource>))
			{
				ICollection<string> values2 = dispatcher.GetSmartUsage(val2.Parent, source2).Values;
				if (values2.Count > 0)
				{
					return new NetworkIntelliSenseArray(NetworkIntelliSenseArray.Type.usage, ((IEnumerable<string>)values2).Select((Func<string, NetworkIntelliSenseArray.Suggestion>)((string x) => x)).ToArray());
				}
			}
			return default(NetworkIntelliSenseArray);
		}

		public static IEnumerable<PlayerControllerB> GetPlayers()
		{
			return StartOfRound.Instance.ClientPlayerList.Values.Select((int x) => StartOfRound.Instance.allPlayerScripts[x]);
		}

		public static IEnumerable<NetworkBehaviour> GetEntitys()
		{
			return GetPlayers().OfType<NetworkBehaviour>().Concat((IEnumerable<NetworkBehaviour>)(object)Object.FindObjectsByType<EnemyAI>((FindObjectsSortMode)0)).Concat((IEnumerable<NetworkBehaviour>)(object)Object.FindObjectsByType<Anomaly>((FindObjectsSortMode)0))
				.Concat((IEnumerable<NetworkBehaviour>)(object)Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0));
		}
	}
	internal static class Debug
	{
		public static void Log(object data)
		{
			ManualLogSource? logger = BFLCPlugin.logger;
			if (logger != null)
			{
				logger.LogInfo(data);
			}
		}

		public static void LogWarning(object data)
		{
			ManualLogSource? logger = BFLCPlugin.logger;
			if (logger != null)
			{
				logger.LogWarning(data);
			}
		}

		public static void LogError(object data)
		{
			ManualLogSource? logger = BFLCPlugin.logger;
			if (logger != null)
			{
				logger.LogError(data);
			}
		}

		public static void LogD(object data)
		{
			ManualLogSource? logger = BFLCPlugin.logger;
			if (logger != null)
			{
				logger.LogDebug(data);
			}
		}
	}
	internal static class ReflectionManager
	{
		public static IReadOnlyList<Assembly> assemblys { get; private set; } = Array.Empty<Assembly>();


		public static IReadOnlyList<Type> types { get; private set; } = Array.Empty<Type>();


		public static event Action? onRefresh;

		public static void Refresh()
		{
			assemblys = AppDomain.CurrentDomain.GetAssemblies();
			List<Type> list = new List<Type>();
			list.AddRange(assemblys.SelectMany<Assembly, Type>(delegate(Assembly x)
			{
				try
				{
					return x.GetTypes();
				}
				catch (ReflectionTypeLoadException ex)
				{
					List<Type> list2 = new List<Type>();
					list2.AddRange(ex.Types.Where((Type x) => x != null));
					return new <>z__ReadOnlyList<Type>(list2);
				}
			}));
			types = new <>z__ReadOnlyList<Type>(list);
			ReflectionManager.onRefresh?.Invoke();
		}

		public static bool IsSubtypeOf<T>(this Type type)
		{
			if (type != typeof(T))
			{
				return typeof(T).IsAssignableFrom(type);
			}
			return false;
		}

		public static bool IsSubtypeOf(this Type type, Type surclass)
		{
			if (type != surclass)
			{
				return surclass.IsAssignableFrom(type);
			}
			return false;
		}

		public static bool AttributeContains<T>(this MemberInfo element) where T : Attribute
		{
			return element.AttributeContains(typeof(T));
		}

		public static bool AttributeContains(this MemberInfo element, Type attribute)
		{
			return Attribute.GetCustomAttributes(element, attribute).Length != 0;
		}

		public static bool AttributeContains<T>(this Assembly element) where T : Attribute
		{
			return element.AttributeContains(typeof(T));
		}

		public static bool AttributeContains(this Assembly element, Type attribute)
		{
			return Attribute.GetCustomAttributes(element, attribute).Length != 0;
		}

		public static bool AttributeContains<T>(this ParameterInfo element) where T : Attribute
		{
			return element.AttributeContains(typeof(T));
		}

		public static bool AttributeContains(this ParameterInfo element, Type attribute)
		{
			return Attribute.GetCustomAttributes(element, attribute).Length != 0;
		}

		public static bool AttributeContains<T>(this Module element) where T : Attribute
		{
			return element.AttributeContains(typeof(T));
		}

		public static bool AttributeContains(this Module element, Type attribute)
		{
			return element.GetCustomAttributes(attribute, inherit: false).Length != 0;
		}

		public static bool IsAsyncMethod(this MethodBase methodBase)
		{
			return methodBase.AttributeContains<AsyncStateMachineAttribute>();
		}

		public static bool IsCompilerGenerated(this Type type)
		{
			return type.AttributeContains<CompilerGeneratedAttribute>();
		}

		public static bool IsCompilerGenerated(this MemberInfo memberInfo)
		{
			return memberInfo.AttributeContains<CompilerGeneratedAttribute>();
		}
	}
	public static class RPCParamsUtility
	{
		public static bool TryGetPlayer(this ServerRpcParams rpcParams, [NotNullWhen(true)] out PlayerControllerB? player)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			player = BFLCUtility.GetPlayers().FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB x) => ((NetworkBehaviour)x).OwnerClientId == rpcParams.Receive.SenderClientId));
			return (Object)(object)player != (Object)null;
		}

		public static ClientRpcParams ToRpc(this PlayerControllerB? player)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_000b: 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 ((Object)(object)player == (Object)null)
			{
				return default(ClientRpcParams);
			}
			ClientRpcParams result = default(ClientRpcParams);
			result.Send = new ClientRpcSendParams
			{
				TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(((NetworkBehaviour)player).OwnerClientId)
			};
			return result;
		}

		public static ClientRpcParams ToRpc(this IEnumerable<PlayerControllerB?> players)
		{
			//IL_0002: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			ClientRpcParams result = default(ClientRpcParams);
			ClientRpcSendParams send = default(ClientRpcSendParams);
			List<ulong> list = new List<ulong>();
			list.AddRange(from x in players.WhereNotNull()
				select ((NetworkBehaviour)x).OwnerClientId);
			send.TargetClientIds = new <>z__ReadOnlyList<ulong>(list);
			result.Send = send;
			return result;
		}

		public static ClientRpcParams PlayerToRpc([ParamCollection] IEnumerable<PlayerControllerB?> players)
		{
			//IL_0002: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			ClientRpcParams result = default(ClientRpcParams);
			ClientRpcSendParams send = default(ClientRpcSendParams);
			List<ulong> list = new List<ulong>();
			list.AddRange(from x in players.WhereNotNull()
				select ((NetworkBehaviour)x).OwnerClientId);
			send.TargetClientIds = new <>z__ReadOnlyList<ulong>(list);
			result.Send = send;
			return result;
		}
	}
}
namespace Rumi.BrigadierForLethalCompany.Components
{
	public sealed class CommandIntelliSense : MonoBehaviour
	{
		[CompilerGenerated]
		private RectTransform <rectTransform>k__BackingField;

		[CompilerGenerated]
		private Image <bgImage>k__BackingField;

		[CompilerGenerated]
		private VerticalLayoutGroup <layout>k__BackingField;

		[CompilerGenerated]
		private ContentSizeFitter <sizeFitter>k__BackingField;

		private static readonly Color orgCaretColor = new Color(0.4157f, 0.3569f, 1f, 0.7725f);

		private static readonly Color orgTextColor = new Color(0.3451f, 0.3686f, 0.8196f, 0.8314f);

		private int lastCaretPosition;

		public static TMP_FontAsset? font => ((TMP_Text)HUDManager.Instance.chatText).font;

		public RectTransform rectTransform
		{
			get
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Expected O, but got Unknown
				//IL_001d: Expected O, but got Unknown
				RectTransform obj = <rectTransform>k__BackingField;
				if (obj == null)
				{
					RectTransform val = (RectTransform)((Component)this).transform;
					RectTransform val2 = val;
					<rectTransform>k__BackingField = val;
					obj = val2;
				}
				return obj;
			}
		}

		public Image bgImage => <bgImage>k__BackingField ?? (<bgImage>k__BackingField = ((Component)this).GetComponent<Image>());

		public VerticalLayoutGroup layout => <layout>k__BackingField ?? (<layout>k__BackingField = ((Component)this).GetComponent<VerticalLayoutGroup>());

		public ContentSizeFitter sizeFitter => <sizeFitter>k__BackingField ?? (<sizeFitter>k__BackingField = ((Component)this).GetComponent<ContentSizeFitter>());

		public HUDManager? hudManager { get; private set; }

		public TMP_InputField? chatField
		{
			get
			{
				if (!((Object)(object)hudManager != (Object)null))
				{
					return null;
				}
				return hudManager.chatTextField;
			}
		}

		public Image? inputBgImage { get; private set; }

		public CommandIntelliSenseText? text { get; private set; }

		private void Update()
		{
			if (!((Object)(object)chatField == (Object)null) && lastCaretPosition != chatField.caretPosition)
			{
				UpdateIntelliSenseText(chatField.text);
				lastCaretPosition = chatField.caretPosition;
			}
		}

		private void OnGUI()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Invalid comparison between Unknown and I4
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Invalid comparison between Unknown and I4
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Invalid comparison between Unknown and I4
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Invalid comparison between Unknown and I4
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Invalid comparison between Unknown and I4
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Invalid comparison between Unknown and I4
			if ((Object)(object)chatField == (Object)null || (Object)(object)this.text == (Object)null || !Event.current.isKey || this.text.intelliSenseArray.length == 0)
			{
				return;
			}
			if ((int)Event.current.keyCode == 273)
			{
				if ((int)Event.current.type == 4)
				{
					this.text.selectedLine--;
				}
				Event.current.Use();
			}
			else if ((int)Event.current.keyCode == 274)
			{
				if ((int)Event.current.type == 4)
				{
					this.text.selectedLine++;
				}
				Event.current.Use();
			}
			else if ((int)Event.current.keyCode == 9 && this.text.intelliSenseArray.type == NetworkIntelliSenseArray.Type.suggestion)
			{
				if ((int)Event.current.type == 4)
				{
					NetworkIntelliSenseArray.Suggestion suggestion = this.text.intelliSenseArray[this.text.selectedLine];
					int end = suggestion.range.end;
					int startIndex = end - suggestion.range.start;
					string text = suggestion.text.Substring(startIndex);
					chatField.text = chatField.text.Insert(end + 1, text);
					TMP_InputField? obj = chatField;
					obj.stringPosition += text.Length;
				}
				Event.current.Use();
			}
		}

		public void UpdateIntelliSenseText(string input)
		{
			//IL_008f: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)text == (Object)null || (Object)(object)inputBgImage == (Object)null || (Object)(object)chatField == (Object)null)
			{
				return;
			}
			bool flag = input.StartsWith("/");
			if (flag && (Object)(object)hudManager != (Object)null)
			{
				ServerCommand.RequestIntelliSense(input.Remove(0, 1), chatField.caretPosition - 1, delegate(NetworkIntelliSenseArray x)
				{
					//IL_0023: Unknown result type (might be due to invalid IL or missing references)
					//IL_001c: Unknown result type (might be due to invalid IL or missing references)
					text.intelliSenseArray = x;
					((Graphic)bgImage).color = ((x.length > 0) ? Color.black : Color.clear);
				});
			}
			else
			{
				ServerCommand.CancelRequestIntelliSense();
				text.intelliSenseArray = default(NetworkIntelliSenseArray);
				((Graphic)bgImage).color = Color.clear;
			}
			((Graphic)inputBgImage).color = (flag ? Color.black : Color.clear);
			chatField.caretColor = (flag ? Color.white : orgCaretColor);
			((Graphic)chatField.textComponent).color = (flag ? Color.white : orgTextColor);
			chatField.richText = !flag;
		}

		public static CommandIntelliSense Create(HUDManager hudManager)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			TMP_InputField chatTextField = hudManager.chatTextField;
			CommandIntelliSense commandIntelliSense = new GameObject("Command Intelli Sense", new Type[5]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(VerticalLayoutGroup),
				typeof(ContentSizeFitter)
			}).AddComponent<CommandIntelliSense>();
			((Component)commandIntelliSense).transform.SetParent(((Component)chatTextField).transform, false);
			((UnityEvent<string>)(object)chatTextField.onValueChanged).AddListener((UnityAction<string>)commandIntelliSense.UpdateIntelliSenseText);
			commandIntelliSense.rectTransform.anchorMin = Vector2.up;
			commandIntelliSense.rectTransform.anchorMax = Vector2.up;
			commandIntelliSense.rectTransform.pivot = new Vector2(0f, 0f);
			((Graphic)commandIntelliSense.bgImage).color = Color.clear;
			((LayoutGroup)commandIntelliSense.layout).padding = new RectOffset(5, 5, 5, 5);
			((HorizontalOrVerticalLayoutGroup)commandIntelliSense.layout).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)commandIntelliSense.layout).childForceExpandHeight = false;
			commandIntelliSense.sizeFitter.horizontalFit = (FitMode)2;
			commandIntelliSense.sizeFitter.verticalFit = (FitMode)2;
			Image val = new GameObject("Command Intelli Sense Input Field BG", new Type[2]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer)
			}).AddComponent<Image>();
			((Component)val).transform.SetParent(((Component)chatTextField).transform, false);
			((Component)val).transform.SetAsFirstSibling();
			((Graphic)val).rectTransform.anchorMin = Vector2.zero;
			((Graphic)val).rectTransform.anchorMax = Vector2.one;
			((Graphic)val).rectTransform.sizeDelta = Vector2.zero;
			((Graphic)val).rectTransform.offsetMin = new Vector2(((Graphic)val).rectTransform.offsetMin.x, ((Graphic)val).rectTransform.offsetMin.y + 37f);
			((Graphic)val).rectTransform.offsetMax = new Vector2(((Graphic)val).rectTransform.offsetMax.x, ((Graphic)val).rectTransform.offsetMax.y - 2f);
			((Graphic)val).color = Color.clear;
			commandIntelliSense.inputBgImage = val;
			commandIntelliSense.hudManager = hudManager;
			commandIntelliSense.text = CommandIntelliSenseText.Create(commandIntelliSense);
			return commandIntelliSense;
		}
	}
	public sealed class CommandIntelliSenseText : MonoBehaviour
	{
		[CompilerGenerated]
		private RectTransform <rectTransform>k__BackingField;

		private StringBuilder builder = new StringBuilder();

		[CompilerGenerated]
		private NetworkIntelliSenseArray <intelliSenseArray>k__BackingField;

		private int _selectedLine;

		[CompilerGenerated]
		private TextMeshProUGUI <textComponent>k__BackingField;

		[CompilerGenerated]
		private ContentSizeFitter <sizeFitter>k__BackingField;

		public RectTransform rectTransform
		{
			get
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Expected O, but got Unknown
				//IL_001d: Expected O, but got Unknown
				RectTransform obj = <rectTransform>k__BackingField;
				if (obj == null)
				{
					RectTransform val = (RectTransform)((Component)this).transform;
					RectTransform val2 = val;
					<rectTransform>k__BackingField = val;
					obj = val2;
				}
				return obj;
			}
		}

		public NetworkIntelliSenseArray intelliSenseArray
		{
			[CompilerGenerated]
			get
			{
				return <intelliSenseArray>k__BackingField;
			}
			set
			{
				<intelliSenseArray>k__BackingField = value;
				if (<intelliSenseArray>k__BackingField.type == NetworkIntelliSenseArray.Type.usage)
				{
					((TMP_Text)textComponent).text = "<color=#aaaaaa>" + string.Join('\n', <intelliSenseArray>k__BackingField.Select((NetworkIntelliSenseArray.Suggestion x) => x.text)) + "</color>";
					_selectedLine = 0;
				}
				else if (<intelliSenseArray>k__BackingField.type == NetworkIntelliSenseArray.Type.exception)
				{
					((TMP_Text)textComponent).text = "<color=#ff5555>" + string.Join('\n', <intelliSenseArray>k__BackingField.Select((NetworkIntelliSenseArray.Suggestion x) => x.text)) + "</color>";
					_selectedLine = 0;
				}
				else
				{
					_selectedLine = Mathf.Clamp(_selectedLine, 0, <intelliSenseArray>k__BackingField.length - 1);
					builder.Clear();
					int i = selectedLine - 5;
					int num = selectedLine + 6;
					if (-i > 0)
					{
						num -= i;
						i = 0;
					}
					if (num > <intelliSenseArray>k__BackingField.length)
					{
						i = ((i >= num - <intelliSenseArray>k__BackingField.length) ? (i - (num - <intelliSenseArray>k__BackingField.length)) : 0);
						num = <intelliSenseArray>k__BackingField.length;
					}
					for (; i < num; i++)
					{
						if (i == selectedLine)
						{
							builder.AppendLine("<color=yellow>" + <intelliSenseArray>k__BackingField[i].text + "</color>");
						}
						else
						{
							builder.AppendLine(<intelliSenseArray>k__BackingField[i].text);
						}
					}
					((TMP_Text)textComponent).text = builder.ToString();
				}
				sizeFitter.SetLayoutHorizontal();
				sizeFitter.SetLayoutVertical();
			}
		}

		public int selectedLine
		{
			get
			{
				return _selectedLine;
			}
			set
			{
				if (intelliSenseArray.type != 0)
				{
					_selectedLine = 0;
					return;
				}
				if (value < 0)
				{
					_selectedLine = intelliSenseArray.length - 1;
				}
				else if (value >= intelliSenseArray.length)
				{
					_selectedLine = 0;
				}
				else
				{
					_selectedLine = value;
				}
				intelliSenseArray = intelliSenseArray;
			}
		}

		public TextMeshProUGUI textComponent => <textComponent>k__BackingField ?? (<textComponent>k__BackingField = ((Component)this).GetComponent<TextMeshProUGUI>());

		public ContentSizeFitter sizeFitter => <sizeFitter>k__BackingField ?? (<sizeFitter>k__BackingField = ((Component)this).GetComponent<ContentSizeFitter>());

		public static CommandIntelliSenseText Create(CommandIntelliSense parent)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			CommandIntelliSenseText commandIntelliSenseText = new GameObject("Text", new Type[4]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(TextMeshProUGUI),
				typeof(ContentSizeFitter)
			}).AddComponent<CommandIntelliSenseText>();
			((Component)commandIntelliSenseText).transform.SetParent(((Component)parent).transform, false);
			((TMP_Text)commandIntelliSenseText.textComponent).text = "";
			((TMP_Text)commandIntelliSenseText.textComponent).font = CommandIntelliSense.font;
			((TMP_Text)commandIntelliSenseText.textComponent).fontSize = 14f;
			((TMP_Text)commandIntelliSenseText.textComponent).enableWordWrapping = false;
			((TMP_Text)commandIntelliSenseText.textComponent).alignment = (TextAlignmentOptions)1025;
			commandIntelliSenseText.sizeFitter.horizontalFit = (FitMode)2;
			commandIntelliSenseText.sizeFitter.verticalFit = (FitMode)2;
			return commandIntelliSenseText;
		}
	}
}
namespace Rumi.BrigadierForLethalCompany.API
{
	public static class BuiltInExceptionsExpansion
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Function <>9__0_0;

			public static Function <>9__6_0;

			public static Function <>9__7_0;

			public static Function <>9__9_0;

			public static Function <>9__11_0;

			public static Function <>9__12_0;

			public static Function <>9__13_0;

			internal IMessage <ColonTooMany>b__0_0(object found, object max)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Number of colons must not be many than {max}, found {found}");
			}

			internal IMessage <SelectorUnkown>b__6_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Unknown selector type '{x}'");
			}

			internal IMessage <SelectorOptionsUnknown>b__7_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Unknown option '{x}'");
			}

			internal IMessage <SelectorOptionsValueless>b__9_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Expected value for option '{x}'");
			}

			internal IMessage <InvalidSort>b__11_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Invalid or unknown sort type '{x}'");
			}

			internal IMessage <InvalidEntityType>b__12_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Invalid or unknown entity type '{x}'");
			}

			internal IMessage <InvalidItemType>b__13_0(object x)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				return (IMessage)new LiteralMessage($"Unknown item '{x}'");
			}
		}

		public static Dynamic2CommandExceptionType ColonTooMany(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0014: 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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				Function val = (object found, object max) => (IMessage)new LiteralMessage($"Number of colons must not be many than {max}, found {found}");
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			return new Dynamic2CommandExceptionType((Function)obj);
		}

		public static SimpleCommandExceptionType InvalidPosSwizzle(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Invalid swizzle, expected combination of 'x', 'y' and 'z'"));
		}

		public static SimpleCommandExceptionType WorldLocalPosMixed(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Cannot mix world & local coordinates (everything must either use ^ or not)"));
		}

		public static SimpleCommandExceptionType EntityToMany(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Only one entity is allowed, but the provided selector allows more than one"));
		}

		public static SimpleCommandExceptionType PlayerToMany(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Only one player is allowed, but the provided selector allows more than one"));
		}

		public static SimpleCommandExceptionType OnlyPlayer(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Only players may be affected by this command, but the provided selector includes entities"));
		}

		public static DynamicCommandExceptionType SelectorUnkown(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0014: 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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__6_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Unknown selector type '{x}'");
				<>c.<>9__6_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}

		public static DynamicCommandExceptionType SelectorOptionsUnknown(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0014: 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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__7_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Unknown option '{x}'");
				<>c.<>9__7_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}

		public static SimpleCommandExceptionType SelectorOptionsUnterminated(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Expected end of options"));
		}

		public static DynamicCommandExceptionType SelectorOptionsValueless(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0014: 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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__9_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Expected value for option '{x}'");
				<>c.<>9__9_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}

		public static SimpleCommandExceptionType RangeEmpty(this IBuiltInExceptionProvider e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			return new SimpleCommandExceptionType((IMessage)new LiteralMessage("Expected value or range of values"));
		}

		public static DynamicCommandExceptionType InvalidSort(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0014: 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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__11_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Invalid or unknown sort type '{x}'");
				<>c.<>9__11_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}

		public static DynamicCommandExceptionType InvalidEntityType(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0014: 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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Invalid or unknown entity type '{x}'");
				<>c.<>9__12_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}

		public static DynamicCommandExceptionType InvalidItemType(this IBuiltInExceptionProvider e)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0014: 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_001f: Expected O, but got Unknown
			object obj = <>c.<>9__13_0;
			if (obj == null)
			{
				Function val = (object x) => (IMessage)new LiteralMessage($"Unknown item '{x}'");
				<>c.<>9__13_0 = val;
				obj = (object)val;
			}
			return new DynamicCommandExceptionType((Function)obj);
		}
	}
	public static class LethalArguments
	{
		public static CoordinatesArgumentType<T> Coordinates<T>(T? min, T? max, Func<IStringReader, T> readFunc, int argumentCount, int localArgumentCount) where T : struct, IComparable<T>
		{
			return new CoordinatesArgumentType<T>(min, max, readFunc, argumentCount, localArgumentCount);
		}

		public static CoordinatesArgumentValue<TValue>[] GetCoordinates<TSource, TValue>(CommandContext<TSource> context, string name)
		{
			return ((CommandContext<CoordinatesArgumentValue<TValue>[]>)(object)context).GetArgument<CoordinatesArgumentValue<TValue>[]>(name);
		}

		public static CoordinatesArgumentType<float> Vector2(float? min = null, float? max = null, bool allowLocalType = true)
		{
			return Coordinates(min, max, (IStringReader x) => x.ReadFloat(), 2, allowLocalType ? 3 : 0);
		}

		public static Vector2 GetVector2<TSource>(CommandContext<TSource> context, string name) where TSource : ServerCommandSource
		{
			//IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			return GetVector2<TSource>(context, name, context.Source.position, context.Source.rotation);
		}

		public static Vector2 GetVector2<TSource>(CommandContext<TSource> context, string name, Vector3 offset, Vector3 localRotation)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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)
			CoordinatesArgumentValue<float>[] coordinates = GetCoordinates<TSource, float>(context, name);
			if (coordinates.Length < 2)
			{
				return Vector2.zero;
			}
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(coordinates[0].value, coordinates[1].value);
			if (coordinates[0].coordinatesType == CoordinateType.local && coordinates.Length == 3)
			{
				Vector3 val2 = offset + Quaternion.Euler(localRotation) * new Vector3(val.x, val.y, coordinates[2].value);
				return new Vector2(val2.x, val2.z);
			}
			if (coordinates[0].coordinatesType == CoordinateType.offset)
			{
				val.x += offset.x;
			}
			if (coordinates[1].coordinatesType == CoordinateType.offset)
			{
				val.y += offset.y;
			}
			return val;
		}

		public static CoordinatesArgumentType<int> Vector2Int(int? min = null, int? max = null, bool allowLocalType = true)
		{
			return Coordinates(min, max, (IStringReader x) => x.ReadInt(), 2, allowLocalType ? 3 : 0);
		}

		public static Vector2Int GetVector2Int<TSource>(CommandContext<TSource> context, string name) where TSource : ServerCommandSource
		{
			//IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			return GetVector2Int<TSource>(context, name, context.Source.position, context.Source.rotation);
		}

		public static Vector2Int GetVector2Int<TSource>(CommandContext<TSource> context, string name, Vector3 offset, Vector3 localRotation)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_004a: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0087: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			CoordinatesArgumentValue<int>[] coordinates = GetCoordinates<TSource, int>(context, name);
			if (coordinates.Length < 2)
			{
				return Vector2Int.zero;
			}
			Vector2Int result = default(Vector2Int);
			((Vector2Int)(ref result))..ctor(coordinates[0].value, coordinates[1].value);
			if (coordinates[0].coordinatesType == CoordinateType.local && coordinates.Length == 3)
			{
				Vector3 val = offset + Quaternion.Euler(localRotation) * new Vector3((float)((Vector2Int)(ref result)).x, (float)((Vector2Int)(ref result)).y, (float)coordinates[2].value);
				return new Vector2Int(Mathf.FloorToInt(val.x), Mathf.FloorToInt(val.z));
			}
			if (coordinates[0].coordinatesType == CoordinateType.offset)
			{
				((Vector2Int)(ref result)).x = ((Vector2Int)(ref result)).x + Mathf.FloorToInt(offset.x);
			}
			if (coordinates[1].coordinatesType == CoordinateType.offset)
			{
				((Vector2Int)(ref result)).y = ((Vector2Int)(ref result)).y + Mathf.FloorToInt(offset.y);
			}
			return result;
		}

		public static CoordinatesArgumentType<float> Vector3(float? min = null, float? max = null, bool allowLocalType = true)
		{
			return Coordinates(min, max, (IStringReader x) => x.ReadFloat(), 3, allowLocalType ? 3 : 0);
		}

		public static Vector3 GetVector3<TSource>(CommandContext<TSource> context, string name) where TSource : ServerCommandSource
		{
			//IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			return GetVector3<TSource>(context, name, context.Source.position, context.Source.rotation);
		}

		public static Vector3 GetVector3<TSource>(CommandContext<TSource> context, string name, Vector3 offset, Vector3 localRotation)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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)
			CoordinatesArgumentValue<float>[] coordinates = GetCoordinates<TSource, float>(context, name);
			if (coordinates.Length < 3)
			{
				return Vector3.zero;
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(coordinates[0].value, coordinates[1].value, coordinates[2].value);
			if (coordinates[0].coordinatesType == CoordinateType.local)
			{
				return offset + Quaternion.Euler(localRotation) * new Vector3(val.x, val.y, val.z);
			}
			if (coordinates[0].coordinatesType == CoordinateType.offset)
			{
				val.x += offset.x;
			}
			if (coordinates[1].coordinatesType == CoordinateType.offset)
			{
				val.y += offset.y;
			}
			if (coordinates[2].coordinatesType == CoordinateType.offset)
			{
				val.z += offset.z;
			}
			return val;
		}

		public static CoordinatesArgumentType<int> Vector3Int(int? min = null, int? max = null, bool allowLocalType = true)
		{
			return Coordinates(min, max, (IStringReader x) => x.ReadInt(), 3, allowLocalType ? 3 : 0);
		}

		public static Vector3Int GetVector3Int<TSource>(CommandContext<TSource> context, string name) where TSource : ServerCommandSource
		{
			//IL_000d: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			return GetVector3Int<TSource>(context, name, context.Source.position, context.Source.rotation);
		}

		public static Vector3Int GetVector3Int<TSource>(CommandContext<TSource> context, string name, Vector3 offset, Vector3 localRotation)
		{
			//IL_000e: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			CoordinatesArgumentValue<int>[] coordinates = GetCoordinates<TSource, int>(context, name);
			if (coordinates.Length < 3)
			{
				return Vector3Int.zero;
			}
			Vector3Int result = default(Vector3Int);
			((Vector3Int)(ref result))..ctor(coordinates[0].value, coordinates[1].value, coordinates[2].value);
			if (coordinates[0].coordinatesType == CoordinateType.local && coordinates.Length == 3)
			{
				Vector3 val = offset + Quaternion.Euler(localRotation) * new Vector3((float)((Vector3Int)(ref result)).x, (float)((Vector3Int)(ref result)).y, (float)((Vector3Int)(ref result)).z);
				return new Vector3Int(Mathf.FloorToInt(val.x), Mathf.FloorToInt(val.y), Mathf.FloorToInt(val.z));
			}
			if (coordinates[0].coordinatesType == CoordinateType.offset)
			{
				((Vector3Int)(ref result)).x = ((Vector3Int)(ref result)).x + Mathf.FloorToInt(offset.x);
			}
			if (coordinates[1].coordinatesType == CoordinateType.offset)
			{
				((Vector3Int)(ref result)).y = ((Vector3Int)(ref result)).y + Mathf.FloorToInt(offset.y);
			}
			if (coordinates[2].coordinatesType == CoordinateType.offset)
			{
				((Vector3Int)(ref result)).z = ((Vector3Int)(ref result)).z + Mathf.FloorToInt(offset.z);
			}
			return result;
		}

		public static CoordinatesArgumentType<float> Vector4(float? min = null, float? max = null)
		{
			return Coordinates(min, max, (IStringReader x) => x.ReadFloat(), 4, 0);
		}

		public static Vector4 GetVector4<TSource>(CommandContext<TSource> context, string name, Vector4 offset)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			CoordinatesArgumentValue<float>[] coordinates = GetCoordinates<TSource, float>(context, name);
			if (coordinates.Length < 4)
			{
				return Vector4.zero;
			}
			Vector4 result = default(Vector4);
			((Vector4)(ref result))..ctor(coordinates[0].value, coordinates[1].value, coordinates[2].value, coordinates[3].value);
			if (coordinates[0].coordinatesType == CoordinateType.offset)
			{
				result.x += offset.x;
			}
			if (coordinates[1].coordinatesType == CoordinateType.offset)
			{
				result.y += offset.y;
			}
			if (coordinates[2].coordinatesType == CoordinateType.offset)
			{
				result.z += offset.z;
			}
			if (coordinates[3].coordinatesType == CoordinateType.offset)
			{
				result.w += offset.w;
			}
			return result;
		}

		public static CoordinatesArgumentType<float> Rect(float? min = null, float? max = null)
		{
			return Coordinates(min, max, (IStringReader x) => x.ReadFloat(), 4, 0);
		}

		public static Rect GetRect<TSource>(CommandContext<TSource> context, string name, Rect offset)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			CoordinatesArgumentValue<float>[] coordinates = GetCoordinates<TSource, float>(context, name);
			if (coordinates.Length < 4)
			{
				return Rect.zero;
			}
			Rect result = default(Rect);
			((Rect)(ref result))..ctor(coordinates[0].value, coordinates[1].value, coordinates[2].value, coordinates[3].value);
			if (coordinates[0].coordinatesType == CoordinateType.offset)
			{
				((Rect)(ref result)).x = ((Rect)(ref result)).x + ((Rect)(ref offset)).x;
			}
			if (coordinates[1].coordinatesType == CoordinateType.offset)
			{
				((Rect)(ref result)).y = ((Rect)(ref result)).y + ((Rect)(ref offset)).y;
			}
			if (coordinates[2].coordinatesType == CoordinateType.offset)
			{
				((Rect)(ref result)).width = ((Rect)(ref result)).width + ((Rect)(ref offset)).width;
			}
			if (coordinates[3].coordinatesType == CoordinateType.offset)
			{
				((Rect)(ref result)).height = ((Rect)(ref result)).height + ((Rect)(ref offset)).height;
			}
			return result;
		}

		public static CoordinatesArgumentType<int> RectInt(int? min = null, int? max = null)
		{
			return Coordinates(min, max, (IStringReader x) => x.ReadInt(), 4, 0);
		}

		public static Rect GetRectInt<TSource>(CommandContext<TSource> context, string name, Rect offset)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			CoordinatesArgumentValue<int>[] coordinates = GetCoordinates<TSource, int>(context, name);
			if (coordinates.Length < 4)
			{
				return Rect.zero;
			}
			Rect result = default(Rect);
			((Rect)(ref result))..ctor((float)coordinates[0].value, (float)coordinates[1].value, (float)coordinates[2].value, (float)coordinates[3].value);
			if (coordinates[0].coordinatesType == CoordinateType.offset)
			{
				((Rect)(ref result)).x = ((Rect)(ref result)).x + ((Rect)(ref offset)).x;
			}
			if (coordinates[1].coordinatesType == CoordinateType.offset)
			{
				((Rect)(ref result)).y = ((Rect)(ref result)).y + ((Rect)(ref offset)).y;
			}
			if (coordinates[2].coordinatesType == CoordinateType.offset)
			{
				((Rect)(ref result)).width = ((Rect)(ref result)).width + ((Rect)(ref offset)).width;
			}
			if (coordinates[3].coordinatesType == CoordinateType.offset)
			{
				((Rect)(ref result)).height = ((Rect)(ref result)).height + ((Rect)(ref offset)).height;
			}
			return result;
		}

		public static CoordinatesArgumentType<float> Color()
		{
			return Coordinates(0f, 1f, (IStringReader x) => (float)x.ReadInt() / 255f, 3, 0);
		}

		public static Color GetColor<TSource>(CommandContext<TSource> context, string name, Color offset)
		{
			//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)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			CoordinatesArgumentValue<float>[] coordinates = GetCoordinates<TSource, float>(context, name);
			if (coordinates.Length < 3)
			{
				return Color.white;
			}
			Color result = default(Color);
			((Color)(ref result))..ctor(coordinates[0].value, coordinates[1].value, coordinates[2].value);
			if (coordinates[0].coordinatesType == CoordinateType.offset)
			{
				result.r += offset.r;
			}
			if (coordinates[1].coordinatesType == CoordinateType.offset)
			{
				result.g += offset.g;
			}
			if (coordinates[2].coordinatesType == CoordinateType.offset)
			{
				result.b += offset.b;
			}
			return result;
		}

		public static CoordinatesArgumentType<float> ColorAlpha()
		{
			return Coordinates(0f, 1f, (IStringReader x) => (float)x.ReadInt() / 255f, 4, 0);
		}

		public static Color GetColorAlpha<TSource>(CommandContext<TSource> context, string name, Color offset)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			CoordinatesArgumentValue<float>[] coordinates = GetCoordinates<TSource, float>(context, name);
			if (coordinates.Length < 4)
			{
				return Color.white;
			}
			Color result = default(Color);
			((Color)(ref result))..ctor(coordinates[0].value, coordinates[1].value, coordinates[2].value, coordinates[3].value);
			if (coordinates[0].coordinatesType == CoordinateType.offset)
			{
				result.r += offset.r;
			}
			if (coordinates[1].coordinatesType == CoordinateType.offset)
			{
				result.g += offset.g;
			}
			if (coordinates[2].coordinatesType == CoordinateType.offset)
			{
				result.b += offset.b;
			}
			if (coordinates[3].coordinatesType == CoordinateType.offset)
			{
				result.a += offset.a;
			}
			return result;
		}

		public static SelectorArgumentType Selector(bool onlyPlayer = false, bool limit = false)
		{
			return new SelectorArgumentType(onlyPlayer, limit);
		}

		public static SelectorArgumentValue GetSelector<TSource>(CommandContext<TSource> context, string name) where TSource : ServerCommandSource
		{
			return ((CommandContext<SelectorArgumentValue>)(object)context).GetArgument<SelectorArgumentValue>(name);
		}

		public static TransformArgumentType Transform()
		{
			return new TransformArgumentType();
		}

		public static Transform GetTransform<TSource>(CommandContext<TSource> context, string name)
		{
			return ((CommandContext<Transform>)(object)context).GetArgument<Transform>(name);
		}

		public static TransformsStringArgumentType Transforms()
		{
			return new TransformsStringArgumentType();
		}

		public static Transform[] GetTransforms<TSource>(CommandContext<TSource> context, string name)
		{
			return ((CommandContext<Transform[]>)(object)context).GetArgument<Transform[]>(name);
		}

		public static GameObjectArgumentType GameObject()
		{
			return new GameObjectArgumentType();
		}

		public static GameObject GetGameObject<TSource>(CommandContext<TSource> context, string name)
		{
			return ((CommandContext<GameObject>)(object)context).GetArgument<GameObject>(name);
		}

		public static GameObjectsStringArgumentType GameObjects()
		{
			return new GameObjectsStringArgumentType();
		}

		public static GameObject[] GetGameObjects<TSource>(CommandContext<TSource> context, string name)
		{
			return ((CommandContext<GameObject[]>)(object)context).GetArgument<GameObject[]>(name);
		}

		public static SpriteArgumentType Sprite()
		{
			return new SpriteArgumentType();
		}

		public static Sprite GetSprite<TSource>(CommandContext<TSource> context, string name)
		{
			return ((CommandContext<Sprite>)(object)context).GetArgument<Sprite>(name);
		}

		public static SpritesArgumentType Sprites()
		{
			return new SpritesArgumentType();
		}

		public static Sprite[] GetSprites<TSource>(CommandContext<TSource> context, string name)
		{
			return ((CommandContext<Sprite[]>)(object)context).GetArgument<Sprite[]>(name);
		}

		public static PosSwizzleArgumentType PosSwizzle()
		{
			return new PosSwizzleArgumentType();
		}

		public static PosSwizzleEnum GetPosSwizzle<TSource>(CommandContext<TSource> context, string name)
		{
			return ((CommandContext<PosSwizzleEnum>)(object)context).GetArgument<PosSwizzleEnum>(name);
		}

		public static EnemyTypeArgumentType EnemyType()
		{
			return new EnemyTypeArgumentType();
		}

		public static EnemyType GetEnemyType<TSource>(CommandContext<TSource> context, string name)
		{
			return ((CommandContext<EnemyType>)(object)context).GetArgument<EnemyType>(name);
		}

		public static AnomalyTypeArgumentType AnomalyType()
		{
			return new AnomalyTypeArgumentType();
		}

		public static AnomalyType GetAnomalyType<TSource>(CommandContext<TSource> context, string name)
		{
			return ((CommandContext<AnomalyType>)(object)context).GetArgument<AnomalyType>(name);
		}

		public static ItemTypeArgumentType ItemType()
		{
			return new ItemTypeArgumentType();
		}

		public static Item GetItemType<TSource>(CommandContext<TSource> context, string name)
		{
			return ((CommandContext<Item>)(object)context).GetArgument<Item>(name);
		}
	}
	public struct NetworkIntelliSenseArray : INetworkSerializable, IEnumerable<NetworkIntelliSenseArray.Suggestion>, IEnumerable
	{
		public enum Type
		{
			suggestion,
			usage,
			exception
		}

		public struct Suggestion : INetworkSerializable
		{
			public StringRange range;

			public string text;

			public Suggestion(StringRange range, string text)
			{
				this.range = range;
				this.text = text;
			}

			public static implicit operator Suggestion(string text)
			{
				return new Suggestion(default(StringRange), text);
			}

			public static implicit operator Suggestion(Suggestion suggestion)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return new Suggestion(suggestion.Range, suggestion.Text);
			}

			unsafe void INetworkSerializable.NetworkSerialize<T>(BufferSerializer<T> serializer)
			{
				//IL_0018: 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)
				serializer.SerializeValue(ref text, false);
				((BufferSerializer<StringRange>*)(&serializer))->SerializeValue<StringRange>(ref range, default(ForNetworkSerializable));
			}

			public override readonly string ToString()
			{
				return $"NetworkIntelliSenseArray.Suggestion{{range={range}, text={text}}}";
			}
		}

		public struct StringRange : INetworkSerializable
		{
			public int start;

			public int end;

			public StringRange(int start, int end)
			{
				this.start = start;
				this.end = end;
			}

			public readonly string Get(string source)
			{
				return source.Substring(start, end - start);
			}

			public static implicit operator StringRange(StringRange range)
			{
				return new StringRange(((StringRange)(ref range)).Start, ((StringRange)(ref range)).End);
			}

			unsafe void INetworkSerializable.NetworkSerialize<T>(BufferSerializer<T> serializer)
			{
				//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)
				//IL_0020: 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)
				((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref start, default(ForPrimitives));
				((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref end, default(ForPrimitives));
			}

			public override readonly string ToString()
			{
				return $"NetworkIntelliSenseArray.StringRange{{start={start}, end={end}}}";
			}
		}

		public Type type;

		private Suggestion[]? texts;

		public readonly int length
		{
			get
			{
				Suggestion[]? array = texts;
				if (array == null)
				{
					return 0;
				}
				return array.Length;
			}
		}

		public readonly Suggestion this[int index]
		{
			get
			{
				Suggestion[]? array = texts;
				if (array == null)
				{
					return Array.Empty<Suggestion>()[index];
				}
				return array[index];
			}
			set
			{
				if (texts != null)
				{
					texts[index] = value;
				}
				else
				{
					Array.Empty<Suggestion>()[index] = value;
				}
			}
		}

		public NetworkIntelliSenseArray(Type type, Suggestion[] texts)
		{
			this.type = type;
			this.texts = texts;
		}

		public override readonly string ToString()
		{
			return $"NetworkIntelliSenseArray{{type={type}, length={length}}}";
		}

		unsafe void INetworkSerializable.NetworkSerialize<T>(BufferSerializer<T> serializer)
		{
			//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)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<Type>*)(&serializer))->SerializeValue<Type>(ref type, default(ForEnums));
			int num = ((texts != null) ? texts.Length : 0);
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref num, default(ForPrimitives));
			if (serializer.IsReader)
			{
				texts = new Suggestion[num];
			}
			for (int i = 0; i < num; i++)
			{
				((BufferSerializer<Suggestion>*)(&serializer))->SerializeValue<Suggestion>(ref texts[i], default(ForNetworkSerializable));
			}
		}

		public readonly IEnumerator<Suggestion> GetEnumerator()
		{
			return ((IEnumerable<Suggestion>)texts)?.GetEnumerator() ?? Enumerable.Empty<Suggestion>().GetEnumerator();
		}

		readonly IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}
	}
	public readonly struct Range : IEquatable<Range>
	{
		public readonly float? min;

		public readonly float? max;

		public Range(float? value)
		{
			min = (max = value);
		}

		public Range(float? min, float? max)
		{
			if (min.HasValue && max.HasValue && max < min)
			{
				this.max = max;
				this.min = min;
			}
			else
			{
				this.min = min;
				this.max = max;
			}
		}

		public bool Contains(float value)
		{
			if (!min.HasValue || min.Value <= value)
			{
				if (max.HasValue)
				{
					return value <= max.Value;
				}
				return true;
			}
			return false;
		}

		public bool Equals(Range other)
		{
			if ((!min.HasValue && !other.min.HasValue) || (min.HasValue && other.min.HasValue && min.Value == other.min.Value))
			{
				if (max.HasValue || other.max.HasValue)
				{
					if (max.HasValue && other.max.HasValue)
					{
						return max.Value == other.max.Value;
					}
					return false;
				}
				return true;
			}
			return false;
		}

		public override bool Equals(object? obj)
		{
			if (obj is Range other)
			{
				return Equals(other);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return 542216 + min.GetHashCode() * 215321 + max.GetHashCode() * 826715;
		}

		public static bool operator ==(Range left, Range right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(Range left, Range right)
		{
			return !(left == right);
		}

		public override string ToString()
		{
			return $"{min}..{max}";
		}
	}
	public readonly struct RangeInt : IEquatable<RangeInt>
	{
		public readonly int? min;

		public readonly int? max;

		public RangeInt(int? value)
		{
			min = (max = value);
		}

		public RangeInt(int? min, int? max)
		{
			if (min.HasValue && max.HasValue && max < min)
			{
				this.max = max;
				this.min = min;
			}
			else
			{
				this.min = min;
				this.max = max;
			}
		}

		public bool Contains(float value)
		{
			if (!min.HasValue || (float)min.Value <= value)
			{
				if (max.HasValue)
				{
					return value <= (float)max.Value;
				}
				return true;
			}
			return false;
		}

		public bool Equals(RangeInt other)
		{
			if ((!min.HasValue && !other.min.HasValue) || (min.HasValue && other.min.HasValue && min.Value == other.min.Value))
			{
				if (max.HasValue || other.max.HasValue)
				{
					if (max.HasValue && other.max.HasValue)
					{
						return max.Value == other.max.Value;
					}
					return false;
				}
				return true;
			}
			return false;
		}

		public override bool Equals(object? obj)
		{
			if (obj is RangeInt other)
			{
				return Equals(other);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return 542216 + min.GetHashCode() * 215321 + max.GetHashCode() * 826715;
		}

		public static bool operator ==(RangeInt left, RangeInt right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(RangeInt left, RangeInt right)
		{
			return !(left == right);
		}

		public override string ToString()
		{
			return $"{min}..{max}";
		}
	}
	[StaticNetcode]
	public abstract class ServerCommand
	{
		public struct NetworkStringRanges : INetworkSerializable
		{
			public int start;

			public int end;

			public NetworkStringRanges(int start, int end)
			{
				this.start = start;
				this.end = end;
			}

			public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
			{
				//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)
				//IL_0020: 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)
				((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref start, default(ForPrimitives));
				((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref end, default(ForPrimitives));
			}
		}

		private static HashSet<ulong> opLists = new HashSet<ulong>();

		private static Action<NetworkIntelliSenseArray>? requestedIntelliSense;

		public static RootCommandNode<ServerCommandSource> rootNode
		{
			get
			{
				return dispatcher.Root;
			}
			set
			{
				dispatcher = new CommandDispatcher<ServerCommandSource>(value);
			}
		}

		public static CommandDispatcher<ServerCommandSource> dispatcher { get; private set; } = new CommandDispatcher<ServerCommandSource>();


		public abstract void Register();

		public static void Reset()
		{
			dispatcher = new CommandDispatcher<ServerCommandSource>();
		}

		public static void AllRegister()
		{
			opLists.Clear();
			Debug.Log("Command Registering...");
			for (int i = 0; i < ReflectionManager.types.Count; i++)
			{
				Type type = ReflectionManager.types[i];
				if (!type.IsAbstract && typeof(ServerCommand).IsAssignableFrom(type))
				{
					try
					{
						((ServerCommand)Activator.CreateInstance(type, nonPublic: true)).Register();
						Debug.Log("Registered command: " + type.Name);
					}
					catch (Exception data)
					{
						Debug.LogError(data);
					}
				}
			}
			Debug.Log("Command Registered!");
		}

		public static void ExecuteCommand(string command)
		{
			//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)
			Debug.Log("Sending commands to the server side : " + command);
			InternalExecuteCommandServerRpc(command);
		}

		[ServerRpc]
		private static void InternalExecuteCommandServerRpc(string command, ServerRpcParams rpcParams = default(ServerRpcParams))
		{
			//IL_005d: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer || !rpcParams.TryGetPlayer(out PlayerControllerB player))
			{
				return;
			}
			Debug.Log("Received command from " + player.playerUsername + " : " + command);
			ServerCommandSource serverCommandSource = new ServerCommandSource((NetworkBehaviour)(object)player, IsOp(player));
			try
			{
				dispatcher.Execute(command, serverCommandSource);
			}
			catch (CommandSyntaxException val)
			{
				CommandSyntaxException e = val;
				serverCommandSource.SendCommandResult((Exception)(object)e);
			}
			catch (Exception data)
			{
				Debug.LogError(data);
			}
		}

		public static void RequestIntelliSense(string command, int cursor, Action<NetworkIntelliSenseArray> action)
		{
			//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)
			Debug.LogD($"Requesting intelli sense to the server side : {cursor} : {command}");
			InternalRequestIntelliSenseServerRpc(command, cursor);
			requestedIntelliSense = action;
		}

		public static void CancelRequestIntelliSense()
		{
			requestedIntelliSense = null;
		}

		[ServerRpc]
		private static async void InternalRequestIntelliSenseServerRpc(string command, int cursor, ServerRpcParams rpcParams = default(ServerRpcParams))
		{
			//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)
			if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsServer && rpcParams.TryGetPlayer(out PlayerControllerB player))
			{
				Debug.LogD($"Received request intelli sense from {player.playerUsername} : {cursor} : {command}");
				NetworkIntelliSenseArray networkIntelliSenseArray = await dispatcher.GetIntelliSenseText(command, new ServerCommandSource((NetworkBehaviour)(object)player, IsOp(player)), cursor);
				Debug.LogD($"Sending intelli sense to {player.playerUsername} : {networkIntelliSenseArray}");
				SendIntelliSenseClientRpc(networkIntelliSenseArray, player.ToRpc());
			}
		}

		[ClientRpc]
		private static void SendIntelliSenseClientRpc(NetworkIntelliSenseArray intelliSenseArray, ClientRpcParams rpcParams = default(ClientRpcParams))
		{
			Debug.LogD($"Received intelli sense from server side : {intelliSenseArray}");
			requestedIntelliSense?.Invoke(intelliSenseArray);
		}

		public static bool IsOp(PlayerControllerB player)
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer)
			{
				return false;
			}
			if (GameNetworkManager.Instance.disableSteam)
			{
				return opLists.Contains(player.playerClientId);
			}
			return opLists.Contains(player.playerSteamId);
		}

		public static bool AddOp(PlayerControllerB targetPlayer)
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer)
			{
				return false;
			}
			if (GameNetworkManager.Instance.disableSteam)
			{
				return opLists.Add(targetPlayer.playerClientId);
			}
			return opLists.Add(targetPlayer.playerSteamId);
		}

		public static bool RemoveOp(PlayerControllerB targetPlayer)
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer)
			{
				return false;
			}
			if (GameNetworkManager.Instance.disableSteam)
			{
				return opLists.Remove(targetPlayer.playerClientId);
			}
			return opLists.Remove(targetPlayer.playerSteamId);
		}
	}
	public class ServerCommandSource : ICloneable
	{
		public string name { get; private set; }

		public NetworkBehaviour? sender { get; private set; }

		public PlayerControllerB? player { get; private set; }

		public PlayerControllerB? firstPlayer { get; }

		public Vector3 position { get; private set; } = Vector3.zero;


		public Vector3 rotation { get; private set; } = Vector3.zero;


		public bool isOp { get; private set; }

		public override string ToString()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			return string.Format("{0}:{1}, {2}:{3}, {4}:{5}, {6}:{7}, {8}:{9}", "name", name, "sender", sender, "player", player, "position", position, "rotation", rotation);
		}

		public ServerCommandSource SetSender(NetworkBehaviour sender)
		{
			name = ((Object)sender).name;
			this.sender = sender;
			player = (PlayerControllerB?)(object)((sender is PlayerControllerB) ? sender : null);
			return this;
		}

		public ServerCommandSource SetPosition(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			this.position = position;
			return this;
		}

		public ServerCommandSource SetRotation(Vector3 rotation)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			this.rotation = rotation;
			return this;
		}

		public void SendCommandResult(string text, bool sendGlobal = true)
		{
			if ((Object)(object)sender == (Object)null)
			{
				return;
			}
			BFLCUtility.SendChat("<color=white><size=10>" + text + "</size></color>", firstPlayer);
			if (sendGlobal)
			{
				BFLCUtility.SendChat("<color=#aaaaaa><size=10><i>[" + sender.GetEntityName() + "] " + text + "</i></size></color>", from x in BFLCUtility.GetPlayers()
					where (Object)(object)x != (Object)(object)firstPlayer
					select x);
			}
		}

		public void SendCommandResult(Exception e)
		{
			if (!((Object)(object)firstPlayer == (Object)null))
			{
				BFLCUtility.SendChat("<color=#ff5555><size=10>" + e.Message + "</size></color>", firstPlayer);
			}
		}

		public ServerCommandSource Clone()
		{
			return new ServerCommandSource(this);
		}

		object ICloneable.Clone()
		{
			return Clone();
		}

		public ServerCommandSource(string name = "IL", bool isOp = false)
			: this(name, Vector3.zero, Vector3.zero, isOp)
		{
		}//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)


		public ServerCommandSource(Vector3 position, Vector3 rotation, bool isOp = false)
			: this("IL", position, rotation, isOp)
		{
		}//IL_0006: 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)


		public ServerCommandSource(NetworkBehaviour entity, bool isOp = false)
			: this(entity, ((Component)entity).transform.position, ((Component)entity).transform.eulerAngles, isOp)
		{
			//IL_0008: 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)
			sender = entity;
		}

		public ServerCommandSource(NetworkBehaviour entity, Vector3 position, Vector3 rotation, bool isOp = false)
			: this(((Object)entity).name, position, rotation, isOp)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			sender = entity;
			NetworkBehaviour? obj = sender;
			player = (PlayerControllerB?)(object)((obj is PlayerControllerB) ? obj : null);
			firstPlayer = player;
		}

		public ServerCommandSource(string name, Vector3 position, Vector3 rotation, bool isOp = false)
		{
			//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_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_0024: 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)
			this.name = name;
			this.position = position;
			this.rotation = rotation;
			this.isOp = isOp;
		}

		public ServerCommandSource(ServerCommandSource source)
		{
			//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_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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			name = source.name;
			sender = source.sender;
			player = source.player;
			firstPlayer = player;
			position = source.position;
			rotation = source.rotation;
		}
	}
	public static class StringReaderExpansion
	{
		public static PosSwizzleEnum ReadPosSwizzle(this IStringReader reader)
		{
			PosSwizzleEnum posSwizzleEnum = PosSwizzleEnum.none;
			while (((IImmutableStringReader)reader).CanRead() && !char.IsWhiteSpace(((IImmutableStringReader)reader).Peek()))
			{
				if (((IImmutableStringReader)reader).Peek() == 'x')
				{
					int cursor = reader.Cursor;
					reader.Cursor = cursor + 1;
					if (posSwizzleEnum.HasFlag(PosSwizzleEnum.x))
					{
						throw CommandSyntaxException.BuiltInExceptions.InvalidPosSwizzle().CreateWithContext((IImmutableStringReader)(object)reader);
					}
					posSwizzleEnum = (posSwizzleEnum.HasFlag(PosSwizzleEnum.none) ? PosSwizzleEnum.x : (posSwizzleEnum | PosSwizzleEnum.x));
					continue;
				}
				if (((IImmutableStringReader)reader).Peek() == 'y')
				{
					int cursor = reader.Cursor;
					reader.Cursor = cursor + 1;
					if (posSwizzleEnum.HasFlag(PosSwizzleEnum.y))
					{
						throw CommandSyntaxException.BuiltInExceptions.InvalidPosSwizzle().CreateWithContext((IImmutableStringReader)(object)reader);
					}
					posSwizzleEnum = (posSwizzleEnum.HasFlag(PosSwizzleEnum.none) ? PosSwizzleEnum.y : (posSwizzleEnum | PosSwizzleEnum.y));
					continue;
				}
				if (((IImmutableStringReader)reader).Peek() == 'z')
				{
					int cursor = reader.Cursor;
					reader.Cursor = cursor + 1;
					if (posSwizzleEnum.HasFlag(PosSwizzleEnum.z))
					{
						throw CommandSyntaxException.BuiltInExceptions.InvalidPosSwizzle().CreateWithContext((IImmutableStringReader)(object)reader);
					}
					posSwizzleEnum = (posSwizzleEnum.HasFlag(PosSwizzleEnum.none) ? PosSwizzleEnum.z : (posSwizzleEnum | PosSwizzleEnum.z));
					continue;
				}
				throw CommandSyntaxException.BuiltInExceptions.InvalidPosSwizzle().CreateWithContext((IImmutableStringReader)(object)reader);
			}
			return posSwizzleEnum;
		}

		public static Range ReadRange(this IStringReader reader)
		{
			int cursor = reader.Cursor;
			string text = reader.ReadNumberString();
			string[] array = text.Split("..");
			if (array.Length == 2)
			{
				float? min = null;
				string text2 = array[0];
				if (!string.IsNullOrEmpty(text2))
				{
					try
					{
						min = float.Parse(text2);
					}
					catch (FormatException)
					{
						reader.Cursor = cursor;
						throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidFloat().CreateWithContext((IImmutableStringReader)(object)reader, (object)text2);
					}
				}
				float? max = null;
				string text3 = array[1];
				if (!string.IsNullOrEmpty(text3))
				{
					try
					{
						max = float.Parse(text3);
					}
					catch (FormatException)
					{
						reader.Cursor = cursor;
						throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidFloat().CreateWithContext((IImmutableStringReader)(object)reader, (object)text3);
					}
				}
				if (!min.HasValue && !max.HasValue)
				{
					throw CommandSyntaxException.BuiltInExceptions.RangeEmpty().CreateWithContext((IImmutableStringReader)(object)reader);
				}
				return new Range(min, max);
			}
			if (array.Length == 1)
			{
				try
				{
					return new Range(float.Parse(text));
				}
				catch (FormatException)
				{
					reader.Cursor = cursor;
					throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidFloat().CreateWithContext((IImmutableStringReader)(object)reader, (object)text);
				}
			}
			throw CommandSyntaxException.BuiltInExceptions.RangeEmpty().CreateWithContext((IImmutableStringReader)(object)reader);
		}

		public static RangeInt ReadRangeInt(this IStringReader reader)
		{
			int cursor = reader.Cursor;
			string text = reader.ReadNumberString();
			string[] array = text.Split("..");
			if (array.Length == 2)
			{
				int? min;
				try
				{
					min = int.Parse(array[0]);
				}
				catch (FormatException)
				{
					reader.Cursor = cursor;
					throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidInt().CreateWithContext((IImmutableStringReader)(object)reader, (object)array[0]);
				}
				int? max;
				try
				{
					max = int.Parse(array[1]);
				}
				catch (FormatException)
				{
					reader.Cursor = cursor;
					throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidInt().CreateWithContext((IImmutableStringReader)(object)reader, (object)array[1]);
				}
				if (!min.HasValue && !max.HasValue)
				{
					throw CommandSyntaxException.BuiltInExceptions.RangeEmpty().CreateWithContext((IImmutableStringReader)(object)reader);
				}
				return new RangeInt(min, max);
			}
			if (array.Length == 1)
			{
				try
				{
					return new RangeInt(int.Parse(text));
				}
				catch (FormatException)
				{
					reader.Cursor = cursor;
					throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidInt().CreateWithContext((IImmutableStringReader)(object)reader, (object)text);
				}
			}
			throw CommandSyntaxException.BuiltInExceptions.RangeEmpty().CreateWithContext((IImmutableStringReader)(object)reader);
		}

		public static string ReadNumberString(this IStringReader reader)
		{
			int cursor = reader.Cursor;
			while (((IImmutableStringReader)reader).CanRead() && IsAllowedNumber(((IImmutableStringReader)reader).Peek()))
			{
				reader.Skip();
			}
			return ((IImmutableStringReader)reader).String.Substring(cursor, reader.Cursor - cursor);
		}

		public static bool IsAllowedNumber(char c)
		{
			if ((c < '0' || c > '9') && c != '-')
			{
				return c == '.';
			}
			return true;
		}
	}
}
namespace Rumi.BrigadierForLethalCompany.API.Commands
{
	public sealed class DeopCommand : ServerCommand
	{
		public const string resultText = "Operator revoked for {0}";

		private DeopCommand()
		{
		}

		public override void Register()
		{
			ServerCommand.dispatcher.Register((Func<IArgumentContext<ServerCommandSource>, LiteralArgumentBuilder<ServerCommandSource>>)((IArgumentContext<ServerCommandSource> x) => ((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)((ArgumentBuilder<ServerCommandSource, LiteralArgumentBuilder<ServerCommandSource>, LiteralCommandNode<ServerCommandSource>>)(object)LiteralArgumentBuilderExtensions.Literal<ServerCommandSource>(x, "deop")).Requires((Predicate<ServerCommandSource>)((ServerCommandSource x) => x.isOp))).Then<ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>((Func<IArgumentContext<ServerCommandSource>, IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>>)((IArgumentContext<ServerCommandSource> x) => (IArgumentBuilder<ServerCommandSource, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>)(object)((ArgumentBuilder<ServerCommandSource, RequiredArgumentBuilder<ServerCommandSource, SelectorArgumentValue>, ArgumentCommandNode<ServerCommandSource, SelectorArgumentValue>>)(object)RequiredArgumentBuilderExtensions.Argument<ServerCommandSource, SelectorArgumentValue>(x, "targets", (IArgumentType<SelectorArgumentValue>)LethalArguments.Selector(onlyPlayer: true)).Suggests((SuggestionProvider<ServerCommandSource>)delegate(CommandContext<ServerCommandSource> context, SuggestionsBuilder builder)
			{
				SelectorArgumentType.PlayerListSuggestions<ServerCommandSource>(from x in BFLCUtility.GetPlayers()
					where ServerCommand.IsOp(x)
					select x, context, builder);
				return builder.BuildAsync();
			})).Executes((Command<ServerCommandSource>)delegate(CommandContext<ServerCommandSource> x)
			{
				IEnumerable<PlayerControllerB> enumerable = LethalArguments.GetSelector<ServerCommandSource>(x, "targets").GetEntitys(x.Source).OfType<PlayerControllerB>();
				int num = 0;
				foreach (PlayerControllerB item in enumerable)
				{
					if (item != null)
					{
						PlayerControllerB targetPlayer = item;
						ServerCommand.RemoveOp(targetPlayer);
						num++;
					}
				}
				x.Source.SendCommandResult($"Operator revoked for {enumerable.GetPlayerName()}");
				return num;
			})))));
		}
	}
	public sealed class OpCommand : ServerCommand
	{
		public const string resultText = "Operator granted to {0}";

		private OpCommand()
		{
		}

		pu

Brigadier.NET.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
using Brigadier.NET.ArgumentTypes;
using Brigadier.NET.Builder;
using Brigadier.NET.Context;
using Brigadier.NET.Exceptions;
using Brigadier.NET.Suggestion;
using Brigadier.NET.Tree;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Steven Blom")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("\n\t\t\tBrigadier.NET is a port of Mojang's brigadier command line parser & dispatcher, originally for Minecraft: Java Edition and now freely available for use elsewhere under the MIT license.\n\n\t\t\tThis port is not supported by Mojang or Microsoft.\n\t\t")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2b5a647c0fc48c8366f18c1f801125ff6fbf6f00")]
[assembly: AssemblyProduct("Brigadier.NET")]
[assembly: AssemblyTitle("Brigadier.NET")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/AtomicBlom/Brigadier.NET")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 JetBrains.Annotations
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.GenericParameter)]
	internal sealed class CanBeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.GenericParameter)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Delegate)]
	internal sealed class ItemNotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Delegate)]
	internal sealed class ItemCanBeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Delegate)]
	internal sealed class StringFormatMethodAttribute : Attribute
	{
		[NotNull]
		public string FormatParameterName { get; }

		public StringFormatMethodAttribute([NotNull] string formatParameterName)
		{
			FormatParameterName = formatParameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class StructuredMessageTemplateAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = true)]
	internal sealed class ValueProviderAttribute : Attribute
	{
		[NotNull]
		public string Name { get; }

		public ValueProviderAttribute([NotNull] string name)
		{
			Name = name;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Delegate, AllowMultiple = true)]
	internal sealed class ValueRangeAttribute : Attribute
	{
		public object From { get; }

		public object To { get; }

		public ValueRangeAttribute(long from, long to)
		{
			From = from;
			To = to;
		}

		public ValueRangeAttribute(ulong from, ulong to)
		{
			From = from;
			To = to;
		}

		public ValueRangeAttribute(long value)
		{
			From = (To = value);
		}

		public ValueRangeAttribute(ulong value)
		{
			From = (To = value);
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Delegate)]
	internal sealed class NonNegativeValueAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class InvokerParameterNameAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
	{
		[CanBeNull]
		public string ParameterName { get; }

		public NotifyPropertyChangedInvocatorAttribute()
		{
		}

		public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
	internal sealed class ContractAnnotationAttribute : Attribute
	{
		[NotNull]
		public string Contract { get; }

		public bool ForceFullStates { get; }

		public ContractAnnotationAttribute([NotNull] string contract)
			: this(contract, forceFullStates: false)
		{
		}

		public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)
		{
			Contract = contract;
			ForceFullStates = forceFullStates;
		}
	}
	[AttributeUsage(AttributeTargets.All)]
	internal sealed class LocalizationRequiredAttribute : Attribute
	{
		public bool Required { get; }

		public LocalizationRequiredAttribute()
			: this(required: true)
		{
		}

		public LocalizationRequiredAttribute(bool required)
		{
			Required = required;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface)]
	internal sealed class CannotApplyEqualityOperatorAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter)]
	internal sealed class DefaultEqualityUsageAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
	[BaseTypeRequired(typeof(Attribute))]
	internal sealed class BaseTypeRequiredAttribute : Attribute
	{
		[NotNull]
		public Type BaseType { get; }

		public BaseTypeRequiredAttribute([NotNull] Type baseType)
		{
			BaseType = baseType;
		}
	}
	[AttributeUsage(AttributeTargets.All)]
	internal sealed class UsedImplicitlyAttribute : Attribute
	{
		public ImplicitUseKindFlags UseKindFlags { get; }

		public ImplicitUseTargetFlags TargetFlags { get; }

		public string Reason { get; set; }

		public UsedImplicitlyAttribute()
			: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default)
		{
		}

		public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)
			: this(useKindFlags, ImplicitUseTargetFlags.Default)
		{
		}

		public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)
			: this(ImplicitUseKindFlags.Default, targetFlags)
		{
		}

		public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
		{
			UseKindFlags = useKindFlags;
			TargetFlags = targetFlags;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Parameter | AttributeTargets.GenericParameter)]
	internal sealed class MeansImplicitUseAttribute : Attribute
	{
		[UsedImplicitly]
		public ImplicitUseKindFlags UseKindFlags { get; }

		[UsedImplicitly]
		public ImplicitUseTargetFlags TargetFlags { get; }

		public MeansImplicitUseAttribute()
			: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default)
		{
		}

		public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)
			: this(useKindFlags, ImplicitUseTargetFlags.Default)
		{
		}

		public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)
			: this(ImplicitUseKindFlags.Default, targetFlags)
		{
		}

		public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
		{
			UseKindFlags = useKindFlags;
			TargetFlags = targetFlags;
		}
	}
	[Flags]
	internal enum ImplicitUseKindFlags
	{
		Default = 7,
		Access = 1,
		Assign = 2,
		InstantiatedWithFixedConstructorSignature = 4,
		InstantiatedNoFixedConstructorSignature = 8
	}
	[Flags]
	internal enum ImplicitUseTargetFlags
	{
		Default = 1,
		Itself = 1,
		Members = 2,
		WithInheritors = 4,
		WithMembers = 3
	}
	[MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)]
	[AttributeUsage(AttributeTargets.All, Inherited = false)]
	internal sealed class PublicAPIAttribute : Attribute
	{
		[CanBeNull]
		public string Comment { get; }

		public PublicAPIAttribute()
		{
		}

		public PublicAPIAttribute([NotNull] string comment)
		{
			Comment = comment;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class InstantHandleAttribute : Attribute
	{
		public bool RequireAwait { get; set; }
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class PureAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class MustUseReturnValueAttribute : Attribute
	{
		[CanBeNull]
		public string Justification { get; }

		public bool IsFluentBuilderMethod { get; set; }

		public MustUseReturnValueAttribute()
		{
		}

		public MustUseReturnValueAttribute([NotNull] string justification)
		{
			Justification = justification;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Parameter)]
	internal sealed class MustDisposeResourceAttribute : Attribute
	{
		public bool Value { get; }

		public MustDisposeResourceAttribute()
		{
			Value = true;
		}

		public MustDisposeResourceAttribute(bool value)
		{
			Value = value;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class HandlesResourceDisposalAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class RequireStaticDelegateAttribute : Attribute
	{
		public bool IsError { get; set; }
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.GenericParameter)]
	internal sealed class ProvidesContextAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class PathReferenceAttribute : Attribute
	{
		[CanBeNull]
		public string BasePath { get; }

		public PathReferenceAttribute()
		{
		}

		public PathReferenceAttribute([NotNull][PathReference] string basePath)
		{
			BasePath = basePath;
		}
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class SourceTemplateAttribute : Attribute
	{
		public SourceTemplateTargetExpression Target { get; set; }
	}
	internal enum SourceTemplateTargetExpression
	{
		Inner,
		Outer
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Parameter, AllowMultiple = true)]
	internal sealed class MacroAttribute : Attribute
	{
		[CanBeNull]
		public string Expression { get; set; }

		public int Editable { get; set; }

		[CanBeNull]
		public string Target { get; set; }
	}
	[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.ReturnValue)]
	internal sealed class CollectionAccessAttribute : Attribute
	{
		public CollectionAccessType CollectionAccessType { get; }

		public CollectionAccessAttribute(CollectionAccessType collectionAccessType)
		{
			CollectionAccessType = collectionAccessType;
		}
	}
	[Flags]
	internal enum CollectionAccessType
	{
		None = 0,
		Read = 1,
		ModifyExistingContent = 2,
		UpdatedContent = 6
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class AssertionMethodAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class AssertionConditionAttribute : Attribute
	{
		public AssertionConditionType ConditionType { get; }

		public AssertionConditionAttribute(AssertionConditionType conditionType)
		{
			ConditionType = conditionType;
		}
	}
	internal enum AssertionConditionType
	{
		IS_TRUE,
		IS_FALSE,
		IS_NULL,
		IS_NOT_NULL
	}
	[Obsolete("Use [ContractAnnotation('=> halt')] instead")]
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class TerminatesProgramAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class LinqTunnelAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class NoEnumerationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class RegexPatternAttribute : Attribute
	{
	}
	internal enum InjectedLanguage
	{
		CSS,
		HTML,
		JAVASCRIPT,
		JSON,
		XML
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
	internal sealed class LanguageInjectionAttribute : Attribute
	{
		public InjectedLanguage InjectedLanguage { get; }

		[CanBeNull]
		public string InjectedLanguageName { get; }

		[CanBeNull]
		public string Prefix { get; set; }

		[CanBeNull]
		public string Suffix { get; set; }

		public LanguageInjectionAttribute(InjectedLanguage injectedLanguage)
		{
			InjectedLanguage = injectedLanguage;
		}

		public LanguageInjectionAttribute([NotNull] string injectedLanguage)
		{
			InjectedLanguageName = injectedLanguage;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface, AllowMultiple = true)]
	internal sealed class NoReorderAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
	internal sealed class CodeTemplateAttribute : Attribute
	{
		public string SearchTemplate { get; }

		public string Message { get; set; }

		public string ReplaceTemplate { get; set; }

		public string ReplaceMessage { get; set; }

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


		public bool MatchSimilarConstructs { get; set; }

		public bool ShortenReferences { get; set; }

		public string SuppressionKey { get; set; }

		public CodeTemplateAttribute(string searchTemplate)
		{
			SearchTemplate = searchTemplate;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class IgnoreSpellingAndGrammarErrorsAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
	internal sealed class AspChildControlTypeAttribute : Attribute
	{
		[NotNull]
		public string TagName { get; }

		[NotNull]
		public Type ControlType { get; }

		public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType)
		{
			TagName = tagName;
			ControlType = controlType;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property)]
	internal sealed class AspDataFieldAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property)]
	internal sealed class AspDataFieldsAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property)]
	internal sealed class AspMethodPropertyAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
	internal sealed class AspRequiredAttributeAttribute : Attribute
	{
		[NotNull]
		public string Attribute { get; }

		public AspRequiredAttributeAttribute([NotNull] string attribute)
		{
			Attribute = attribute;
		}
	}
	[AttributeUsage(AttributeTargets.Property)]
	internal sealed class AspTypePropertyAttribute : Attribute
	{
		public bool CreateConstructorReferences { get; }

		public AspTypePropertyAttribute(bool createConstructorReferences)
		{
			CreateConstructorReferences = createConstructorReferences;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
	internal sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute
	{
		[NotNull]
		public string Format { get; }

		public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format)
		{
			Format = format;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
	internal sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute
	{
		[NotNull]
		public string Format { get; }

		public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format)
		{
			Format = format;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
	internal sealed class AspMvcAreaViewComponentViewLocationFormatAttribute : Attribute
	{
		[NotNull]
		public string Format { get; }

		public AspMvcAreaViewComponentViewLocationFormatAttribute([NotNull] string format)
		{
			Format = format;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
	internal sealed class AspMvcAreaViewLocationFormatAttribute : Attribute
	{
		[NotNull]
		public string Format { get; }

		public AspMvcAreaViewLocationFormatAttribute([NotNull] string format)
		{
			Format = format;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
	internal sealed class AspMvcMasterLocationFormatAttribute : Attribute
	{
		[NotNull]
		public string Format { get; }

		public AspMvcMasterLocationFormatAttribute([NotNull] string format)
		{
			Format = format;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
	internal sealed class AspMvcPartialViewLocationFormatAttribute : Attribute
	{
		[NotNull]
		public string Format { get; }

		public AspMvcPartialViewLocationFormatAttribute([NotNull] string format)
		{
			Format = format;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
	internal sealed class AspMvcViewComponentViewLocationFormatAttribute : Attribute
	{
		[NotNull]
		public string Format { get; }

		public AspMvcViewComponentViewLocationFormatAttribute([NotNull] string format)
		{
			Format = format;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
	internal sealed class AspMvcViewLocationFormatAttribute : Attribute
	{
		[NotNull]
		public string Format { get; }

		public AspMvcViewLocationFormatAttribute([NotNull] string format)
		{
			Format = format;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class AspMvcActionAttribute : Attribute
	{
		[CanBeNull]
		public string AnonymousProperty { get; }

		public AspMvcActionAttribute()
		{
		}

		public AspMvcActionAttribute([NotNull] string anonymousProperty)
		{
			AnonymousProperty = anonymousProperty;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class AspMvcAreaAttribute : Attribute
	{
		[CanBeNull]
		public string AnonymousProperty { get; }

		public AspMvcAreaAttribute()
		{
		}

		public AspMvcAreaAttribute([NotNull] string anonymousProperty)
		{
			AnonymousProperty = anonymousProperty;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class AspMvcControllerAttribute : Attribute
	{
		[CanBeNull]
		public string AnonymousProperty { get; }

		public AspMvcControllerAttribute()
		{
		}

		public AspMvcControllerAttribute([NotNull] string anonymousProperty)
		{
			AnonymousProperty = anonymousProperty;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class AspMvcMasterAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class AspMvcModelTypeAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class AspMvcPartialViewAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
	internal sealed class AspMvcSuppressViewErrorAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class AspMvcDisplayTemplateAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class AspMvcEditorTemplateAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class AspMvcTemplateAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class AspMvcViewAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class AspMvcViewComponentAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class AspMvcViewComponentViewAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
	internal sealed class AspMvcActionSelectorAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class RouteTemplateAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class)]
	internal sealed class RouteParameterConstraintAttribute : Attribute
	{
		[NotNull]
		public string ConstraintName { get; }

		[CanBeNull]
		public Type ProposedType { get; set; }

		public RouteParameterConstraintAttribute([NotNull] string constraintName)
		{
			ConstraintName = constraintName;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class UriStringAttribute : Attribute
	{
		[CanBeNull]
		public string HttpVerb { get; }

		public UriStringAttribute()
		{
		}

		public UriStringAttribute(string httpVerb)
		{
			HttpVerb = httpVerb;
		}
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class AspRouteConventionAttribute : Attribute
	{
		[CanBeNull]
		public string PredefinedPattern { get; }

		public AspRouteConventionAttribute()
		{
		}

		public AspRouteConventionAttribute(string predefinedPattern)
		{
			PredefinedPattern = predefinedPattern;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class AspDefaultRouteValuesAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class AspRouteValuesConstraintsAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
	internal sealed class AspRouteOrderAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter)]
	internal sealed class AspRouteVerbsAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class)]
	internal sealed class AspAttributeRoutingAttribute : Attribute
	{
		public string HttpVerb { get; set; }
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class AspMinimalApiDeclarationAttribute : Attribute
	{
		public string HttpVerb { get; set; }
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class AspMinimalApiGroupAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class AspMinimalApiHandlerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
	internal sealed class AspMinimalApiImplicitEndpointDeclarationAttribute : Attribute
	{
		public string HttpVerb { get; set; }

		public string RouteTemplate { get; set; }

		public Type BodyType { get; set; }

		public string QueryParameters { get; set; }
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class HtmlElementAttributesAttribute : Attribute
	{
		[CanBeNull]
		public string Name { get; }

		public HtmlElementAttributesAttribute()
		{
		}

		public HtmlElementAttributesAttribute([NotNull] string name)
		{
			Name = name;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
	internal sealed class HtmlAttributeValueAttribute : Attribute
	{
		[NotNull]
		public string Name { get; }

		public HtmlAttributeValueAttribute([NotNull] string name)
		{
			Name = name;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Parameter)]
	internal sealed class RazorSectionAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class RazorImportNamespaceAttribute : Attribute
	{
		[NotNull]
		public string Name { get; }

		public RazorImportNamespaceAttribute([NotNull] string name)
		{
			Name = name;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class RazorInjectionAttribute : Attribute
	{
		[NotNull]
		public string Type { get; }

		[NotNull]
		public string FieldName { get; }

		public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName)
		{
			Type = type;
			FieldName = fieldName;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class RazorDirectiveAttribute : Attribute
	{
		[NotNull]
		public string Directive { get; }

		public RazorDirectiveAttribute([NotNull] string directive)
		{
			Directive = directive;
		}
	}
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class RazorPageBaseTypeAttribute : Attribute
	{
		[NotNull]
		public string BaseType { get; }

		[CanBeNull]
		public string PageName { get; }

		public RazorPageBaseTypeAttribute([NotNull] string baseType)
		{
			BaseType = baseType;
		}

		public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName)
		{
			BaseType = baseType;
			PageName = pageName;
		}
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class RazorHelperCommonAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property)]
	internal sealed class RazorLayoutAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class RazorWriteLiteralMethodAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Method)]
	internal sealed class RazorWriteMethodAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter)]
	internal sealed class RazorWriteMethodParameterAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class)]
	internal sealed class XamlItemsControlAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property)]
	internal sealed class XamlItemBindingOfItemsControlAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property)]
	internal sealed class XamlItemStyleOfItemsControlAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
	internal sealed class XamlOneWayBindingModeByDefaultAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
	internal sealed class XamlTwoWayBindingModeByDefaultAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Interface, AllowMultiple = true)]
	internal sealed class TestSubjectAttribute : Attribute
	{
		[NotNull]
		public Type Subject { get; }

		public TestSubjectAttribute([NotNull] Type subject)
		{
			Subject = subject;
		}
	}
	[AttributeUsage(AttributeTargets.GenericParameter)]
	internal sealed class MeansTestSubjectAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Interface)]
	internal sealed class CqrsCommandAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Interface)]
	internal sealed class CqrsQueryAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Interface)]
	internal sealed class CqrsCommandHandlerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Interface)]
	internal sealed class CqrsQueryHandlerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Interface)]
	internal sealed class CqrsExcludeFromAnalysisAttribute : Attribute
	{
	}
}
namespace Brigadier.NET
{
	public delegate void AmbiguityConsumer<TSource>(CommandNode<TSource> parent, CommandNode<TSource> child, CommandNode<TSource> sibling, IEnumerable<string> inputs);
	[PublicAPI]
	public class Arguments
	{
		public static IntegerArgumentType Integer(int min = int.MinValue, int max = int.MaxValue)
		{
			return new IntegerArgumentType(min, max);
		}

		public static int GetInteger<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<int>(name);
		}

		public static BoolArgumentType Bool()
		{
			return new BoolArgumentType();
		}

		public static bool GetBool<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<bool>(name);
		}

		public static DoubleArgumentType Double(double min = double.MinValue, double max = double.MaxValue)
		{
			return new DoubleArgumentType(min, max);
		}

		public static double GetDouble<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<double>(name);
		}

		public static EnumArgumentType<TEnum> Enum<TEnum>() where TEnum : struct, Enum
		{
			return new EnumArgumentType<TEnum>();
		}

		public static TEnum GetEnum<TSource, TEnum>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<TEnum>(name);
		}

		public static FloatArgumentType Float(float min = float.MinValue, float max = float.MaxValue)
		{
			return new FloatArgumentType(min, max);
		}

		public static float GetFloat<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<float>(name);
		}

		public static LongArgumentType Long(long min = long.MinValue, long max = long.MaxValue)
		{
			return new LongArgumentType(min, max);
		}

		public static long GetLong<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<long>(name);
		}

		public static StringArgumentType Word()
		{
			return new StringArgumentType(StringArgType.SingleWord);
		}

		public static StringArgumentType String()
		{
			return new StringArgumentType(StringArgType.QuotablePhrase);
		}

		public static StringArgumentType GreedyString()
		{
			return new StringArgumentType(StringArgType.GreedyPhrase);
		}

		public static string GetString<TSource>(CommandContext<TSource> context, string name)
		{
			return context.GetArgument<string>(name);
		}
	}
	public delegate int Command<TSource>(CommandContext<TSource> context);
	[PublicAPI]
	public class CommandDispatcher<TSource>
	{
		public string ArgumentSeparator = " ";

		public char ArgumentSeparatorChar = ' ';

		private const string UsageOptionalOpen = "[";

		private const string UsageOptionalClose = "]";

		private const string UsageRequiredOpen = "(";

		private const string UsageRequiredClose = ")";

		private const string UsageOr = "|";

		private readonly RootCommandNode<TSource> _root;

		private readonly Predicate<CommandNode<TSource>> _hasCommand;

		public ResultConsumer<TSource> Consumer { get; set; } = delegate
		{
		};


		public RootCommandNode<TSource> Root => _root;

		public CommandDispatcher(RootCommandNode<TSource> root)
		{
			_root = root;
			_hasCommand = (CommandNode<TSource> input) => input != null && (input.Command != null || input.Children.Any((CommandNode<TSource> c) => _hasCommand?.Invoke(c) ?? false));
		}

		public CommandDispatcher()
			: this(new RootCommandNode<TSource>())
		{
		}

		public LiteralCommandNode<TSource> Register(LiteralArgumentBuilder<TSource> command)
		{
			LiteralCommandNode<TSource> literalCommandNode = command.Build();
			_root.AddChild(literalCommandNode);
			return literalCommandNode;
		}

		public LiteralCommandNode<TSource> Register(Func<IArgumentContext<TSource>, LiteralArgumentBuilder<TSource>> command)
		{
			LiteralCommandNode<TSource> literalCommandNode = command(default(ArgumentContext<TSource>)).Build();
			_root.AddChild(literalCommandNode);
			return literalCommandNode;
		}

		public int Execute(string input, TSource source)
		{
			return Execute(new StringReader(input), source);
		}

		public int Execute(StringReader input, TSource source)
		{
			ParseResults<TSource> parse = Parse(input, source);
			return Execute(parse);
		}

		public int Execute(ParseResults<TSource> parse)
		{
			if (parse.Reader.CanRead())
			{
				if (parse.Exceptions.Count == 1)
				{
					throw parse.Exceptions.Values.Single();
				}
				if (parse.Context.Range.IsEmpty)
				{
					throw CommandSyntaxException.BuiltInExceptions.DispatcherUnknownCommand().CreateWithContext(parse.Reader);
				}
				throw CommandSyntaxException.BuiltInExceptions.DispatcherUnknownArgument().CreateWithContext(parse.Reader);
			}
			string @string = parse.Reader.String;
			CommandContext<TSource> commandContext = parse.Context.Build(@string);
			if (!commandContext.TryFlatten(out ContextChain<TSource> chain))
			{
				Consumer(commandContext, success: false, 0);
				throw CommandSyntaxException.BuiltInExceptions.DispatcherUnknownCommand().CreateWithContext(parse.Reader);
			}
			return chain.ExecuteAll(commandContext.Source, Consumer);
		}

		public ParseResults<TSource> Parse(string command, TSource source)
		{
			return Parse(new StringReader(command), source);
		}

		public ParseResults<TSource> Parse(StringReader command, TSource source)
		{
			CommandContextBuilder<TSource> contextSoFar = new CommandContextBuilder<TSource>(this, source, _root, command.Cursor);
			return ParseNodes(_root, command, contextSoFar);
		}

		private ParseResults<TSource> ParseNodes(CommandNode<TSource> node, StringReader originalReader, CommandContextBuilder<TSource> contextSoFar)
		{
			TSource source = contextSoFar.Source;
			IDictionary<CommandNode<TSource>, CommandSyntaxException> dictionary = null;
			List<ParseResults<TSource>> list = null;
			int cursor = originalReader.Cursor;
			foreach (CommandNode<TSource> relevantNode in node.GetRelevantNodes(originalReader))
			{
				if (!relevantNode.CanUse(source))
				{
					continue;
				}
				CommandContextBuilder<TSource> commandContextBuilder = contextSoFar.Copy();
				StringReader stringReader = new StringReader(originalReader);
				try
				{
					try
					{
						relevantNode.Parse(stringReader, commandContextBuilder);
					}
					catch (CommandSyntaxException)
					{
						throw;
					}
					catch (Exception ex2)
					{
						throw CommandSyntaxException.BuiltInExceptions.DispatcherParseException().CreateWithContext(stringReader, ex2.Message);
					}
					if (stringReader.CanRead() && stringReader.Peek() != ArgumentSeparatorChar)
					{
						throw CommandSyntaxException.BuiltInExceptions.DispatcherExpectedArgumentSeparator().CreateWithContext(stringReader);
					}
				}
				catch (CommandSyntaxException value)
				{
					if (dictionary == null)
					{
						dictionary = new Dictionary<CommandNode<TSource>, CommandSyntaxException>();
					}
					dictionary.Add(relevantNode, value);
					stringReader.Cursor = cursor;
					continue;
				}
				commandContextBuilder.WithCommand(relevantNode.Command);
				if (stringReader.CanRead((relevantNode.Redirect != null) ? 1 : 2))
				{
					stringReader.Skip();
					if (relevantNode.Redirect != null)
					{
						CommandContextBuilder<TSource> contextSoFar2 = new CommandContextBuilder<TSource>(this, source, relevantNode.Redirect, stringReader.Cursor);
						ParseResults<TSource> parseResults = ParseNodes(relevantNode.Redirect, stringReader, contextSoFar2);
						commandContextBuilder.WithChild(parseResults.Context);
						return new ParseResults<TSource>(commandContextBuilder, parseResults.Reader, parseResults.Exceptions);
					}
					ParseResults<TSource> item = ParseNodes(relevantNode, stringReader, commandContextBuilder);
					if (list == null)
					{
						list = new List<ParseResults<TSource>>(1);
					}
					list.Add(item);
				}
				else
				{
					if (list == null)
					{
						list = new List<ParseResults<TSource>>(1);
					}
					list.Add(new ParseResults<TSource>(commandContextBuilder, stringReader, new Dictionary<CommandNode<TSource>, CommandSyntaxException>()));
				}
			}
			if (list != null)
			{
				if (list.Count > 1)
				{
					list.Sort(delegate(ParseResults<TSource> a, ParseResults<TSource> b)
					{
						if (!a.Reader.CanRead() && b.Reader.CanRead())
						{
							return -1;
						}
						if (a.Reader.CanRead() && !b.Reader.CanRead())
						{
							return 1;
						}
						if (a.Exceptions.Count == 0 && b.Exceptions.Count > 0)
						{
							return -1;
						}
						return (a.Exceptions.Count > 0 && b.Exceptions.Count == 0) ? 1 : 0;
					});
				}
				return list[0];
			}
			return new ParseResults<TSource>(contextSoFar, originalReader, dictionary ?? new Dictionary<CommandNode<TSource>, CommandSyntaxException>());
		}

		public string[] GetAllUsage(CommandNode<TSource> node, TSource source, bool restricted)
		{
			List<string> list = new List<string>();
			GetAllUsage(node, source, list, "", restricted);
			return list.ToArray();
		}

		private void GetAllUsage(CommandNode<TSource> node, TSource source, List<string> result, string prefix, bool restricted)
		{
			if (restricted && !node.CanUse(source))
			{
				return;
			}
			if (node.Command != null)
			{
				result.Add(prefix);
			}
			if (node.Redirect != null)
			{
				string text = ((node.Redirect == _root) ? "..." : ("-> " + node.Redirect.UsageText));
				result.Add((prefix.Length == 0) ? (node.UsageText + ArgumentSeparator + text) : (prefix + ArgumentSeparator + text));
			}
			else
			{
				if (node.Children.Count <= 0)
				{
					return;
				}
				foreach (CommandNode<TSource> child in node.Children)
				{
					GetAllUsage(child, source, result, (prefix.Length == 0) ? child.UsageText : (prefix + ArgumentSeparator + child.UsageText), restricted);
				}
			}
		}

		public IDictionary<CommandNode<TSource>, string> GetSmartUsage(CommandNode<TSource> node, TSource source)
		{
			IDictionary<CommandNode<TSource>, string> dictionary = new Dictionary<CommandNode<TSource>, string>();
			bool optional = node.Command != null;
			foreach (CommandNode<TSource> child in node.Children)
			{
				string smartUsage = GetSmartUsage(child, source, optional, deep: false);
				if (smartUsage != null)
				{
					dictionary.Add(child, smartUsage);
				}
			}
			return dictionary;
		}

		private string? GetSmartUsage(CommandNode<TSource> node, TSource source, bool optional, bool deep)
		{
			TSource source2 = source;
			if (!node.CanUse(source2))
			{
				return null;
			}
			string text = (optional ? ("[" + node.UsageText + "]") : node.UsageText);
			bool flag = node.Command != null;
			string value = (flag ? "[" : "(");
			string value2 = (flag ? "]" : ")");
			if (!deep)
			{
				if (node.Redirect != null)
				{
					string text2 = ((node.Redirect == _root) ? "..." : ("-> " + node.Redirect.UsageText));
					return text + ArgumentSeparator + text2;
				}
				List<CommandNode<TSource>> list = node.Children.Where((CommandNode<TSource> c) => c.CanUse(source2)).ToList();
				if (list.Count == 1)
				{
					string smartUsage = GetSmartUsage(list.Single(), source2, flag, flag);
					if (smartUsage != null)
					{
						return text + ArgumentSeparator + smartUsage;
					}
				}
				else if (list.Count > 1)
				{
					ISet<string> set = new HashSet<string>();
					foreach (CommandNode<TSource> item in list)
					{
						string smartUsage2 = GetSmartUsage(item, source2, flag, deep: true);
						if (smartUsage2 != null)
						{
							set.Add(smartUsage2);
						}
					}
					if (set.Count == 1)
					{
						string text3 = set.Single();
						return text + ArgumentSeparator + (flag ? ("[" + text3 + "]") : text3);
					}
					if (set.Count > 1)
					{
						StringBuilder stringBuilder = new StringBuilder(value);
						int num = 0;
						foreach (CommandNode<TSource> item2 in list)
						{
							if (num > 0)
							{
								stringBuilder.Append("|");
							}
							stringBuilder.Append(item2.UsageText);
							num++;
						}
						if (num > 0)
						{
							stringBuilder.Append(value2);
							return text + ArgumentSeparator + stringBuilder;
						}
					}
				}
			}
			return text;
		}

		public Task<Suggestions> GetCompletionSuggestions(ParseResults<TSource> parse)
		{
			return GetCompletionSuggestions(parse, parse.Reader.TotalLength);
		}

		public async Task<Suggestions> GetCompletionSuggestions(ParseResults<TSource> parse, int cursor)
		{
			CommandContextBuilder<TSource> context = parse.Context;
			SuggestionContext<TSource> suggestionContext = context.FindSuggestionContext(cursor);
			CommandNode<TSource> parent = suggestionContext.Parent;
			int start = Math.Min(suggestionContext.StartPos, cursor);
			string fullInput = parse.Reader.String;
			string text = fullInput.Substring(0, cursor);
			string inputLowerCase = text.ToLowerInvariant();
			Task<Suggestions>[] futures = new Task<Suggestions>[parent.Children.Count()];
			int num = 0;
			foreach (CommandNode<TSource> child in parent.Children)
			{
				Task<Suggestions> task = Suggestions.Empty();
				try
				{
					task = child.ListSuggestions(context.Build(text), new SuggestionsBuilder(text, inputLowerCase, start));
				}
				catch (CommandSyntaxException)
				{
				}
				futures[num++] = task;
			}
			await Task.WhenAll(futures);
			return Suggestions.Merge(fullInput, futures.Select((Task<Suggestions> s) => s.Result).ToArray());
		}

		public List<string> GetPath(CommandNode<TSource> target)
		{
			List<List<CommandNode<TSource>>> list = new List<List<CommandNode<TSource>>>();
			AddPaths(_root, list, new List<CommandNode<TSource>>());
			foreach (List<CommandNode<TSource>> item in list)
			{
				if (item[item.Count - 1] != target)
				{
					continue;
				}
				List<string> list2 = new List<string>(item.Count);
				foreach (CommandNode<TSource> item2 in item)
				{
					if (item2 != _root)
					{
						list2.Add(item2.Name);
					}
				}
				return list2;
			}
			return new List<string>();
		}

		public CommandNode<TSource>? FindNode(IEnumerable<string> path)
		{
			CommandNode<TSource> commandNode = _root;
			foreach (string item in path)
			{
				commandNode = commandNode.GetChild(item);
				if (commandNode == null)
				{
					return null;
				}
			}
			return commandNode;
		}

		public void FindAmbiguities(AmbiguityConsumer<TSource> consumer)
		{
			_root.FindAmbiguities(consumer);
		}

		private void AddPaths(CommandNode<TSource> node, List<List<CommandNode<TSource>>> result, List<CommandNode<TSource>> parents)
		{
			List<CommandNode<TSource>> list = new List<CommandNode<TSource>>(parents) { node };
			result.Add(list);
			foreach (CommandNode<TSource> child in node.Children)
			{
				AddPaths(child, result, list);
			}
		}
	}
	[PublicAPI]
	public interface IImmutableStringReader
	{
		string String { get; }

		int RemainingLength { get; }

		int TotalLength { get; }

		int Cursor { get; }

		string Read { get; }

		string Remaining { get; }

		bool CanRead(int length);

		bool CanRead();

		char Peek();

		char Peek(int offset);
	}
	[PublicAPI]
	public interface IStringReader : IImmutableStringReader
	{
		new int Cursor { get; set; }

		char Next();

		void Skip();

		void SkipWhitespace();

		int ReadInt();

		long ReadLong();

		double ReadDouble();

		float ReadFloat();

		string ReadUnquotedString();

		string ReadQuotedString();

		string ReadString();

		bool ReadBoolean();

		void Expect(char c);
	}
	[PublicAPI]
	public class LiteralMessage : IMessage
	{
		public string String { get; }

		public LiteralMessage(string message)
		{
			String = message;
		}

		public override string ToString()
		{
			return String;
		}
	}
	[PublicAPI]
	public interface IMessage
	{
		string String { get; }
	}
	[PublicAPI]
	public class ParseResults<TSource>
	{
		public CommandContextBuilder<TSource> Context { get; }

		public IImmutableStringReader Reader { get; }

		public IDictionary<CommandNode<TSource>, CommandSyntaxException> Exceptions { get; }

		public ParseResults(CommandContextBuilder<TSource> context, IImmutableStringReader reader, IDictionary<CommandNode<TSource>, CommandSyntaxException> exceptions)
		{
			Context = context;
			Reader = reader;
			Exceptions = exceptions;
		}

		public ParseResults(CommandContextBuilder<TSource> context)
			: this(context, (IImmutableStringReader)new StringReader(""), (IDictionary<CommandNode<TSource>, CommandSyntaxException>)new Dictionary<CommandNode<TSource>, CommandSyntaxException>())
		{
		}
	}
	public delegate IList<TSource> RedirectModifier<TSource>(CommandContext<TSource> context);
	public delegate void ResultConsumer<TSource>(CommandContext<TSource> context, bool success, int result);
	public delegate TSource SingleRedirectModifier<TSource>(CommandContext<TSource> context);
	[PublicAPI]
	public class StringReader : IStringReader, IImmutableStringReader
	{
		private static readonly char SyntaxEscape = '\\';

		private static readonly char SyntaxDoubleQuote = '"';

		private static readonly char SyntaxSingleQuote = '\'';

		public string String { get; }

		public int Cursor { get; set; }

		public int RemainingLength => String.Length - Cursor;

		public int TotalLength => String.Length;

		public string Read => String.Substring(0, Cursor);

		public string Remaining => String.Substring(Cursor);

		public StringReader(StringReader other)
		{
			String = other.String;
			Cursor = other.Cursor;
		}

		public StringReader(string input)
		{
			String = input;
		}

		public bool CanRead(int length)
		{
			return Cursor + length <= String.Length;
		}

		public bool CanRead()
		{
			return CanRead(1);
		}

		public char Peek()
		{
			return String[Cursor];
		}

		public char Peek(int offset)
		{
			return String[Cursor + offset];
		}

		public char Next()
		{
			return String[Cursor++];
		}

		public void Skip()
		{
			Cursor++;
		}

		private static bool IsAllowedNumber(char c)
		{
			if ((c < '0' || c > '9') && c != '.')
			{
				return c == '-';
			}
			return true;
		}

		private static bool IsQuotedStringStart(char c)
		{
			if (c != SyntaxDoubleQuote)
			{
				return c == SyntaxSingleQuote;
			}
			return true;
		}

		public void SkipWhitespace()
		{
			while (CanRead() && char.IsWhiteSpace(Peek()))
			{
				Skip();
			}
		}

		public int ReadInt()
		{
			int cursor = Cursor;
			while (CanRead() && IsAllowedNumber(Peek()))
			{
				Skip();
			}
			ReadOnlySpan<char> s = String.AsSpan(cursor, Cursor - cursor);
			if (s.Length == 0)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedInt().CreateWithContext(this);
			}
			try
			{
				return int.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
			}
			catch (FormatException)
			{
				Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidInt().CreateWithContext(this, s.ToString());
			}
		}

		public long ReadLong()
		{
			int cursor = Cursor;
			while (CanRead() && IsAllowedNumber(Peek()))
			{
				Skip();
			}
			ReadOnlySpan<char> s = String.AsSpan(cursor, Cursor - cursor);
			if (s.Length == 0)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedLong().CreateWithContext(this);
			}
			try
			{
				return long.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture);
			}
			catch (FormatException)
			{
				Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidLong().CreateWithContext(this, s.ToString());
			}
		}

		public double ReadDouble()
		{
			int cursor = Cursor;
			while (CanRead() && IsAllowedNumber(Peek()))
			{
				Skip();
			}
			ReadOnlySpan<char> s = String.AsSpan(cursor, Cursor - cursor);
			if (s.Length == 0)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedDouble().CreateWithContext(this);
			}
			try
			{
				return double.Parse(s, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture);
			}
			catch (FormatException)
			{
				Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidDouble().CreateWithContext(this, s.ToString());
			}
		}

		public float ReadFloat()
		{
			int cursor = Cursor;
			while (CanRead() && IsAllowedNumber(Peek()))
			{
				Skip();
			}
			ReadOnlySpan<char> s = String.AsSpan(cursor, Cursor - cursor);
			if (s.Length == 0)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedFloat().CreateWithContext(this);
			}
			try
			{
				return float.Parse(s, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture);
			}
			catch (FormatException)
			{
				Cursor = cursor;
				throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidFloat().CreateWithContext(this, s.ToString());
			}
		}

		public static bool IsAllowedInUnquotedString(char c)
		{
			if ((c < '0' || c > '9') && (c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && c != '_' && c != '-' && c != '.')
			{
				return c == '+';
			}
			return true;
		}

		public string ReadUnquotedString()
		{
			int cursor = Cursor;
			while (CanRead() && IsAllowedInUnquotedString(Peek()))
			{
				Skip();
			}
			return String.AsSpan(cursor, Cursor - cursor).ToString();
		}

		public string ReadQuotedString()
		{
			if (!CanRead())
			{
				return "";
			}
			char c = Peek();
			if (!IsQuotedStringStart(c))
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedStartOfQuote().CreateWithContext(this);
			}
			Skip();
			return ReadStringUntil(c);
		}

		private string ReadStringUntil(char terminator)
		{
			StringBuilder stringBuilder = new StringBuilder();
			bool flag = false;
			while (CanRead())
			{
				char c = Next();
				if (flag)
				{
					if (c != terminator && c != SyntaxEscape)
					{
						Cursor--;
						throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidEscape().CreateWithContext(this, c.ToString());
					}
					stringBuilder.Append(c);
					flag = false;
				}
				else if (c == SyntaxEscape)
				{
					flag = true;
				}
				else
				{
					if (c == terminator)
					{
						return stringBuilder.ToString();
					}
					stringBuilder.Append(c);
				}
			}
			throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedEndOfQuote().CreateWithContext(this);
		}

		public string ReadString()
		{
			if (!CanRead())
			{
				return "";
			}
			char c = Peek();
			if (IsQuotedStringStart(c))
			{
				Skip();
				return ReadStringUntil(c);
			}
			return ReadUnquotedString();
		}

		public bool ReadBoolean()
		{
			int cursor = Cursor;
			string text = ReadString();
			if (text.Length == 0)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedBool().CreateWithContext(this);
			}
			if (text.Equals("true"))
			{
				return true;
			}
			if (text.Equals("false"))
			{
				return false;
			}
			Cursor = cursor;
			throw CommandSyntaxException.BuiltInExceptions.ReaderInvalidBool().CreateWithContext(this, text);
		}

		public void Expect(char c)
		{
			if (!CanRead() || Peek() != c)
			{
				throw CommandSyntaxException.BuiltInExceptions.ReaderExpectedSymbol().CreateWithContext(this, c.ToString());
			}
			Skip();
		}
	}
}
namespace Brigadier.NET.Tree
{
	[PublicAPI]
	public abstract class ArgumentCommandNode<TSource> : CommandNode<TSource>
	{
		protected ArgumentCommandNode(Command<TSource>? command, Predicate<TSource> requirement, CommandNode<TSource>? redirect, RedirectModifier<TSource>? modifier, bool forks)
			: base(command, requirement, redirect, modifier, forks)
		{
		}
	}
	[PublicAPI]
	public class ArgumentCommandNode<TSource, T> : ArgumentCommandNode<TSource>, IEquatable<ArgumentCommandNode<TSource, T>> where T : notnull
	{
		private const string UsageArgumentOpen = "<";

		private const string UsageArgumentClose = ">";

		private readonly string _name;

		public IArgumentType<T> Type { get; }

		public override string Name => _name;

		public override string UsageText => "<" + Name + ">";

		public SuggestionProvider<TSource>? CustomSuggestions { get; }

		protected override string SortedKey => _name;

		public override IEnumerable<string> Examples => Type.Examples;

		public ArgumentCommandNode(string name, IArgumentType<T> type, Command<TSource>? command, Predicate<TSource> requirement, CommandNode<TSource>? redirect, RedirectModifier<TSource>? modifier, bool forks, SuggestionProvider<TSource>? customSuggestions)
			: base(command, requirement, redirect, modifier, forks)
		{
			_name = name;
			Type = type;
			CustomSuggestions = customSuggestions;
		}

		public override void Parse(StringReader reader, CommandContextBuilder<TSource> contextBuilder)
		{
			int cursor = reader.Cursor;
			T result = Type.Parse(reader, contextBuilder.Source);
			ParsedArgument<TSource, T> parsedArgument = new ParsedArgument<TSource, T>(cursor, reader.Cursor, result);
			contextBuilder.WithArgument(_name, parsedArgument);
			contextBuilder.WithNode(this, parsedArgument.Range);
		}

		public override Task<Suggestions> ListSuggestions(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			if (CustomSuggestions == null)
			{
				return Type.ListSuggestions(context, builder);
			}
			return CustomSuggestions(context, builder);
		}

		public override IArgumentBuilder<TSource, CommandNode<TSource>> CreateBuilder()
		{
			RequiredArgumentBuilder<TSource, T> requiredArgumentBuilder = RequiredArgumentBuilder<TSource, T>.RequiredArgument(_name, Type);
			requiredArgumentBuilder.Requires(base.Requirement);
			requiredArgumentBuilder.Forward(base.Redirect, base.RedirectModifier, base.IsFork);
			requiredArgumentBuilder.Suggests(CustomSuggestions);
			if (base.Command != null)
			{
				requiredArgumentBuilder.Executes(base.Command);
			}
			return requiredArgumentBuilder;
		}

		protected override bool IsValidInput(string input)
		{
			try
			{
				StringReader stringReader = new StringReader(input);
				Type.Parse(stringReader);
				return !stringReader.CanRead() || stringReader.Peek() == ' ';
			}
			catch (CommandSyntaxException)
			{
				return false;
			}
		}

		public override bool Equals(object? obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is ArgumentCommandNode<TSource, T> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(ArgumentCommandNode<TSource, T>? other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			if (string.Equals(_name, other._name))
			{
				return object.Equals(Type, other.Type);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(_name, Type);
		}

		public override string ToString()
		{
			return $"<argument {_name}:{Type}>";
		}
	}
	[PublicAPI]
	public abstract class CommandNode<TSource> : IComparable<CommandNode<TSource>>, IEnumerable<CommandNode<TSource>>, IEnumerable
	{
		[CompilerGenerated]
		private sealed class <GetRelevantNodes>d__35 : IEnumerable<CommandNode<TSource>>, IEnumerable, IEnumerator<CommandNode<TSource>>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private CommandNode<TSource> <>2__current;

			private int <>l__initialThreadId;

			public CommandNode<TSource> <>4__this;

			private StringReader input;

			public StringReader <>3__input;

			private IEnumerator<ArgumentCommandNode<TSource>> <>7__wrap1;

			CommandNode<TSource> IEnumerator<CommandNode<TSource>>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GetRelevantNodes>d__35(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				switch (<>1__state)
				{
				case -3:
				case 2:
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
					break;
				case -4:
				case 3:
					try
					{
					}
					finally
					{
						<>m__Finally2();
					}
					break;
				}
				<>7__wrap1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				try
				{
					int num = <>1__state;
					CommandNode<TSource> commandNode = <>4__this;
					switch (num)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						if (commandNode._literals.Count > 0)
						{
							int cursor = input.Cursor;
							while (input.CanRead() && input.Peek() != ' ')
							{
								input.Skip();
							}
							string key = input.String.Substring(cursor, input.Cursor - cursor);
							input.Cursor = cursor;
							if (commandNode._literals.TryGetValue(key, out LiteralCommandNode<TSource> value))
							{
								<>2__current = value;
								<>1__state = 1;
								return true;
							}
							<>7__wrap1 = commandNode._arguments.Values.GetEnumerator();
							<>1__state = -3;
							goto IL_0122;
						}
						<>7__wrap1 = commandNode._arguments.Values.GetEnumerator();
						<>1__state = -4;
						goto IL_0186;
					case 1:
						<>1__state = -1;
						break;
					case 2:
						<>1__state = -3;
						goto IL_0122;
					case 3:
						{
							<>1__state = -4;
							goto IL_0186;
						}
						IL_0122:
						if (<>7__wrap1.MoveNext())
						{
							ArgumentCommandNode<TSource> current = <>7__wrap1.Current;
							<>2__current = current;
							<>1__state = 2;
							return true;
						}
						<>m__Finally1();
						<>7__wrap1 = null;
						break;
						IL_0186:
						if (<>7__wrap1.MoveNext())
						{
							ArgumentCommandNode<TSource> current2 = <>7__wrap1.Current;
							<>2__current = current2;
							<>1__state = 3;
							return true;
						}
						<>m__Finally2();
						<>7__wrap1 = null;
						break;
					}
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<>7__wrap1 != null)
				{
					<>7__wrap1.Dispose();
				}
			}

			private void <>m__Finally2()
			{
				<>1__state = -1;
				if (<>7__wrap1 != null)
				{
					<>7__wrap1.Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<CommandNode<TSource>> IEnumerable<CommandNode<TSource>>.GetEnumerator()
			{
				<GetRelevantNodes>d__35 <GetRelevantNodes>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<GetRelevantNodes>d__ = this;
				}
				else
				{
					<GetRelevantNodes>d__ = new <GetRelevantNodes>d__35(0)
					{
						<>4__this = <>4__this
					};
				}
				<GetRelevantNodes>d__.input = <>3__input;
				return <GetRelevantNodes>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<CommandNode<TSource>>)this).GetEnumerator();
			}
		}

		private readonly IDictionary<string, CommandNode<TSource>> _children = new Dictionary<string, CommandNode<TSource>>();

		private readonly IDictionary<string, LiteralCommandNode<TSource>> _literals = new Dictionary<string, LiteralCommandNode<TSource>>();

		private readonly IDictionary<string, ArgumentCommandNode<TSource>> _arguments = new Dictionary<string, ArgumentCommandNode<TSource>>();

		public Command<TSource>? Command { get; set; }

		public ICollection<CommandNode<TSource>> Children => _children.Values;

		public CommandNode<TSource>? Redirect { get; }

		public RedirectModifier<TSource>? RedirectModifier { get; }

		public Predicate<TSource> Requirement { get; }

		public abstract string Name { get; }

		public abstract string UsageText { get; }

		protected abstract string SortedKey { get; }

		public bool IsFork { get; }

		public abstract IEnumerable<string> Examples { get; }

		protected CommandNode(Command<TSource>? command, Predicate<TSource> requirement, CommandNode<TSource>? redirect, RedirectModifier<TSource>? modifier, bool forks)
		{
			Command = command;
			Requirement = requirement;
			Redirect = redirect;
			RedirectModifier = modifier;
			IsFork = forks;
		}

		public CommandNode<TSource>? GetChild(string name)
		{
			if (!_children.TryGetValue(name, out CommandNode<TSource> value))
			{
				return null;
			}
			return value;
		}

		public bool CanUse(TSource source)
		{
			return Requirement(source);
		}

		public void Add(CommandNode<TSource> node)
		{
			AddChild(node);
		}

		public void Add(params CommandNode<TSource>[] nodes)
		{
			foreach (CommandNode<TSource> node in nodes)
			{
				AddChild(node);
			}
		}

		public void AddChild(CommandNode<TSource> node)
		{
			if (node is RootCommandNode<TSource>)
			{
				throw new InvalidOperationException("Cannot add a RootCommandNode as a child to any other CommandNode");
			}
			if (_children.TryGetValue(node.Name, out CommandNode<TSource> value))
			{
				if (node.Command != null)
				{
					value.Command = node.Command;
				}
				{
					foreach (CommandNode<TSource> child in node.Children)
					{
						value.AddChild(child);
					}
					return;
				}
			}
			_children.Add(node.Name, node);
			if (node is LiteralCommandNode<TSource> value2)
			{
				_literals.Add(node.Name, value2);
			}
			else if (node is ArgumentCommandNode<TSource> value3)
			{
				_arguments.Add(node.Name, value3);
			}
		}

		public void FindAmbiguities(AmbiguityConsumer<TSource> consumer)
		{
			HashSet<string> hashSet = new HashSet<string>();
			foreach (CommandNode<TSource> value in _children.Values)
			{
				foreach (CommandNode<TSource> value2 in _children.Values)
				{
					if (value == value2)
					{
						continue;
					}
					foreach (string example in value.Examples)
					{
						if (value2.IsValidInput(example))
						{
							hashSet.Add(example);
						}
					}
					if (hashSet.Count > 0)
					{
						consumer(this, value, value2, hashSet);
						hashSet = new HashSet<string>();
					}
				}
				value.FindAmbiguities(consumer);
			}
		}

		protected abstract bool IsValidInput(string input);

		public abstract void Parse(StringReader reader, CommandContextBuilder<TSource> contextBuilder);

		public abstract Task<Suggestions> ListSuggestions(CommandContext<TSource> context, SuggestionsBuilder builder);

		public abstract IArgumentBuilder<TSource, CommandNode<TSource>> CreateBuilder();

		[IteratorStateMachine(typeof(CommandNode<>.<GetRelevantNodes>d__35))]
		public IEnumerable<CommandNode<TSource>> GetRelevantNodes(StringReader input)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GetRelevantNodes>d__35(-2)
			{
				<>4__this = this,
				<>3__input = input
			};
		}

		public int CompareTo(CommandNode<TSource>? o)
		{
			if (this is LiteralCommandNode<TSource> == o is LiteralCommandNode<TSource>)
			{
				return string.Compare(SortedKey, o?.SortedKey, StringComparison.Ordinal);
			}
			if (!(o is LiteralCommandNode<TSource>))
			{
				return -1;
			}
			return 1;
		}

		public IEnumerator<CommandNode<TSource>> GetEnumerator()
		{
			return _children.Values.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}
	}
	[PublicAPI]
	public class LiteralCommandNode<TSource> : CommandNode<TSource>, IEquatable<LiteralCommandNode<TSource>>
	{
		public string Literal { get; }

		public string LiteralLowerCase { get; }

		public override string Name => Literal;

		public override string UsageText => Literal;

		protected override string SortedKey => Literal;

		public override IEnumerable<string> Examples => new <>z__ReadOnlySingleElementList<string>(Literal);

		public LiteralCommandNode(string literal, Command<TSource>? command, Predicate<TSource> requirement, CommandNode<TSource>? redirect, RedirectModifier<TSource>? modifier, bool forks)
			: base(command, requirement, redirect, modifier, forks)
		{
			Literal = literal;
			LiteralLowerCase = literal.ToLowerInvariant();
		}

		public override void Parse(StringReader reader, CommandContextBuilder<TSource> contextBuilder)
		{
			int cursor = reader.Cursor;
			int num = Parse(reader);
			if (num > -1)
			{
				contextBuilder.WithNode(this, StringRange.Between(cursor, num));
				return;
			}
			throw CommandSyntaxException.BuiltInExceptions.LiteralIncorrect().CreateWithContext(reader, Literal);
		}

		private int Parse(StringReader reader)
		{
			int cursor = reader.Cursor;
			if (reader.CanRead(Literal.Length))
			{
				int num = cursor + Literal.Length;
				if (reader.String.Substring(cursor, num - cursor).Equals(Literal))
				{
					reader.Cursor = num;
					if (!reader.CanRead() || reader.Peek() == ' ')
					{
						return num;
					}
					reader.Cursor = cursor;
				}
			}
			return -1;
		}

		public override Task<Suggestions> ListSuggestions(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			if (Literal.ToLower().StartsWith(builder.RemainingLowerCase))
			{
				return builder.Suggest(Literal).BuildAsync();
			}
			return Suggestions.Empty();
		}

		protected override bool IsValidInput(string input)
		{
			return Parse(new StringReader(input)) > -1;
		}

		public override bool Equals(object? obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is LiteralCommandNode<TSource> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(LiteralCommandNode<TSource>? other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			return string.Equals(Literal, other.Literal);
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(Literal);
		}

		public override IArgumentBuilder<TSource, CommandNode<TSource>> CreateBuilder()
		{
			LiteralArgumentBuilder<TSource> literalArgumentBuilder = LiteralArgumentBuilder<TSource>.LiteralArgument(Literal);
			literalArgumentBuilder.Requires(base.Requirement);
			literalArgumentBuilder.Forward(base.Redirect, base.RedirectModifier, base.IsFork);
			if (base.Command != null)
			{
				literalArgumentBuilder.Executes(base.Command);
			}
			return literalArgumentBuilder;
		}
	}
	[PublicAPI]
	public class RootCommandNode<TSource> : CommandNode<TSource>, IEquatable<RootCommandNode<TSource>>
	{
		public override string Name => string.Empty;

		public override string UsageText => string.Empty;

		protected override string SortedKey => string.Empty;

		public override IEnumerable<string> Examples => new string[0];

		public RootCommandNode()
			: base((Command<TSource>?)null, (Predicate<TSource>)((TSource c) => true), (CommandNode<TSource>?)null, (RedirectModifier<TSource>?)((CommandContext<TSource> s) => new List<TSource>(1) { s.Source }), forks: false)
		{
		}

		public override void Parse(StringReader reader, CommandContextBuilder<TSource> contextBuilder)
		{
		}

		public override Task<Suggestions> ListSuggestions(CommandContext<TSource> context, SuggestionsBuilder builder)
		{
			return Suggestions.Empty();
		}

		protected override bool IsValidInput(string input)
		{
			return false;
		}

		public override bool Equals(object? obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is RootCommandNode<TSource> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(RootCommandNode<TSource>? other)
		{
			return true;
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(GetType());
		}

		public override IArgumentBuilder<TSource, CommandNode<TSource>> CreateBuilder()
		{
			throw new InvalidOperationException("Cannot convert root into a builder");
		}

		public override string ToString()
		{
			return "<root>";
		}
	}
}
namespace Brigadier.NET.Suggestion
{
	[PublicAPI]
	public class IntegerSuggestion : Suggestion, IEquatable<IntegerSuggestion>
	{
		public int Value { get; }

		public IntegerSuggestion(StringRange range, int value, IMessage? tooltip = null)
			: base(range, value.ToString(), tooltip)
		{
			Value = value;
		}

		public override bool Equals(object? obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is IntegerSuggestion other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(IntegerSuggestion? other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			if (Value == other?.Value)
			{
				return Equals((Suggestion?)other);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(GetType(), Value);
		}

		public override string ToString()
		{
			return $"IntegerSuggestion{{value={Value}, range={base.Range}, text='{base.Text}', tooltip='{base.Tooltip}'}}";
		}

		public override int CompareTo(Suggestion? o)
		{
			if (o is IntegerSuggestion integerSuggestion)
			{
				return integerSuggestion.Value.CompareTo(Value);
			}
			return base.CompareTo(o);
		}

		public override int CompareToIgnoreCase(Suggestion b)
		{
			return CompareTo(b);
		}
	}
	[PublicAPI]
	public class Suggestion : IComparable<Suggestion>, IEquatable<Suggestion>
	{
		public StringRange Range { get; }

		public string Text { get; }

		public IMessage? Tooltip { get; }

		public Suggestion(StringRange range, string text, IMessage? tooltip = null)
		{
			Range = range;
			Text = text;
			Tooltip = tooltip;
		}

		public string Apply(string input)
		{
			if (Range.Start == 0 && Range.End == input.Length)
			{
				return Text;
			}
			StringBuilder stringBuilder = new StringBuilder();
			if (Range.Start > 0)
			{
				stringBuilder.Append(input.Substring(0, Range.Start));
			}
			stringBuilder.Append(Text);
			if (Range.End < input.Length)
			{
				stringBuilder.Append(input.Substring(Range.End));
			}
			return stringBuilder.ToString();
		}

		public override bool Equals(object? obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is Suggestion other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(Suggestion? other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			if (object.Equals(Range, other.Range) && string.Equals(Text, other.Text))
			{
				return object.Equals(Tooltip, other.Tooltip);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(Range, Text, Tooltip);
		}

		public override string ToString()
		{
			return $"Suggestion{{range={Range}, text='{Text}', tooltip='{Tooltip}}}";
		}

		public virtual int CompareTo(Suggestion? o)
		{
			return string.Compare(Text, o?.Text, StringComparison.Ordinal);
		}

		public virtual int CompareToIgnoreCase(Suggestion b)
		{
			return string.Compare(Text, b.Text, StringComparison.OrdinalIgnoreCase);
		}

		public Suggestion Expand(string command, StringRange range)
		{
			if (range.Equals(Range))
			{
				return this;
			}
			StringBuilder stringBuilder = new StringBuilder();
			if (range.Start < Range.Start)
			{
				stringBuilder.Append(command.Substring(range.Start, Range.Start - range.Start));
			}
			stringBuilder.Append(Text);
			if (range.End > Range.End)
			{
				stringBuilder.Append(command.Substring(Range.End, range.End - Range.End));
			}
			return new Suggestion(range, stringBuilder.ToString(), Tooltip);
		}
	}
	public delegate Task<Suggestions> SuggestionProvider<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder);
	[PublicAPI]
	public class Suggestions : IEquatable<Suggestions>
	{
		private static readonly Suggestions NoSuggestions = new Suggestions(StringRange.At(0), new List<Suggestion>());

		public StringRange Range { get; }

		public List<Suggestion> List { get; }

		public Suggestions(StringRange range, List<Suggestion> suggestions)
		{
			Range = range;
			List = suggestions;
		}

		public bool IsEmpty()
		{
			return List.Count == 0;
		}

		public override bool Equals(object? obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is Suggestions other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(Suggestions? other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			if (object.Equals(Range, other.Range))
			{
				return object.Equals(List, other.List);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(Range, List);
		}

		public override string ToString()
		{
			return $"Suggestions{{range={Range}, suggestions={List}}}";
		}

		public static Task<Suggestions> Empty()
		{
			return Task.FromResult(NoSuggestions);
		}

		public static Suggestions Merge(string command, ICollection<Suggestions> input)
		{
			if (input.Count == 0)
			{
				return NoSuggestions;
			}
			if (input.Count == 1)
			{
				return input.Single();
			}
			ISet<Suggestion> set = new HashSet<Suggestion>();
			foreach (Suggestions item in input)
			{
				foreach (Suggestion item2 in item.List)
				{
					set.Add(item2);
				}
			}
			return Create(command, set.ToArray());
		}

		public static Suggestions Create(string command, Suggestion[] suggestions)
		{
			if (suggestions.Length == 0)
			{
				return NoSuggestions;
			}
			int num = int.MaxValue;
			int num2 = int.MinValue;
			Suggestion[] array = suggestions;
			foreach (Suggestion obj in array)
			{
				num = Math.Min(obj.Range.Start, num);
				num2 = Math.Max(obj.Range.End, num2);
			}
			StringRange range = new StringRange(num, num2);
			HashSet<Suggestion> hashSet = new HashSet<Suggestion>();
			array = suggestions;
			foreach (Suggestion suggestion in array)
			{
				hashSet.Add(suggestion.Expand(command, range));
			}
			List<Suggestion> list = new List<Suggestion>(hashSet);
			list.Sort((Suggestion a, Suggestion b) => a.CompareToIgnoreCase(b));
			return new Suggestions(range, list);
		}
	}
	[PublicAPI]
	public class SuggestionsBuilder
	{
		private readonly List<Suggestion> _result = new List<Suggestion>();

		public string Input { get; }

		public string InputLowerCase { get; }

		public int Start { get; }

		public string Remaining { get; }

		public string RemainingLowerCase { get; set; }

		public SuggestionsBuilder(string input, string inputLowerCase, int start)
		{
			Input = input;
			InputLowerCase = inputLowerCase;
			Start = start;
			Remaining = input.Substring(start);
			RemainingLowerCase = inputLowerCase.Substring(start);
		}

		public SuggestionsBuilder(string input, int start)
			: this(input, input.ToLowerInvariant(), start)
		{
		}

		public Suggestions Build()
		{
			return Suggestions.Create(Input, _result.ToArray());
		}

		public Task<Suggestions> BuildAsync()
		{
			return Task.FromResult(Build());
		}

		public SuggestionsBuilder Suggest(string text)
		{
			if (text.Equals(Remaining))
			{
				return this;
			}
			_result.Add(new Suggestion(StringRange.Between(Start, Input.Length), text));
			return this;
		}

		public SuggestionsBuilder Suggest(string text, IMessage tooltip)
		{
			if (text.Equals(Remaining))
			{
				return this;
			}
			_result.Add(new Suggestion(StringRange.Between(Start, Input.Length), text, tooltip));
			return this;
		}

		public SuggestionsBuilder Suggest(int value)
		{
			_result.Add(new IntegerSuggestion(StringRange.Between(Start, Input.Length), value));
			return this;
		}

		public SuggestionsBuilder Suggest(int value, IMessage tooltip)
		{
			_result.Add(new IntegerSuggestion(StringRange.Between(Start, Input.Length), value, tooltip));
			return this;
		}

		public SuggestionsBuilder Add(SuggestionsBuilder other)
		{
			_result.AddRange(other._result);
			return this;
		}

		public SuggestionsBuilder CreateOffset(int start)
		{
			return new SuggestionsBuilder(Input, InputLowerCase, start);
		}

		public SuggestionsBuilder Restart()
		{
			return CreateOffset(Start);
		}
	}
}
namespace Brigadier.NET.Exceptions
{
	public interface IBuiltInExceptionProvider
	{
		Dynamic2CommandExceptionType DoubleTooLow();

		Dynamic2CommandExceptionType DoubleTooHigh();

		Dynamic2CommandExceptionType FloatTooLow();

		Dynamic2CommandExceptionType FloatTooHigh();

		Dynamic2CommandExceptionType IntegerTooLow();

		Dynamic2CommandExceptionType IntegerTooHigh();

		Dynamic2CommandExceptionType LongTooLow();

		Dynamic2CommandExceptionType LongTooHigh();

		DynamicCommandExceptionType LiteralIncorrect();

		SimpleCommandExceptionType ReaderExpectedStartOfQuote();

		SimpleCommandExceptionType ReaderExpectedEndOfQuote();

		DynamicCommandExceptionType ReaderInvalidEscape();

		DynamicCommandExceptionType ReaderInvalidBool();

		DynamicCommandExceptionType ReaderInvalidInt();

		SimpleCommandExceptionType ReaderExpectedInt();

		DynamicCommandExceptionType ReaderInvalidLong();

		SimpleCommandExceptionType ReaderExpectedLong();

		DynamicCommandExceptionType ReaderInvalidDouble();

		SimpleCommandExceptionType ReaderExpectedDouble();

		DynamicCommandExceptionType ReaderInvalidFloat();

		SimpleCommandExceptionType ReaderExpectedFloat();

		SimpleCommandExceptionType ReaderExpectedBool();

		DynamicCommandExceptionType ReaderExpectedSymbol();

		SimpleCommandExceptionType DispatcherUnknownCommand();

		SimpleCommandExceptionType DispatcherUnknownArgument();

		SimpleCommandExceptionType DispatcherExpectedArgumentSeparator();

		DynamicCommandExceptionType DispatcherParseException();
	}
	public class BuiltInExceptions : IBuiltInExceptionProvider
	{
		private static readonly Dynamic2CommandExceptionType DOUBLE_TOO_SMALL = new Dynamic2CommandExceptionType((object found, object min) => new LiteralMessage($"Double must not be less than {min}, found {found}"));

		private static readonly Dynamic2CommandExceptionType DOUBLE_TOO_BIG = new Dynamic2CommandExceptionType((object found, object max) => new LiteralMessage($"Double must not be more than {max}, found {found}"));

		private static readonly Dynamic2CommandExceptionType FLOAT_TOO_SMALL = new Dynamic2CommandExceptionType((object found, object min) => new LiteralMessage($"Float must not be less than {min}, found {found}"));

		private static readonly Dynamic2CommandExceptionType FLOAT_TOO_BIG = new Dynamic2CommandExceptionType((object found, object max) => new LiteralMessage($"Float must not be more than {max}, found {found}"));

		private static readonly Dynamic2CommandExceptionType INTEGER_TOO_SMALL = new Dynamic2CommandExceptionType((object found, object min) => new LiteralMessage($"Integer must not be less than {min}, found {found}"));

		private static readonly Dynamic2CommandExceptionType INTEGER_TOO_BIG = new Dynamic2CommandExceptionType((object found, object max) => new LiteralMessage($"Integer must not be more than {max}, found {found}"));

		private static readonly Dynamic2CommandExceptionType LONG_TOO_SMALL = new Dynamic2CommandExceptionType((object found, object min) => new LiteralMessage($"Long must not be less than {min}, found {found}"));

		private static readonly Dynamic2CommandExceptionType LONG_TOO_BIG = new Dynamic2CommandExceptionType((object found, object max) => new LiteralMessage($"Long must not be more than {max}, found {found}"));

		private static readonly DynamicCommandExceptionType LITERAL_INCORRECT = new DynamicCommandExceptionType((object expected) => new LiteralMessage($"Expected literal {expected}"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_START_OF_QUOTE = new SimpleCommandExceptionType(new LiteralMessage("Expected quote to start a string"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_END_OF_QUOTE = new SimpleCommandExceptionType(new LiteralMessage("Unclosed quoted string"));

		private static readonly DynamicCommandExceptionType READER_INVALID_ESCAPE = new DynamicCommandExceptionType((object character) => new LiteralMessage($"Invalid escape sequence '{character}' in quoted string"));

		private static readonly DynamicCommandExceptionType READER_INVALID_BOOL = new DynamicCommandExceptionType((object value) => new LiteralMessage($"Invalid bool, expected true or false but found '{value}'"));

		private static readonly DynamicCommandExceptionType READER_INVALID_INT = new DynamicCommandExceptionType((object value) => new LiteralMessage($"Invalid integer '{value}'"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_INT = new SimpleCommandExceptionType(new LiteralMessage("Expected integer"));

		private static readonly DynamicCommandExceptionType READER_INVALID_LONG = new DynamicCommandExceptionType((object value) => new LiteralMessage($"Invalid long '{value}'"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_LONG = new SimpleCommandExceptionType(new LiteralMessage("Expected long"));

		private static readonly DynamicCommandExceptionType READER_INVALID_DOUBLE = new DynamicCommandExceptionType((object value) => new LiteralMessage($"Invalid double '{value}'"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_DOUBLE = new SimpleCommandExceptionType(new LiteralMessage("Expected double"));

		private static readonly DynamicCommandExceptionType READER_INVALID_FLOAT = new DynamicCommandExceptionType((object value) => new LiteralMessage($"Invalid float '{value}'"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_FLOAT = new SimpleCommandExceptionType(new LiteralMessage("Expected float"));

		private static readonly SimpleCommandExceptionType READER_EXPECTED_BOOL = new SimpleCommandExceptionType(new LiteralMessage("Expected bool"));

		private static readonly DynamicCommandExceptionType READER_EXPECTED_SYMBOL = new DynamicCommandExceptionType((object symbol) => new LiteralMessage($"Expected '{symbol}'"));

		private static readonly SimpleCommandExceptionType DISPATCHER_UNKNOWN_COMMAND = new SimpleCommandExceptionType(new LiteralMessage("Unknown command"));

		private static readonly SimpleCommandExceptionType DISPATCHER_UNKNOWN_ARGUMENT = new SimpleCommandExceptionType(new LiteralMessage("Incorrect argument for command"));

		private static readonly SimpleCommandExceptionType DISPATCHER_EXPECTED_ARGUMENT_SEPARATOR = new SimpleCommandExceptionType(new LiteralMessage("Expected whitespace to end one argument, but found trailing data"));

		private static readonly DynamicCommandExceptionType DISPATCHER_PARSE_EXCEPTION = new DynamicCommandExceptionType((object message) => new LiteralMessage($"Could not parse command: {message}"));

		public Dynamic2CommandExceptionType DoubleTooLow()
		{
			return DOUBLE_TOO_SMALL;
		}

		public Dynamic2CommandExceptionType DoubleTooHigh()
		{
			return DOUBLE_TOO_BIG;
		}

		public Dynamic2CommandExceptionType FloatTooLow()
		{
			return FLOAT_TOO_SMALL;
		}

		public Dynamic2CommandExceptionType FloatTooHigh()
		{
			return FLOAT_TOO_BIG;
		}

		public Dynamic2CommandExceptionType IntegerTooLow()
		{
			return INTEGER_TOO_SMALL;
		}

		public Dynamic2CommandExceptionType IntegerTooHigh()
		{
			return INTEGER_TOO_BIG;
		}

		public Dynamic2CommandExceptionType LongTooLow()
		{
			return LONG_TOO_SMALL;
		}

		public Dynamic2CommandExceptionType LongTooHigh()
		{
			return LONG_TOO_BIG;
		}

		public DynamicCommandExceptionType LiteralIncorrect()
		{
			return LITERAL_INCORRECT;
		}

		public SimpleCommandExceptionType ReaderExpectedStartOfQuote()
		{
			return READER_EXPECTED_START_OF_QUOTE;
		}

		public SimpleCommandExceptionType ReaderExpectedEndOfQuote()
		{
			return READER_EXPECTED_END_OF_QUOTE;
		}

		public DynamicCommandExceptionType ReaderInvalidEscape()
		{
			return READER_INVALID_ESCAPE;
		}

		public DynamicCommandExceptionType ReaderInvalidBool()
		{
			return READER_INVALID_BOOL;
		}

		public DynamicCommandExceptionType ReaderInvalidInt()
		{
			return READER_INVALID_INT;
		}

		public SimpleCommandExceptionType ReaderExpectedInt()
		{
			return READER_EXPECTED_INT;
		}

		public DynamicCommandExceptionType ReaderInvalidLong()
		{
			return READER_INVALID_LONG;
		}

		public SimpleCommandExceptionType ReaderExpectedLong()
		{
			return READER_EXPECTED_LONG;
		}

		public DynamicCommandExceptionType ReaderInvalidDouble()
		{
			return READER_INVALID_DOUBLE;
		}

		public SimpleCommandExceptionType ReaderExpectedDouble()
		{
			return READER_EXPECTED_DOUBLE;
		}

		public DynamicCommandExceptionType ReaderInvalidFloat()
		{
			return READER_INVALID_FLOAT;
		}

		public SimpleCommandExceptionType ReaderExpectedFloat()
		{
			return READER_EXPECTED_FLOAT;
		}

		public SimpleCommandExceptionType ReaderExpectedBool()
		{
			return READER_EXPECTED_BOOL;
		}

		public DynamicCommandExceptionType ReaderExpectedSymbol()
		{
			return READER_EXPECTED_SYMBOL;
		}

		public SimpleCommandExceptionType DispatcherUnknownCommand()
		{
			return DISPATCHER_UNKNOWN_COMMAND;
		}

		public SimpleCommandExceptionType DispatcherUnknownArgument()
		{
			return DISPATCHER_UNKNOWN_ARGUMENT;
		}

		public SimpleCommandExceptionType DispatcherExpectedArgumentSeparator()
		{
			return DISPATCHER_EXPECTED_ARGUMENT_SEPARATOR;
		}

		public DynamicCommandExceptionType DispatcherParseException()
		{
			return DISPATCHER_PARSE_EXCEPTION;
		}
	}
	[PublicAPI]
	public class CommandSyntaxException : Exception
	{
		public static readonly int ContextAmount = 10;

		public static readonly IBuiltInExceptionProvider BuiltInExceptions = new BuiltInExceptions();

		private readonly IMessage _message;

		public override string Message
		{
			get
			{
				string text = _message.String;
				string context = Context;
				if (context != null)
				{
					text += $" at position {Cursor}: {context}";
				}
				return text;
			}
		}

		public string? Context
		{
			get
			{
				if (Input == null || Cursor < 0)
				{
					return null;
				}
				StringBuilder stringBuilder = new StringBuilder();
				int num = Math.Min(Input.Length, Cursor);
				if (num > ContextAmount)
				{
					stringBuilder.Append("...");
				}
				int num2 = Math.Max(0, num - ContextAmount);
				stringBuilder.Append(Input.Substring(num2, num - num2));
				stringBuilder.Append("<--[HERE]");
				return stringBuilder.ToString();
			}
		}

		public ICommandExceptionType Type { get; }

		public string? Input { get; }

		public int Cursor { get; }

		public CommandSyntaxException(ICommandExceptionType type, IMessage message)
			: base(message.String, null)
		{
			Type = type;
			_message = message;
			Input = null;
			Cursor = -1;
		}

		public CommandSyntaxException(ICommandExceptionType type, IMessage message, string input, int cursor)
			: base(message.String, null)
		{
			Type = type;
			_message = message;
			Input = input;
			Cursor = cursor;
		}

		public IMessage RawMessage()
		{
			return _message;
		}
	}
	[PublicAPI]
	public class Dynamic2CommandExceptionType : ICommandExceptionType
	{
		public delegate IMessage Function(object a, object b);

		private readonly Function _function;

		public Dynamic2CommandExceptionType(Function function)
		{
			_function = function;
		}

		public CommandSyntaxException Create(object a, object b)
		{
			return new CommandSyntaxException(this, _function(a, b));
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader, object a, object b)
		{
			return new CommandSyntaxException(this, _function(a, b), reader.String, reader.Cursor);
		}
	}
	[PublicAPI]
	public class Dynamic3CommandExceptionType : ICommandExceptionType
	{
		public delegate IMessage Function(object a, object b, object c);

		private readonly Function _function;

		public Dynamic3CommandExceptionType(Function function)
		{
			_function = function;
		}

		public CommandSyntaxException Create(object a, object b, object c)
		{
			return new CommandSyntaxException(this, _function(a, b, c));
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader, object a, object b, object c)
		{
			return new CommandSyntaxException(this, _function(a, b, c), reader.String, reader.Cursor);
		}
	}
	[PublicAPI]
	public class Dynamic4CommandExceptionType : ICommandExceptionType
	{
		public delegate IMessage Function(object a, object b, object c, object d);

		private readonly Function _function;

		public Dynamic4CommandExceptionType(Function function)
		{
			_function = function;
		}

		public CommandSyntaxException Create(object a, object b, object c, object d)
		{
			return new CommandSyntaxException(this, _function(a, b, c, d));
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader, object a, object b, object c, object d)
		{
			return new CommandSyntaxException(this, _function(a, b, c, d), reader.String, reader.Cursor);
		}
	}
	[PublicAPI]
	public class DynamicCommandExceptionType : ICommandExceptionType
	{
		public delegate IMessage Function(object a);

		private readonly Function _function;

		public DynamicCommandExceptionType(Function function)
		{
			_function = function;
		}

		public CommandSyntaxException Create(object a)
		{
			return new CommandSyntaxException(this, _function(a));
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader, object a)
		{
			return new CommandSyntaxException(this, _function(a), reader.String, reader.Cursor);
		}
	}
	[PublicAPI]
	public class DynamicNCommandExceptionType : ICommandExceptionType
	{
		public delegate IMessage Function(object[] args);

		private readonly Function _function;

		public DynamicNCommandExceptionType(Function function)
		{
			_function = function;
		}

		public CommandSyntaxException Create(params object[] args)
		{
			return new CommandSyntaxException(this, _function(args));
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader, params object[] args)
		{
			return new CommandSyntaxException(this, _function(args), reader.String, reader.Cursor);
		}
	}
	public interface ICommandExceptionType
	{
	}
	[PublicAPI]
	public class SimpleCommandExceptionType : ICommandExceptionType
	{
		private readonly IMessage _message;

		public SimpleCommandExceptionType(IMessage message)
		{
			_message = message;
		}

		public CommandSyntaxException Create()
		{
			return new CommandSyntaxException(this, _message);
		}

		public CommandSyntaxException CreateWithContext(IImmutableStringReader reader)
		{
			return new CommandSyntaxException(this, _message, reader.String, reader.Cursor);
		}

		public override string ToString()
		{
			return _message.String;
		}
	}
}
namespace Brigadier.NET.Context
{
	[PublicAPI]
	public class CommandContext<TSource> : IEquatable<CommandContext<TSource>>
	{
		private readonly IDictionary<string, IParsedArgument> _arguments;

		private readonly bool _forks;

		public CommandContext<TSource>? Child { get; }

		public CommandContext<TSource> LastChild
		{
			get
			{
				CommandContext<TSource> commandContext = this;
				while (commandContext.Child != null)
				{
					commandContext = commandContext.Child;
				}
				return commandContext;
			}
		}

		public Command<TSource>? Command { get; }

		public TSource Source { get; }

		public RedirectModifier<TSource>? RedirectModifier { get; }

		public StringRange Range { get; }

		public string Input { get; }

		public CommandNode<TSource> RootNode { get; }

		public List<ParsedCommandNode<TSource>> Nodes { get; }

		public CommandContext(TSource source, string input, IDictionary<string, IParsedArgument> arguments, Command<TSource>? command, CommandNode<TSource> rootNode, List<ParsedCommandNode<TSource>> nodes, StringRange range, CommandContext<TSource>? child, RedirectModifier<TSource>? modifier, bool forks)
		{
			Source = source;
			Input = input;
			_arguments = arguments;
			Command = command;
			RootNode = rootNode;
			Nodes = nodes;
			Range = range;
			Child = child;
			RedirectModifier = modifier;
			_forks = forks;
		}

		public CommandContext<TSource> CopyFor(TSource source)
		{
			TSource source2 = Source;
			if (source2 != null && source2.Equals(source))
			{
				return this;
			}
			return new CommandContext<TSource>(source, Input, _arguments, Command, RootNode, Nodes, Range, Child, RedirectModifier, _forks);
		}

		public T GetArgument<T>(string name)
		{
			if (!_arguments.TryGetValue(name, out IParsedArgument value))
			{
				throw new InvalidOperationException("No such argument '" + name + "' exists on this command");
			}
			object result = value.Result;
			if (result is T)
			{
				return (T)result;
			}
			throw new InvalidOperationException("Argument " + name + "' is defined as " + result.GetType().Name + ", not " + typeof(T).Name);
		}

		public override bool Equals(object? obj)
		{
			if (obj == null)
			{
				return false;
			}
			if (this == obj)
			{
				return true;
			}
			if (obj is CommandContext<TSource> other)
			{
				return Equals(other);
			}
			return false;
		}

		public bool Equals(CommandContext<TSource>? other)
		{
			if (other == null)
			{
				return false;
			}
			if (this == other)
			{
				return true;
			}
			if (_arguments.SequenceEqual(other._arguments) && object.Equals(RootNode, other.RootNode) && Nodes.SequenceEqual<ParsedCommandNode<TSource>>(other.Nodes) && object.Equals(Command, other.Command) && EqualityComparer<TSource>.Default.Equals(Source, other.Source))
			{
				return object.Equals(Child, other.Child);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(Source, _arguments, Command, RootNode, Nodes, Child);
		}

		public bool HasNodes()
		{
			return Nodes.Count > 0;
		}

		public bool IsForked()
		{
			return _forks;
		}
	}
	[PublicAPI]
	public class CommandContextBuilder<TSource>
	{
		private readonly IDictionary<string, IParsedArgument> _arguments;

		private RedirectModifier<TSource>? _modifier;

		private bool _forks;

		public TSource Source { get; private set; }

		public CommandNode<TSource> RootNode { get; }

		public CommandContextBuilder<TSource>? Child { get; private set; }

		public CommandContextBuilder<TSource> LastChild
		{
			get
			{
				CommandContextBuilder<TSource> commandContextBuilder = this;
				while (commandContextBuilder.Child != null)
				{
					commandContextBuilder = commandContextBuilder.Child;
				}
				return commandContextBuilder;
			}
		}

		public Command<TSource>? Command { get; private set; }

		public List<ParsedCommandNode<TSource>> Nodes { get; }

		public CommandDispatcher<TSource> Dispatcher { get; }

		public StringRange Range { get; private set; }

		public CommandContextBuilder(CommandDispatcher<TSource> dispatcher, TSource source, CommandNode<TSource> rootNode, int start)
		{
			RootNode = rootNode;
			Dispatcher = dispatcher;
			Source = source;
			Range = StringRange.At(start);
			_arguments = new Dictionary<string, IParsedArgument>();
			Nodes = new List<ParsedCommandNode<TSource>>();
		}

		public CommandContextBuilder(CommandDispatcher<TSource> dispatcher, TSource source, CommandNode<TSource> rootNode, StringRange range, IDictionary<string, IParsedArgument> arguments, List<ParsedCommandNode<TSource>> nodes)
		{
			Dispatcher = dispatcher;
			Source = source;
			RootNode = rootNode;
			Range = range;
			_arguments = new Dictionary<string, IParsedArgument>(arguments);
			Nodes = new List<ParsedCommandNode<TSource>>(nodes);
		}

		public CommandContextBuilder<TSource> WithSource(TSource source)
		{
			Source = source;
			return this;
		}

		public CommandContextBuilder<TSource> WithArgument(string name, IParsedArgument argument)
		{
			_arguments.Add(name, argument);
			return this;
		}

		public IDictionary<string, IParsedArgument> GetArguments()
		{
			return _arguments;
		}

		public CommandContextBuilder<TSource> WithCommand(Command<TSource>? command)
		{
			Command = command;
			return this;
		}

		public CommandContextBuilder<TSource> WithNode(CommandNode<TSource> node, StringRange range)
		{
			Nodes.Add(new ParsedCommandNode<TSource>(node, range));
			Range = StringRange.Encompassing(Range, range);
			_modifier = node.RedirectModifier;
			_forks = node.IsFork;
			return this;
		}

		public CommandContextBuilder<TSource> Copy()
		{
			return new CommandContextBuilder<TSource>(Dispatcher, Source, RootNode, Range, _arguments, Nodes)
			{
				Command = Command,
				Child = Child,
				_forks = _forks
			};
		}

		public CommandContextBuilder<TSource> WithChild(CommandContextBuilder<TSource> child)
		{
			Child = child;
			return this;
		}

		public CommandContext<TSource> Build(string input)
		{
			return new CommandContext<TSource>(Source, input, _arguments, Command, RootNode, Nodes, Range, Child?.Build(input), _modifier, _forks);
		}

		public SuggestionContext<TSource> FindSuggestionContext(int cursor)
		{
			if (Range.Start <= cursor)
			{
				if (Range.End < cursor)
				{
					if (Child != null)
					{
						return Child.FindSuggestionContext(cursor);
					}
					if (Nodes.Count > 0)
					{
						List<ParsedCommandNode<TSource>> nodes = Nodes;
						ParsedCommandNode<TSource> parsedCommandNode = nodes[nodes.Count - 1];
						return new SuggestionContext<TSource>(parsedCommandNode.Node, parsedCommandNode.Range.End + 1);
					}
					return new SuggestionContext<TSource>(RootNode, Range.Start);
				}
				CommandNode<TSource> commandNode = RootNode;
				foreach (ParsedCommandNode<TSource> node in Nodes)
				{
					StringRange range = node.Range;
					if (range.Start <= cursor && cursor <= range.End)
					{
						return new SuggestionContext<TSource>(commandNode, range.Start);
					}
					commandNode = node.Node;
				}
				if (commandNode == null)
				{
					throw new InvalidOperationException("Can't find node before cursor");
				}
				return new SuggestionContext<TSource>(commandNode, Range.Start);
			}
			throw new InvalidOperationException("Can't find node before cursor");
		}
	}
	[PublicAPI]
	public static class ContextChain
	{
		public static bool TryFlatten<TSource>(this CommandContext<TSource> rootContext, [NotNullWhen(true)] out ContextChain<TSource>? chain)
		{
			return ContextChain<TSource>.TryFlatten(rootContext, out chain);
		}

		public static int RunExecutable<TSource>(this CommandContext<TSource> executable, TSource source, ResultConsumer<TSource> resultConsumer, bool forkedMode)
		{
			return ContextChain<TSource>.RunExecutable(executable, source, resultConsumer, forkedMode);
		}

		public static IList<TSource> RunModifier<TSource>(this CommandContext<TSource> modifier, TSource source, ResultConsumer<TSource> resultConsumer, bool forkedMode)
		{
			return ContextChain<TSource>.RunModifier(modifier, source, resultConsumer, forkedMode);
		}
	}
	[PublicAPI]
	public class ContextChain<TSource>
	{
		public enum Stage
		{
			Modify,
			Execute
		}

		private readonly List<CommandContext<TSource>> _modifiers;

		private readonly CommandContext<TSource> _executable;

		private ContextChain<TSource>? _nextStageCache;

		public Stage CurrentStage
		{
			get
			{
				if (_modifiers.Count != 0)
				{
					return Stage.Modify;
				}
				return Stage.Execute;
			}
		}

		public CommandContext<TSource> TopContext
		{
			get
			{
				if (_modifiers.Count != 0)
				{
					return _modifiers[0];
				}
				return _executable;
			}
		}

		public ContextChain(List<CommandContext<TSource>> modifiers, CommandContext<TSource> executable)
		{
			if (executable.Command == null)
			{
				throw new ArgumentException("Last command in chain must be executable", "executable");
			}
			_modifiers = modifiers;
			_executable = executable;
		}

		public static bool TryFlatten(Co