Decompiled source of Glitnir Adm HUD v0.0.1

GlitnirADM_Pay.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace GlitnirListsHUD
{
	[BepInPlugin("glitnir.lists.unified", "Glitnir Lists Unified", "1.10.8")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "glitnir.lists.unified";

		public const string PluginName = "Glitnir Lists Unified";

		public const string PluginVersion = "1.10.8";

		internal const string RpcRequestAdd = "GlitnirLists_RequestAdd";

		internal const string RpcRequestRemove = "GlitnirLists_RequestRemove";

		internal const string RpcRequestPayment = "GlitnirLists_RequestPayment";

		internal const string RpcReceivePayment = "GlitnirLists_ReceivePayment";

		internal const string RpcRequestOnlinePlayers = "GlitnirLists_RequestOnlinePlayers";

		internal const string RpcReceiveOnlinePlayers = "GlitnirLists_ReceiveOnlinePlayers";

		internal const string RpcResponse = "GlitnirLists_Response";

		internal const string RpcRequestHudAccess = "GlitnirLists_RequestHudAccess";

		internal const string RpcReceiveHudAccess = "GlitnirLists_ReceiveHudAccess";

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		private bool _rpcRegistered;

		private GlitnirHud _hud;

		internal static ConfigEntry<string> ConfigSaveDirPath;

		internal static ConfigEntry<string> ConfigCoinPrefabName;

		internal static ConfigEntry<KeyboardShortcut> ConfigHudToggleKey;

		internal static ConfigEntry<float> ConfigHudWindowX;

		internal static ConfigEntry<float> ConfigHudWindowY;

		internal static ConfigEntry<float> ConfigHudWindowWidth;

		internal static ConfigEntry<float> ConfigHudWindowHeight;

		internal static ConfigEntry<bool> ConfigCreateListFilesOnStartup;

		internal static ConfigEntry<bool> ConfigRestrictHudAccessToAdminWhitelist;

		private void InitializeConfig()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			ConfigSaveDirPath = ((BaseUnityPlugin)this).Config.Bind<string>("General", "SaveDirPath", "C:\\Valheim\\servers\\2\\SaveDir", "Pasta onde o mod vai ler e escrever permittedlist.txt, bannedlist.txt e adminlist.txt.");
			ConfigCreateListFilesOnStartup = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CreateListFilesOnStartup", true, "Quando true, cria automaticamente a pasta SaveDir e os arquivos de lista se estiverem faltando.");
			ConfigCoinPrefabName = ((BaseUnityPlugin)this).Config.Bind<string>("Payments", "CoinPrefabName", "GlitnirCoin", "Prefab da moeda enviada pelo comando glitnir_pay.");
			ConfigHudToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("HUD", "ToggleKey", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Tecla para abrir/fechar o HUD.");
			ConfigHudWindowX = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "WindowX", 120f, "Posição X inicial do HUD.");
			ConfigHudWindowY = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "WindowY", 80f, "Posição Y inicial do HUD.");
			ConfigHudWindowWidth = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "WindowWidth", 860f, "Largura inicial do HUD.");
			ConfigHudWindowHeight = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "WindowHeight", 610f, "Altura inicial do HUD.");
			ConfigRestrictHudAccessToAdminWhitelist = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "RestrictHudAccessToAdminWhitelist", true, "Quando true, apenas jogadores presentes na adminlist e na whitelist podem abrir o HUD.");
			((BaseUnityPlugin)this).Config.Save();
		}

		private void Awake()
		{
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			InitializeConfig();
			PathsConfig.EnsureStorageFiles();
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new WlAddCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new WlRemoveCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new BanAddCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new BanRemoveCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AdmAddCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new AdmRemoveCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new GlitnirPayCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new HudToggleCommand());
			_hud = ((Component)this).gameObject.AddComponent<GlitnirHud>();
			_hud.ApplyConfig();
			Print("[GlitnirLists] carregado.");
			Print("Comandos: wl_add, wl_remove, ban_add, ban_remove, adm_add, adm_remove, glitnir_pay, glitnir_hud");
			Print("HUD: pressione " + PathsConfig.HudToggleKeyText + " para abrir/fechar.");
			Print("[GlitnirLists] SaveDir: " + PathsConfig.FolderPath);
		}

		private void Update()
		{
			if (!_rpcRegistered && ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.Register<ZPackage>("GlitnirLists_RequestAdd", (Action<long, ZPackage>)RPC_RequestAdd);
				ZRoutedRpc.instance.Register<ZPackage>("GlitnirLists_RequestRemove", (Action<long, ZPackage>)RPC_RequestRemove);
				ZRoutedRpc.instance.Register<ZPackage>("GlitnirLists_RequestPayment", (Action<long, ZPackage>)RPC_RequestPayment);
				ZRoutedRpc.instance.Register<ZPackage>("GlitnirLists_ReceivePayment", (Action<long, ZPackage>)RPC_ReceivePayment);
				ZRoutedRpc.instance.Register<ZPackage>("GlitnirLists_RequestOnlinePlayers", (Action<long, ZPackage>)RPC_RequestOnlinePlayers);
				ZRoutedRpc.instance.Register<ZPackage>("GlitnirLists_ReceiveOnlinePlayers", (Action<long, ZPackage>)RPC_ReceiveOnlinePlayers);
				ZRoutedRpc.instance.Register<ZPackage>("GlitnirLists_Response", (Action<long, ZPackage>)RPC_Response);
				ZRoutedRpc.instance.Register<ZPackage>("GlitnirLists_RequestHudAccess", (Action<long, ZPackage>)RPC_RequestHudAccess);
				ZRoutedRpc.instance.Register<ZPackage>("GlitnirLists_ReceiveHudAccess", (Action<long, ZPackage>)RPC_ReceiveHudAccess);
				_rpcRegistered = true;
				Print("[GlitnirLists] RPC registrada.");
			}
		}

		internal void ToggleHud()
		{
			if (!((Object)(object)_hud == (Object)null))
			{
				if (_hud.IsVisible)
				{
					_hud.SetVisible(visible: false);
				}
				else if (ConfigRestrictHudAccessToAdminWhitelist == null || !ConfigRestrictHudAccessToAdminWhitelist.Value)
				{
					_hud.SetVisible(visible: true);
				}
				else
				{
					RequestHudAuthorization();
				}
			}
		}

		private void RequestHudAuthorization()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			try
			{
				if (IsServer())
				{
					string message;
					bool allowed = AdminUtils.TryAuthorizeHostLocalHudOpen(out message);
					HandleHudAuthorizationResult(allowed, message);
				}
				else if (ZRoutedRpc.instance == null)
				{
					PushHudMessage("ZRoutedRpc ainda nao esta pronta.");
				}
				else
				{
					ZPackage val = new ZPackage();
					ZRoutedRpc.instance.InvokeRoutedRPC(0L, "GlitnirLists_RequestHudAccess", new object[1] { val });
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
				PushHudMessage("Erro ao validar permissao do HUD: " + ex.Message);
			}
		}

		private void HandleHudAuthorizationResult(bool allowed, string message)
		{
			if (allowed)
			{
				_hud.SetVisible(visible: true);
			}
			if (!string.IsNullOrWhiteSpace(message))
			{
				Print(message);
				PushHudMessage(message);
			}
		}

		internal void PushHudMessage(string message)
		{
			if ((Object)(object)_hud != (Object)null)
			{
				_hud.SetServerMessage(message);
			}
		}

		internal void SetOnlinePlayers(List<OnlinePlayerRecord> players)
		{
			if ((Object)(object)_hud != (Object)null)
			{
				_hud.SetOnlinePlayers(players);
			}
		}

		internal void RequestOnlinePlayers()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			try
			{
				if (IsServer())
				{
					SetOnlinePlayers(OnlinePlayersDirectory.BuildOnlinePlayersForServer());
					PushHudMessage("Lista de jogadores online atualizada.");
					return;
				}
				if (ZRoutedRpc.instance == null)
				{
					PushHudMessage("ZRoutedRpc ainda nao esta pronta.");
					return;
				}
				ZPackage val = new ZPackage();
				ZRoutedRpc.instance.InvokeRoutedRPC(0L, "GlitnirLists_RequestOnlinePlayers", new object[1] { val });
				PushHudMessage("Solicitando lista de jogadores online ao servidor...");
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
				PushHudMessage("Erro ao solicitar lista online: " + ex.Message);
			}
		}

		private void RPC_RequestAdd(long sender, ZPackage pkg)
		{
			if (!IsServer())
			{
				return;
			}
			try
			{
				if (pkg == null || pkg.Size() <= 0)
				{
					SendResponse(sender, "[GlitnirLists] pacote invalido.");
					return;
				}
				string text = pkg.ReadString();
				string steamId = pkg.ReadString();
				string empty = string.Empty;
				try
				{
					empty = pkg.ReadString();
				}
				catch
				{
					empty = string.Empty;
				}
				bool flag = sender == 0;
				if (!flag && !AdminUtils.IsSenderAdmin(sender))
				{
					SendResponse(sender, "[GlitnirLists] voce nao esta na adminlist.");
					return;
				}
				string text2 = (text ?? string.Empty).Trim().ToLowerInvariant() switch
				{
					"whitelist" => NumericIdListIO.AddOrUpdate(PathsConfig.PermittedFile, PathsConfig.PermittedNotesFile, steamId, empty, "Whitelist"), 
					"banlist" => NumericIdListIO.AddOrUpdate(PathsConfig.BannedFile, PathsConfig.BannedNotesFile, steamId, empty, "Banlist"), 
					"adminlist" => NumericIdListIO.AddOrUpdate(PathsConfig.AdminFile, PathsConfig.AdminNotesFile, steamId, empty, "Adminlist"), 
					_ => "[GlitnirLists] tipo de lista invalido.", 
				};
				if (flag)
				{
					Print(text2);
					PushHudMessage(text2);
				}
				else
				{
					SendResponse(sender, text2);
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
				string text3 = "[GlitnirLists] erro: " + ex.Message;
				if (sender == 0)
				{
					Print(text3);
					PushHudMessage(text3);
				}
				else
				{
					SendResponse(sender, text3);
				}
			}
		}

		private void RPC_RequestRemove(long sender, ZPackage pkg)
		{
			if (!IsServer())
			{
				return;
			}
			try
			{
				if (pkg == null || pkg.Size() <= 0)
				{
					SendResponse(sender, "[GlitnirLists] pacote invalido.");
					return;
				}
				string text = pkg.ReadString();
				string steamId = pkg.ReadString();
				bool flag = sender == 0;
				if (!flag && !AdminUtils.IsSenderAdmin(sender))
				{
					SendResponse(sender, "[GlitnirLists] voce nao esta na adminlist.");
					return;
				}
				string text2 = (text ?? string.Empty).Trim().ToLowerInvariant() switch
				{
					"whitelist" => NumericIdListIO.Remove(PathsConfig.PermittedFile, PathsConfig.PermittedNotesFile, steamId, "Whitelist"), 
					"banlist" => NumericIdListIO.Remove(PathsConfig.BannedFile, PathsConfig.BannedNotesFile, steamId, "Banlist"), 
					"adminlist" => NumericIdListIO.Remove(PathsConfig.AdminFile, PathsConfig.AdminNotesFile, steamId, "Adminlist"), 
					_ => "[GlitnirLists] tipo de lista invalido.", 
				};
				if (flag)
				{
					Print(text2);
					PushHudMessage(text2);
				}
				else
				{
					SendResponse(sender, text2);
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
				string text3 = "[GlitnirLists] erro: " + ex.Message;
				if (sender == 0)
				{
					Print(text3);
					PushHudMessage(text3);
				}
				else
				{
					SendResponse(sender, text3);
				}
			}
		}

		private void RPC_RequestPayment(long sender, ZPackage pkg)
		{
			if (!IsServer())
			{
				return;
			}
			try
			{
				if (pkg == null || pkg.Size() <= 0)
				{
					SendResponse(sender, "[Pagamentos] pacote invalido.");
					return;
				}
				string steamId = pkg.ReadString();
				int amount = pkg.ReadInt();
				bool flag = sender == 0;
				if (!flag && !AdminUtils.IsSenderAdmin(sender))
				{
					SendResponse(sender, "[Pagamentos] voce nao esta na adminlist.");
					return;
				}
				string text = GlitnirPayments.DispatchGlitnirCoins(steamId, amount, sender);
				if (flag)
				{
					Print(text);
					PushHudMessage(text);
				}
				else
				{
					SendResponse(sender, text);
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
				string text2 = "[Pagamentos] erro: " + ex.Message;
				if (sender == 0)
				{
					Print(text2);
					PushHudMessage(text2);
				}
				else
				{
					SendResponse(sender, text2);
				}
			}
		}

		private void RPC_ReceivePayment(long sender, ZPackage pkg)
		{
			try
			{
				string text = GlitnirPayments.ReceiveGlitnirCoins(sender, pkg);
				if (!string.IsNullOrWhiteSpace(text))
				{
					Print(text);
					if ((Object)(object)Instance != (Object)null)
					{
						Instance.PushHudMessage(text);
					}
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
			}
		}

		private void RPC_RequestOnlinePlayers(long sender, ZPackage pkg)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (!IsServer())
			{
				return;
			}
			try
			{
				List<OnlinePlayerRecord> list = OnlinePlayersDirectory.BuildOnlinePlayersForServer();
				ZPackage val = new ZPackage();
				val.Write(list.Count);
				foreach (OnlinePlayerRecord item in list)
				{
					val.Write(item.PlayerName ?? string.Empty);
					val.Write(item.SteamId ?? string.Empty);
				}
				if (ZRoutedRpc.instance != null)
				{
					ZRoutedRpc.instance.InvokeRoutedRPC(sender, "GlitnirLists_ReceiveOnlinePlayers", new object[1] { val });
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
				SendResponse(sender, "[GlitnirLists] erro ao montar lista de jogadores online: " + ex.Message);
			}
		}

		private void RPC_ReceiveOnlinePlayers(long sender, ZPackage pkg)
		{
			try
			{
				List<OnlinePlayerRecord> list = new List<OnlinePlayerRecord>();
				if (pkg != null && pkg.Size() > 0)
				{
					int num = pkg.ReadInt();
					for (int i = 0; i < num; i++)
					{
						list.Add(new OnlinePlayerRecord
						{
							PlayerName = pkg.ReadString(),
							SteamId = pkg.ReadString()
						});
					}
				}
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.SetOnlinePlayers(list);
					Instance.PushHudMessage("Lista de jogadores online atualizada.");
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
			}
		}

		private void RPC_RequestHudAccess(long sender, ZPackage pkg)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			if (!IsServer())
			{
				return;
			}
			try
			{
				string message;
				bool flag = ((sender != 0) ? AdminUtils.TryAuthorizeSenderHudOpen(sender, out message) : AdminUtils.TryAuthorizeHostLocalHudOpen(out message));
				ZPackage val = new ZPackage();
				val.Write(flag);
				val.Write(message ?? string.Empty);
				if (sender == 0)
				{
					RPC_ReceiveHudAccess(0L, val);
				}
				else if (ZRoutedRpc.instance != null)
				{
					ZRoutedRpc.instance.InvokeRoutedRPC(sender, "GlitnirLists_ReceiveHudAccess", new object[1] { val });
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
				SendResponse(sender, "[GlitnirLists] erro ao validar permissao do HUD: " + ex.Message);
			}
		}

		private void RPC_ReceiveHudAccess(long sender, ZPackage pkg)
		{
			try
			{
				bool allowed = false;
				string message = string.Empty;
				if (pkg != null && pkg.Size() > 0)
				{
					allowed = pkg.ReadBool();
					message = pkg.ReadString();
				}
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.HandleHudAuthorizationResult(allowed, message);
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
			}
		}

		private void RPC_Response(long sender, ZPackage pkg)
		{
			if (pkg != null && pkg.Size() > 0)
			{
				string empty = string.Empty;
				try
				{
					empty = pkg.ReadString();
				}
				catch
				{
					empty = string.Empty;
				}
				if (!string.IsNullOrWhiteSpace(empty))
				{
					Print(empty);
					PushHudMessage(empty);
				}
			}
		}

		internal static void ExecuteAdd(string listType, string steamId, string alias)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			try
			{
				if (string.IsNullOrWhiteSpace(steamId))
				{
					Print("Uso: <comando> <steamid64> [apelido]");
					if ((Object)(object)Instance != (Object)null)
					{
						Instance.PushHudMessage("Preencha um SteamID com 17 digitos.");
					}
					return;
				}
				if (IsServer())
				{
					ZPackage val = new ZPackage();
					val.Write(listType ?? string.Empty);
					val.Write(steamId.Trim());
					val.Write(alias ?? string.Empty);
					Instance.RPC_RequestAdd(0L, val);
					return;
				}
				if (ZRoutedRpc.instance == null)
				{
					Print("[GlitnirLists] ZRoutedRpc nao esta pronta.");
					if ((Object)(object)Instance != (Object)null)
					{
						Instance.PushHudMessage("ZRoutedRpc ainda nao esta pronta.");
					}
					return;
				}
				ZPackage val2 = new ZPackage();
				val2.Write(listType ?? string.Empty);
				val2.Write(steamId.Trim());
				val2.Write(alias ?? string.Empty);
				ZRoutedRpc.instance.InvokeRoutedRPC(0L, "GlitnirLists_RequestAdd", new object[1] { val2 });
				Print("[GlitnirLists] pedido enviado ao servidor...");
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.PushHudMessage("Pedido enviado ao servidor...");
				}
			}
			catch (Exception ex)
			{
				Print("[GlitnirLists] erro ao enviar pedido: " + ex.Message);
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.PushHudMessage("Erro ao enviar pedido: " + ex.Message);
				}
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
			}
		}

		internal static void ExecuteRemove(string listType, string steamId)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			try
			{
				if (string.IsNullOrWhiteSpace(steamId))
				{
					Print("Uso: <comando> <steamid64>");
					if ((Object)(object)Instance != (Object)null)
					{
						Instance.PushHudMessage("Preencha um SteamID com 17 digitos.");
					}
					return;
				}
				if (IsServer())
				{
					ZPackage val = new ZPackage();
					val.Write(listType ?? string.Empty);
					val.Write(steamId.Trim());
					Instance.RPC_RequestRemove(0L, val);
					return;
				}
				if (ZRoutedRpc.instance == null)
				{
					Print("[GlitnirLists] ZRoutedRpc nao esta pronta.");
					if ((Object)(object)Instance != (Object)null)
					{
						Instance.PushHudMessage("ZRoutedRpc ainda nao esta pronta.");
					}
					return;
				}
				ZPackage val2 = new ZPackage();
				val2.Write(listType ?? string.Empty);
				val2.Write(steamId.Trim());
				ZRoutedRpc.instance.InvokeRoutedRPC(0L, "GlitnirLists_RequestRemove", new object[1] { val2 });
				Print("[GlitnirLists] pedido de remocao enviado ao servidor...");
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.PushHudMessage("Pedido de remocao enviado ao servidor...");
				}
			}
			catch (Exception ex)
			{
				Print("[GlitnirLists] erro ao enviar pedido de remocao: " + ex.Message);
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.PushHudMessage("Erro ao enviar pedido de remocao: " + ex.Message);
				}
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
			}
		}

		internal static void ExecutePayment(string steamId, int amount)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			try
			{
				if (string.IsNullOrWhiteSpace(steamId))
				{
					Print("Uso: glitnir_pay <steamid64> <quantidade>");
					if ((Object)(object)Instance != (Object)null)
					{
						Instance.PushHudMessage("Preencha um SteamID com 17 digitos.");
					}
					return;
				}
				if (amount <= 0)
				{
					Print("Uso: glitnir_pay <steamid64> <quantidade>");
					if ((Object)(object)Instance != (Object)null)
					{
						Instance.PushHudMessage("Informe uma quantidade maior que zero.");
					}
					return;
				}
				if (IsServer())
				{
					ZPackage val = new ZPackage();
					val.Write(steamId.Trim());
					val.Write(amount);
					Instance.RPC_RequestPayment(0L, val);
					return;
				}
				if (ZRoutedRpc.instance == null)
				{
					Print("[Pagamentos] ZRoutedRpc nao esta pronta.");
					if ((Object)(object)Instance != (Object)null)
					{
						Instance.PushHudMessage("ZRoutedRpc ainda nao esta pronta.");
					}
					return;
				}
				ZPackage val2 = new ZPackage();
				val2.Write(steamId.Trim());
				val2.Write(amount);
				ZRoutedRpc.instance.InvokeRoutedRPC(0L, "GlitnirLists_RequestPayment", new object[1] { val2 });
				Print("[Pagamentos] pedido enviado ao servidor...");
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.PushHudMessage("Pedido de pagamento enviado ao servidor...");
				}
			}
			catch (Exception ex)
			{
				Print("[Pagamentos] erro ao enviar pedido: " + ex.Message);
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.PushHudMessage("Erro ao enviar pedido: " + ex.Message);
				}
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
			}
		}

		internal static bool IsServer()
		{
			return (Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer();
		}

		internal static void SendResponse(long sender, string message)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			try
			{
				if (sender != 0L && ZRoutedRpc.instance != null)
				{
					ZPackage val = new ZPackage();
					val.Write(message ?? string.Empty);
					ZRoutedRpc.instance.InvokeRoutedRPC(sender, "GlitnirLists_Response", new object[1] { val });
				}
				else
				{
					Print(message);
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)ex);
				}
			}
		}

		internal static void Print(string msg)
		{
			Debug.Log((object)msg);
			if ((Object)(object)Console.instance != (Object)null)
			{
				Console.instance.Print(msg);
			}
			if (Log != null)
			{
				Log.LogMessage((object)msg);
			}
		}
	}
	internal static class PathsConfig
	{
		private const string DefaultFolderPath = "C:\\Valheim\\servers\\2\\SaveDir";

		private const string DefaultCoinPrefabName = "GlitnirCoin";

		internal static string FolderPath => NormalizeFolderPath((Plugin.ConfigSaveDirPath != null) ? Plugin.ConfigSaveDirPath.Value : "C:\\Valheim\\servers\\2\\SaveDir");

		internal static string CoinPrefabName => string.IsNullOrWhiteSpace((Plugin.ConfigCoinPrefabName != null) ? Plugin.ConfigCoinPrefabName.Value : null) ? "GlitnirCoin" : Plugin.ConfigCoinPrefabName.Value.Trim();

		internal static KeyboardShortcut HudToggleKey => (KeyboardShortcut)((Plugin.ConfigHudToggleKey != null) ? Plugin.ConfigHudToggleKey.Value : new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()));

		internal static string HudToggleKeyText
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: 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)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				KeyboardShortcut hudToggleKey = HudToggleKey;
				object result;
				if ((int)((KeyboardShortcut)(ref hudToggleKey)).MainKey != 0)
				{
					hudToggleKey = HudToggleKey;
					result = ((object)(KeyboardShortcut)(ref hudToggleKey)).ToString();
				}
				else
				{
					result = "sem tecla";
				}
				return (string)result;
			}
		}

		internal static string PermittedFile => Path.Combine(FolderPath, "permittedlist.txt");

		internal static string PermittedNotesFile => Path.Combine(FolderPath, "permittedlist_notes.txt");

		internal static string BannedFile => Path.Combine(FolderPath, "bannedlist.txt");

		internal static string BannedNotesFile => Path.Combine(FolderPath, "bannedlist_notes.txt");

		internal static string AdminFile => Path.Combine(FolderPath, "adminlist.txt");

		internal static string AdminNotesFile => Path.Combine(FolderPath, "adminlist_notes.txt");

		internal static string PermittedHeader => "// List permitted players ID ONE per line";

		internal static string BannedHeader => "// List banned players ID ONE per line";

		internal static string AdminHeader => "// List admin players ID ONE per line";

		internal static Rect GetHudWindowRect()
		{
			//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_0086: Unknown result type (might be due to invalid IL or missing references)
			float num = ((Plugin.ConfigHudWindowX != null) ? Plugin.ConfigHudWindowX.Value : 120f);
			float num2 = ((Plugin.ConfigHudWindowY != null) ? Plugin.ConfigHudWindowY.Value : 80f);
			float num3 = ((Plugin.ConfigHudWindowWidth != null) ? Plugin.ConfigHudWindowWidth.Value : 860f);
			float num4 = ((Plugin.ConfigHudWindowHeight != null) ? Plugin.ConfigHudWindowHeight.Value : 610f);
			return new Rect(num, num2, Mathf.Max(640f, num3), Mathf.Max(420f, num4));
		}

		internal static void EnsureStorageFiles()
		{
			try
			{
				if (Plugin.ConfigCreateListFilesOnStartup == null || Plugin.ConfigCreateListFilesOnStartup.Value)
				{
					if (!Directory.Exists(FolderPath))
					{
						Directory.CreateDirectory(FolderPath);
					}
					EnsureFile(PermittedFile, PermittedHeader);
					EnsureFile(BannedFile, BannedHeader);
					EnsureFile(AdminFile, AdminHeader);
					EnsureFile(PermittedNotesFile, PermittedHeader);
					EnsureFile(BannedNotesFile, BannedHeader);
					EnsureFile(AdminNotesFile, AdminHeader);
				}
			}
			catch (Exception ex)
			{
				Plugin.Print("[GlitnirLists] erro ao garantir arquivos de lista: " + ex.Message);
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)ex);
				}
			}
		}

		private static void EnsureFile(string filePath, string header)
		{
			if (!File.Exists(filePath))
			{
				string[] contents = (string.IsNullOrWhiteSpace(header) ? Array.Empty<string>() : new string[1] { header });
				File.WriteAllLines(filePath, contents);
			}
		}

		private static string NormalizeFolderPath(string value)
		{
			string name = (string.IsNullOrWhiteSpace(value) ? "C:\\Valheim\\servers\\2\\SaveDir" : value.Trim());
			name = Environment.ExpandEnvironmentVariables(name);
			return Path.GetFullPath(name);
		}
	}
	internal sealed class WlAddCommand : ConsoleCommand
	{
		public override string Name => "wl_add";

		public override string Help => "wl_add <steamid64> [apelido] - adiciona na whitelist";

		public override void Run(string[] args)
		{
			if (args == null || args.Length < 1)
			{
				Plugin.Print("Uso: wl_add <steamid64> [apelido]");
				return;
			}
			string steamId = args[0].Trim();
			string alias = ((args.Length > 1) ? string.Join(" ", args.Skip(1)).Trim() : string.Empty);
			Plugin.ExecuteAdd("whitelist", steamId, alias);
		}
	}
	internal sealed class BanAddCommand : ConsoleCommand
	{
		public override string Name => "ban_add";

		public override string Help => "ban_add <steamid64> [apelido] - adiciona na banlist";

		public override void Run(string[] args)
		{
			if (args == null || args.Length < 1)
			{
				Plugin.Print("Uso: ban_add <steamid64> [apelido]");
				return;
			}
			string steamId = args[0].Trim();
			string alias = ((args.Length > 1) ? string.Join(" ", args.Skip(1)).Trim() : string.Empty);
			Plugin.ExecuteAdd("banlist", steamId, alias);
		}
	}
	internal sealed class WlRemoveCommand : ConsoleCommand
	{
		public override string Name => "wl_remove";

		public override string Help => "wl_remove <steamid64> - remove da whitelist";

		public override void Run(string[] args)
		{
			if (args == null || args.Length < 1)
			{
				Plugin.Print("Uso: wl_remove <steamid64>");
			}
			else
			{
				Plugin.ExecuteRemove("whitelist", args[0].Trim());
			}
		}
	}
	internal sealed class BanRemoveCommand : ConsoleCommand
	{
		public override string Name => "ban_remove";

		public override string Help => "ban_remove <steamid64> - remove da banlist";

		public override void Run(string[] args)
		{
			if (args == null || args.Length < 1)
			{
				Plugin.Print("Uso: ban_remove <steamid64>");
			}
			else
			{
				Plugin.ExecuteRemove("banlist", args[0].Trim());
			}
		}
	}
	internal sealed class AdmAddCommand : ConsoleCommand
	{
		public override string Name => "adm_add";

		public override string Help => "adm_add <steamid64> [apelido] - adiciona na adminlist";

		public override void Run(string[] args)
		{
			if (args == null || args.Length < 1)
			{
				Plugin.Print("Uso: adm_add <steamid64> [apelido]");
				return;
			}
			string steamId = args[0].Trim();
			string alias = ((args.Length > 1) ? string.Join(" ", args.Skip(1)).Trim() : string.Empty);
			Plugin.ExecuteAdd("adminlist", steamId, alias);
		}
	}
	internal sealed class AdmRemoveCommand : ConsoleCommand
	{
		public override string Name => "adm_remove";

		public override string Help => "adm_remove <steamid64> - remove da adminlist";

		public override void Run(string[] args)
		{
			if (args == null || args.Length < 1)
			{
				Plugin.Print("Uso: adm_remove <steamid64>");
			}
			else
			{
				Plugin.ExecuteRemove("adminlist", args[0].Trim());
			}
		}
	}
	internal sealed class GlitnirPayCommand : ConsoleCommand
	{
		public override string Name => "glitnir_pay";

		public override string Help => "glitnir_pay <steamid64> <quantidade> - envia a moeda configurada para um jogador online";

		public override void Run(string[] args)
		{
			if (args == null || args.Length < 2)
			{
				Plugin.Print("Uso: glitnir_pay <steamid64> <quantidade>");
				return;
			}
			string steamId = args[0].Trim();
			if (!int.TryParse(args[1].Trim(), out var result))
			{
				Plugin.Print("Quantidade invalida.");
			}
			else
			{
				Plugin.ExecutePayment(steamId, result);
			}
		}
	}
	internal sealed class HudToggleCommand : ConsoleCommand
	{
		public override string Name => "glitnir_hud";

		public override string Help => "glitnir_hud - abre/fecha o HUD do mod";

		public override void Run(string[] args)
		{
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				Plugin.Instance.ToggleHud();
			}
		}
	}
	internal class GlitnirHud : MonoBehaviour
	{
		private enum HudTab
		{
			Whitelist,
			Adminlist,
			Banlist,
			OnlinePlayers,
			Payments
		}

		private enum HudAction
		{
			Add,
			Remove
		}

		private bool _visible;

		private Rect _windowRect = PathsConfig.GetHudWindowRect();

		private HudTab _currentTab = HudTab.Whitelist;

		private HudAction _currentAction = HudAction.Add;

		private string _steamIdInput = string.Empty;

		private string _aliasInput = string.Empty;

		private string _amountInput = "1";

		private string _serverMessage = "Pronto para receber um novo nome nos saloes de Glitnir.";

		private Vector2 _logScroll = Vector2.zero;

		private Vector2 _onlinePlayersScroll = Vector2.zero;

		private string _selectedOnlineName = string.Empty;

		private string _selectedOnlineSteamId = string.Empty;

		private readonly List<OnlinePlayerRecord> _onlinePlayers = new List<OnlinePlayerRecord>();

		private readonly List<string> _logEntries = new List<string>();

		private Texture2D _whiteTex;

		private Texture2D _bgMain;

		private Texture2D _bgPanel;

		private Texture2D _bgHeader;

		private Texture2D _bgAccent;

		private Texture2D _bgButton;

		private Texture2D _bgButtonActive;

		private Texture2D _bgDanger;

		private Texture2D _bgInput;

		private GUIStyle _windowStyle;

		private GUIStyle _titleStyle;

		private GUIStyle _subtitleStyle;

		private GUIStyle _sectionStyle;

		private GUIStyle _bodyStyle;

		private GUIStyle _smallStyle;

		private GUIStyle _inputStyle;

		private GUIStyle _buttonStyle;

		private GUIStyle _buttonActiveStyle;

		private GUIStyle _dangerButtonStyle;

		private GUIStyle _tabStyle;

		private GUIStyle _tabActiveStyle;

		private GUIStyle _messageStyle;

		private GUIStyle _logStyle;

		private GUIStyle _closeStyle;

		private bool _stylesReady;

		private GameObject _inputBlockerCanvasObject;

		private Component _inputBlockerCanvas;

		private Component _inputBlockerImage;

		private Component _inputBlockerRaycaster;

		internal bool IsVisible => _visible;

		private void Update()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut hudToggleKey = PathsConfig.HudToggleKey;
			if ((int)((KeyboardShortcut)(ref hudToggleKey)).MainKey != 0 && ((KeyboardShortcut)(ref hudToggleKey)).IsDown())
			{
				if ((Object)(object)Plugin.Instance != (Object)null)
				{
					Plugin.Instance.ToggleHud();
				}
				else
				{
					Toggle();
				}
			}
		}

		internal void ApplyConfig()
		{
			//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)
			_windowRect = PathsConfig.GetHudWindowRect();
		}

		internal void SetVisible(bool visible)
		{
			_visible = visible;
			UpdateInputBlocker();
			if (_visible && (Object)(object)Plugin.Instance != (Object)null)
			{
				Plugin.Instance.RequestOnlinePlayers();
			}
		}

		internal void Toggle()
		{
			SetVisible(!_visible);
		}

		internal void SetServerMessage(string message)
		{
			if (!string.IsNullOrWhiteSpace(message))
			{
				_serverMessage = message.Trim();
				_logEntries.Insert(0, DateTime.Now.ToString("HH:mm:ss") + "  " + _serverMessage);
				if (_logEntries.Count > 20)
				{
					_logEntries.RemoveAt(_logEntries.Count - 1);
				}
			}
		}

		internal void SetOnlinePlayers(List<OnlinePlayerRecord> players)
		{
			_onlinePlayers.Clear();
			if (players != null)
			{
				foreach (OnlinePlayerRecord player in players)
				{
					if (player != null)
					{
						_onlinePlayers.Add(new OnlinePlayerRecord
						{
							PlayerName = (player.PlayerName ?? string.Empty),
							SteamId = (player.SteamId ?? string.Empty)
						});
					}
				}
			}
			if (_onlinePlayers.Count == 1)
			{
				SelectOnlinePlayer(_onlinePlayers[0]);
			}
			else if (_onlinePlayers.Count > 0)
			{
				OnlinePlayerRecord onlinePlayerRecord = _onlinePlayers.FirstOrDefault((OnlinePlayerRecord p) => !string.IsNullOrWhiteSpace(p.PlayerName) && string.Equals(p.PlayerName, SafeLocalPlayerName(), StringComparison.OrdinalIgnoreCase));
				if (onlinePlayerRecord != null)
				{
					SelectOnlinePlayer(onlinePlayerRecord);
				}
			}
			else
			{
				_selectedOnlineName = string.Empty;
				_selectedOnlineSteamId = string.Empty;
			}
		}

		private string SafeLocalPlayerName()
		{
			try
			{
				if ((Object)(object)Player.m_localPlayer != (Object)null)
				{
					string playerName = Player.m_localPlayer.GetPlayerName();
					if (!string.IsNullOrWhiteSpace(playerName))
					{
						return playerName.Trim();
					}
				}
			}
			catch
			{
			}
			try
			{
				if ((Object)(object)Game.instance != (Object)null && Game.instance.GetPlayerProfile() != null)
				{
					string name = Game.instance.GetPlayerProfile().GetName();
					if (!string.IsNullOrWhiteSpace(name))
					{
						return name.Trim();
					}
				}
			}
			catch
			{
			}
			return string.Empty;
		}

		private void EnsureStyles()
		{
			//IL_0029: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Expected O, but got Unknown
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Expected O, but got Unknown
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Expected O, but got Unknown
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Expected O, but got Unknown
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Expected O, but got Unknown
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Expected O, but got Unknown
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Expected O, but got Unknown
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Expected O, but got Unknown
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Expected O, but got Unknown
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Expected O, but got Unknown
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Expected O, but got Unknown
			//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05aa: Expected O, but got Unknown
			//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Expected O, but got Unknown
			//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Expected O, but got Unknown
			//IL_0639: Unknown result type (might be due to invalid IL or missing references)
			//IL_0643: Expected O, but got Unknown
			//IL_0663: Unknown result type (might be due to invalid IL or missing references)
			//IL_0679: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Expected O, but got Unknown
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06da: Expected O, but got Unknown
			//IL_06fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_070c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Expected O, but got Unknown
			if (!_stylesReady)
			{
				_whiteTex = MakeTex(1, 1, new Color(1f, 1f, 1f, 1f));
				_bgMain = MakeTex(1, 1, new Color(0.06f, 0.07f, 0.09f, 0.97f));
				_bgPanel = MakeTex(1, 1, new Color(0.1f, 0.11f, 0.14f, 0.95f));
				_bgHeader = MakeTex(1, 1, new Color(0.17f, 0.12f, 0.05f, 0.96f));
				_bgAccent = MakeTex(1, 1, new Color(0.78f, 0.6f, 0.22f, 0.18f));
				_bgButton = MakeTex(1, 1, new Color(0.22f, 0.18f, 0.1f, 0.95f));
				_bgButtonActive = MakeTex(1, 1, new Color(0.55f, 0.42f, 0.14f, 0.95f));
				_bgDanger = MakeTex(1, 1, new Color(0.4f, 0.14f, 0.14f, 0.95f));
				_bgInput = MakeTex(1, 1, new Color(0.05f, 0.05f, 0.06f, 0.95f));
				_windowStyle = new GUIStyle(GUI.skin.box);
				_windowStyle.normal.background = _bgMain;
				_windowStyle.border = new RectOffset(1, 1, 1, 1);
				_titleStyle = new GUIStyle(GUI.skin.label);
				_titleStyle.fontSize = 26;
				_titleStyle.fontStyle = (FontStyle)1;
				_titleStyle.normal.textColor = new Color(1f, 0.88f, 0.56f, 1f);
				_subtitleStyle = new GUIStyle(GUI.skin.label);
				_subtitleStyle.fontSize = 12;
				_subtitleStyle.wordWrap = true;
				_subtitleStyle.normal.textColor = new Color(0.86f, 0.82f, 0.72f, 0.9f);
				_sectionStyle = new GUIStyle(GUI.skin.label);
				_sectionStyle.fontSize = 14;
				_sectionStyle.fontStyle = (FontStyle)1;
				_sectionStyle.normal.textColor = new Color(1f, 0.9f, 0.64f, 1f);
				_bodyStyle = new GUIStyle(GUI.skin.label);
				_bodyStyle.fontSize = 13;
				_bodyStyle.wordWrap = true;
				_bodyStyle.normal.textColor = new Color(0.92f, 0.92f, 0.92f, 0.95f);
				_smallStyle = new GUIStyle(GUI.skin.label);
				_smallStyle.fontSize = 11;
				_smallStyle.wordWrap = true;
				_smallStyle.normal.textColor = new Color(0.76f, 0.76f, 0.76f, 0.9f);
				_inputStyle = new GUIStyle(GUI.skin.textField);
				_inputStyle.normal.background = _bgInput;
				_inputStyle.hover.background = _bgInput;
				_inputStyle.active.background = _bgInput;
				_inputStyle.focused.background = _bgInput;
				_inputStyle.fontSize = 15;
				_inputStyle.padding = new RectOffset(12, 12, 10, 10);
				_inputStyle.normal.textColor = Color.white;
				_inputStyle.focused.textColor = Color.white;
				_buttonStyle = new GUIStyle(GUI.skin.button);
				_buttonStyle.normal.background = _bgButton;
				_buttonStyle.hover.background = _bgButtonActive;
				_buttonStyle.active.background = _bgButtonActive;
				_buttonStyle.fontSize = 14;
				_buttonStyle.fontStyle = (FontStyle)1;
				_buttonStyle.padding = new RectOffset(8, 8, 10, 10);
				_buttonStyle.normal.textColor = new Color(1f, 0.93f, 0.78f, 1f);
				_buttonActiveStyle = new GUIStyle(_buttonStyle);
				_buttonActiveStyle.normal.background = _bgButtonActive;
				_buttonActiveStyle.hover.background = _bgButtonActive;
				_buttonActiveStyle.active.background = _bgButtonActive;
				_dangerButtonStyle = new GUIStyle(_buttonStyle);
				_dangerButtonStyle.normal.background = _bgDanger;
				_dangerButtonStyle.hover.background = _bgDanger;
				_dangerButtonStyle.active.background = _bgDanger;
				_tabStyle = new GUIStyle(_buttonStyle);
				_tabStyle.fontSize = 13;
				_tabActiveStyle = new GUIStyle(_buttonActiveStyle);
				_tabActiveStyle.fontSize = 13;
				_messageStyle = new GUIStyle(GUI.skin.box);
				_messageStyle.normal.background = _bgAccent;
				_messageStyle.alignment = (TextAnchor)3;
				_messageStyle.fontSize = 13;
				_messageStyle.wordWrap = true;
				_messageStyle.padding = new RectOffset(14, 14, 10, 10);
				_messageStyle.normal.textColor = new Color(1f, 0.94f, 0.8f, 1f);
				_logStyle = new GUIStyle(GUI.skin.box);
				_logStyle.normal.background = _bgInput;
				_logStyle.alignment = (TextAnchor)0;
				_logStyle.fontSize = 12;
				_logStyle.wordWrap = true;
				_logStyle.padding = new RectOffset(10, 10, 10, 10);
				_logStyle.normal.textColor = new Color(0.88f, 0.88f, 0.88f, 1f);
				_closeStyle = new GUIStyle(_dangerButtonStyle);
				_closeStyle.alignment = (TextAnchor)4;
				_closeStyle.fontSize = 14;
				_stylesReady = true;
			}
		}

		private void OnGUI()
		{
			//IL_0031: 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_0052: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			UpdateInputBlocker();
			if (_visible)
			{
				EnsureStyles();
				GUI.depth = -1000;
				_windowRect = GUI.ModalWindow(818181, _windowRect, new WindowFunction(DrawWindow), string.Empty, _windowStyle);
				GUI.FocusWindow(818181);
				ConsumeHudEvents();
			}
		}

		private void UpdateInputBlocker()
		{
			if (_visible)
			{
				EnsureInputBlocker();
				if ((Object)(object)_inputBlockerCanvasObject != (Object)null && !_inputBlockerCanvasObject.activeSelf)
				{
					_inputBlockerCanvasObject.SetActive(true);
				}
				ClearSelectedGameObjectOnEventSystem();
			}
			else if ((Object)(object)_inputBlockerCanvasObject != (Object)null && _inputBlockerCanvasObject.activeSelf)
			{
				_inputBlockerCanvasObject.SetActive(false);
			}
		}

		private void EnsureInputBlocker()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_inputBlockerCanvasObject != (Object)null)
			{
				return;
			}
			_inputBlockerCanvasObject = new GameObject("GlitnirHudInputBlocker");
			Object.DontDestroyOnLoad((Object)(object)_inputBlockerCanvasObject);
			Type type = FindLoadedType("UnityEngine.Canvas");
			if (!(type == null))
			{
				_inputBlockerCanvas = _inputBlockerCanvasObject.AddComponent(type);
				TrySetProperty(_inputBlockerCanvas, "renderMode", "ScreenSpaceOverlay");
				TrySetProperty(_inputBlockerCanvas, "sortingOrder", 32000);
				Type type2 = FindLoadedType("UnityEngine.UI.GraphicRaycaster");
				if (type2 != null)
				{
					_inputBlockerRaycaster = _inputBlockerCanvasObject.AddComponent(type2);
				}
				GameObject val = new GameObject("Blocker");
				val.transform.SetParent(_inputBlockerCanvasObject.transform, false);
				RectTransform val2 = val.AddComponent<RectTransform>();
				val2.anchorMin = Vector2.zero;
				val2.anchorMax = Vector2.one;
				val2.offsetMin = Vector2.zero;
				val2.offsetMax = Vector2.zero;
				Type type3 = FindLoadedType("UnityEngine.UI.Image");
				if (type3 != null)
				{
					_inputBlockerImage = val.AddComponent(type3);
					TrySetProperty(_inputBlockerImage, "color", (object)new Color(0f, 0f, 0f, 0.001f));
					TrySetProperty(_inputBlockerImage, "raycastTarget", true);
				}
			}
		}

		private void ConsumeHudEvents()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_003b: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Invalid comparison between Unknown and I4
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Invalid comparison between Unknown and I4
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			Event current = Event.current;
			if (current != null)
			{
				Vector2 mousePosition = current.mousePosition;
				bool flag = ((Rect)(ref _windowRect)).Contains(mousePosition);
				if (flag)
				{
					ClearSelectedGameObjectOnEventSystem();
				}
				EventType type = current.type;
				EventType val = type;
				if (((int)val <= 3 || (int)val == 6 || (int)val == 16) && flag)
				{
					current.Use();
				}
			}
		}

		private static Type FindLoadedType(string fullName)
		{
			try
			{
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					if (!(assembly == null))
					{
						Type type = assembly.GetType(fullName, throwOnError: false);
						if (type != null)
						{
							return type;
						}
					}
				}
			}
			catch
			{
			}
			return null;
		}

		private static void TrySetProperty(object target, string propertyName, object value)
		{
			if (target == null || string.IsNullOrWhiteSpace(propertyName))
			{
				return;
			}
			try
			{
				PropertyInfo property = target.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public);
				if (!(property == null) && property.CanWrite)
				{
					object obj = value;
					if (obj != null && property.PropertyType.IsEnum && obj is string value2)
					{
						obj = Enum.Parse(property.PropertyType, value2);
					}
					else if (obj != null && !property.PropertyType.IsAssignableFrom(obj.GetType()))
					{
						obj = Convert.ChangeType(obj, property.PropertyType);
					}
					property.SetValue(target, obj, null);
				}
			}
			catch
			{
			}
		}

		private static void ClearSelectedGameObjectOnEventSystem()
		{
			try
			{
				Type type = FindLoadedType("UnityEngine.EventSystems.EventSystem");
				if (type == null)
				{
					return;
				}
				PropertyInfo property = type.GetProperty("current", BindingFlags.Static | BindingFlags.Public);
				object obj = ((property != null) ? property.GetValue(null, null) : null);
				if (obj != null)
				{
					MethodInfo method = type.GetMethod("SetSelectedGameObject", new Type[1] { typeof(GameObject) });
					if (method != null)
					{
						method.Invoke(obj, new object[1]);
					}
				}
			}
			catch
			{
			}
		}

		private void DrawWindow(int id)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			float width = ((Rect)(ref _windowRect)).width;
			float height = ((Rect)(ref _windowRect)).height;
			DrawBox(new Rect(0f, 0f, width, 92f), _bgHeader, Color.white);
			DrawAccentLine(new Rect(0f, 92f, width, 3f));
			GUI.Label(new Rect(24f, 18f, 380f, 34f), "GLITNIR LISTS", _titleStyle);
			GUI.Label(new Rect(24f, 52f, 620f, 24f), "Painel nordico para listas e pagamentos de moedas Glitnir", _subtitleStyle);
			if (GUI.Button(new Rect(width - 72f, 20f, 48f, 34f), "X", _closeStyle))
			{
				SetVisible(visible: false);
				UpdateInputBlocker();
			}
			DrawTabBar(width);
			DrawStatusCard(width);
			DrawLeftPanel();
			DrawRightPanel(width);
			DrawBottomLog(width, height);
			GUI.DragWindow(new Rect(0f, 0f, width - 80f, 92f));
		}

		private void DrawTabBar(float width)
		{
			//IL_0021: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			float num = 24f;
			float num2 = 108f;
			float num3 = 122f;
			float num4 = 8f;
			if (GUI.Button(new Rect(num, num2, num3, 38f), "Whitelist", (_currentTab == HudTab.Whitelist) ? _tabActiveStyle : _tabStyle))
			{
				_currentTab = HudTab.Whitelist;
			}
			if (GUI.Button(new Rect(num + (num3 + num4) * 1f, num2, num3, 38f), "Admin List", (_currentTab == HudTab.Adminlist) ? _tabActiveStyle : _tabStyle))
			{
				_currentTab = HudTab.Adminlist;
			}
			if (GUI.Button(new Rect(num + (num3 + num4) * 2f, num2, num3, 38f), "Ban List", (_currentTab == HudTab.Banlist) ? _tabActiveStyle : _tabStyle))
			{
				_currentTab = HudTab.Banlist;
			}
			if (GUI.Button(new Rect(num + (num3 + num4) * 3f, num2, num3, 38f), "Online", (_currentTab == HudTab.OnlinePlayers) ? _tabActiveStyle : _tabStyle))
			{
				_currentTab = HudTab.OnlinePlayers;
				if ((Object)(object)Plugin.Instance != (Object)null)
				{
					Plugin.Instance.RequestOnlinePlayers();
				}
			}
			if (GUI.Button(new Rect(num + (num3 + num4) * 4f, num2, num3, 38f), "Pagamentos", (_currentTab == HudTab.Payments) ? _tabActiveStyle : _tabStyle))
			{
				_currentTab = HudTab.Payments;
				_currentAction = HudAction.Add;
			}
		}

		private void DrawStatusCard(float width)
		{
			//IL_001f: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(24f, 162f, width - 48f, 74f);
			DrawPanel(rect);
			GUI.Label(new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).y + 12f, 200f, 24f), GetCardTitle(), _sectionStyle);
			GUI.Label(new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).y + 36f, ((Rect)(ref rect)).width - 32f, 24f), GetCardDescription(), _bodyStyle);
		}

		private void DrawLeftPanel()
		{
			//IL_001d: 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_009d: 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)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(24f, 254f, 390f, 230f);
			DrawPanel(val);
			if (_currentTab == HudTab.OnlinePlayers)
			{
				DrawOnlinePlayersPanel(val);
				return;
			}
			GUI.Label(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 14f, 220f, 24f), "Entrada de dados", _sectionStyle);
			GUI.Label(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 42f, 340f, 22f), "SteamID64 com 17 digitos", _smallStyle);
			string value = GUI.TextField(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 66f, ((Rect)(ref val)).width - 32f, 40f), _steamIdInput, 17, _inputStyle);
			_steamIdInput = FilterDigits(value, 17);
			if (_currentTab == HudTab.Payments)
			{
				GUI.Label(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 114f, 340f, 22f), "Quantidade de GlitnirCoin", _smallStyle);
				string value2 = GUI.TextField(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 138f, ((Rect)(ref val)).width - 32f, 40f), _amountInput ?? "1", 9, _inputStyle);
				_amountInput = FilterDigits(value2, 9);
			}
			else
			{
				GUI.Label(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 114f, 340f, 22f), "Apelido / observacao", _smallStyle);
				_aliasInput = GUI.TextField(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 138f, ((Rect)(ref val)).width - 32f, 40f), _aliasInput ?? string.Empty, 64, _inputStyle);
			}
		}

		private void DrawRightPanel(float width)
		{
			//IL_001f: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(432f, 254f, width - 456f, 230f);
			DrawPanel(val);
			if (_currentTab == HudTab.OnlinePlayers)
			{
				DrawOnlinePlayerActionsPanel(val);
				return;
			}
			GUI.Label(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 14f, 240f, 24f), "Comandos do salao", _sectionStyle);
			if (_currentTab == HudTab.Payments)
			{
				GUI.Label(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 42f, ((Rect)(ref val)).width - 32f, 40f), "Envia o prefab " + PathsConfig.CoinPrefabName + " para um jogador online mantendo a mesma validacao de ADM do mod.", _smallStyle);
				if (GUI.Button(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 138f, ((Rect)(ref val)).width - 32f, 40f), GetActionButtonText(), _buttonActiveStyle))
				{
					SubmitCurrentAction();
				}
			}
			else
			{
				GUI.Label(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 42f, ((Rect)(ref val)).width - 32f, 40f), "A checagem de ADM continua a mesma do codigo anterior. Agora o HUD tambem adiciona e remove.", _smallStyle);
				float num = (((Rect)(ref val)).width - 40f) * 0.5f;
				if (GUI.Button(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 92f, num, 36f), "Modo: ADICIONAR", (_currentAction == HudAction.Add) ? _buttonActiveStyle : _buttonStyle))
				{
					_currentAction = HudAction.Add;
				}
				if (GUI.Button(new Rect(((Rect)(ref val)).x + 24f + num, ((Rect)(ref val)).y + 92f, num, 36f), "Modo: REMOVER", (_currentAction == HudAction.Remove) ? _dangerButtonStyle : _buttonStyle))
				{
					_currentAction = HudAction.Remove;
				}
				if (GUI.Button(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 138f, ((Rect)(ref val)).width - 32f, 40f), GetActionButtonText(), GetPrimaryActionStyle()))
				{
					SubmitCurrentAction();
				}
			}
			float num2 = (((Rect)(ref val)).width - 40f) * 0.5f;
			if (GUI.Button(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 184f, num2, 40f), "Limpar campos", _buttonStyle))
			{
				_steamIdInput = string.Empty;
				_aliasInput = string.Empty;
				_amountInput = "1";
				SetServerMessage("Campos limpos.");
			}
			if (GUI.Button(new Rect(((Rect)(ref val)).x + 24f + num2, ((Rect)(ref val)).y + 184f, num2, 40f), "Fechar HUD", _dangerButtonStyle))
			{
				SetVisible(visible: false);
				UpdateInputBlocker();
			}
		}

		private void DrawOnlinePlayersPanel(Rect panel)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			List<OnlinePlayerRecord> onlinePlayers = _onlinePlayers;
			GUI.Label(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref panel)).y + 14f, 240f, 24f), "Jogadores online", _sectionStyle);
			GUI.Label(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref panel)).y + 42f, ((Rect)(ref panel)).width - 32f, 22f), "Clique em um nome para preencher o SteamID no painel.", _smallStyle);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref panel)).x + 16f, ((Rect)(ref panel)).y + 70f, ((Rect)(ref panel)).width - 32f, ((Rect)(ref panel)).height - 86f);
			float num = 54f;
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(0f, 0f, ((Rect)(ref val)).width - 18f, Mathf.Max(((Rect)(ref val)).height, (float)onlinePlayers.Count * num));
			_onlinePlayersScroll = GUI.BeginScrollView(val, _onlinePlayersScroll, val2, false, true);
			if (onlinePlayers.Count <= 0)
			{
				GUI.Box(new Rect(0f, 0f, ((Rect)(ref val2)).width, 44f), "Nenhum jogador online detectado.", _logStyle);
			}
			else
			{
				Rect val3 = default(Rect);
				for (int i = 0; i < onlinePlayers.Count; i++)
				{
					OnlinePlayerRecord onlinePlayerRecord = onlinePlayers[i];
					((Rect)(ref val3))..ctor(0f, (float)i * num, ((Rect)(ref val2)).width, 48f);
					bool flag = !string.IsNullOrWhiteSpace(_selectedOnlineSteamId) && string.Equals(_selectedOnlineSteamId, onlinePlayerRecord.SteamId, StringComparison.OrdinalIgnoreCase);
					DrawBox(val3, flag ? _bgAccent : _bgInput, Color.white);
					DrawOutline(val3, flag ? new Color(1f, 0.86f, 0.5f, 0.78f) : new Color(0.72f, 0.58f, 0.24f, 0.28f));
					if (GUI.Button(val3, GUIContent.none, GUIStyle.none))
					{
						SelectOnlinePlayer(onlinePlayerRecord);
					}
					GUI.Label(new Rect(((Rect)(ref val3)).x + 10f, ((Rect)(ref val3)).y + 4f, ((Rect)(ref val3)).width - 20f, 20f), onlinePlayerRecord.PlayerName, _sectionStyle);
					GUI.Label(new Rect(((Rect)(ref val3)).x + 10f, ((Rect)(ref val3)).y + 24f, ((Rect)(ref val3)).width - 20f, 18f), onlinePlayerRecord.SteamId, _smallStyle);
				}
			}
			GUI.EndScrollView();
		}

		private void DrawOnlinePlayerActionsPanel(Rect panel)
		{
			//IL_0025: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			GUI.Label(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref panel)).y + 14f, 260f, 24f), "Selecao e copia", _sectionStyle);
			if (GUI.Button(new Rect(((Rect)(ref panel)).x + ((Rect)(ref panel)).width - 156f, ((Rect)(ref panel)).y + 12f, 140f, 32f), "Atualizar lista", _buttonStyle) && (Object)(object)Plugin.Instance != (Object)null)
			{
				Plugin.Instance.RequestOnlinePlayers();
			}
			if (string.IsNullOrWhiteSpace(_selectedOnlineSteamId))
			{
				GUI.Label(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref panel)).y + 46f, ((Rect)(ref panel)).width - 32f, 44f), "Selecione um jogador online no painel da esquerda para ver o nome em jogo e copiar o SteamID.", _smallStyle);
				return;
			}
			GUI.Label(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref panel)).y + 52f, 220f, 22f), "Nome em jogo", _smallStyle);
			GUI.Box(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref panel)).y + 76f, ((Rect)(ref panel)).width - 32f, 32f), _selectedOnlineName, _messageStyle);
			GUI.Label(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref panel)).y + 118f, 220f, 22f), "SteamID64", _smallStyle);
			GUI.TextField(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref panel)).y + 142f, ((Rect)(ref panel)).width - 32f, 38f), _selectedOnlineSteamId, 17, _inputStyle);
			float num = (((Rect)(ref panel)).width - 40f) * 0.5f;
			if (GUI.Button(new Rect(((Rect)(ref panel)).x + 16f, ((Rect)(ref panel)).y + 188f, num, 34f), "Usar no campo", _buttonActiveStyle))
			{
				_steamIdInput = _selectedOnlineSteamId;
				if (!string.IsNullOrWhiteSpace(_selectedOnlineName))
				{
					_aliasInput = _selectedOnlineName;
				}
				SetServerMessage("SteamID carregado no campo principal: " + _selectedOnlineSteamId);
			}
			if (GUI.Button(new Rect(((Rect)(ref panel)).x + 24f + num, ((Rect)(ref panel)).y + 188f, num, 34f), "Copiar SteamID", _buttonStyle))
			{
				GUIUtility.systemCopyBuffer = _selectedOnlineSteamId ?? string.Empty;
				SetServerMessage("SteamID copiado: " + _selectedOnlineSteamId);
			}
		}

		private void SelectOnlinePlayer(OnlinePlayerRecord player)
		{
			if (player != null)
			{
				_selectedOnlineName = player.PlayerName ?? string.Empty;
				_selectedOnlineSteamId = player.SteamId ?? string.Empty;
				_steamIdInput = _selectedOnlineSteamId;
				if (!string.IsNullOrWhiteSpace(_selectedOnlineName))
				{
					_aliasInput = _selectedOnlineName;
				}
				SetServerMessage("Jogador selecionado: " + _selectedOnlineName + " - " + _selectedOnlineSteamId);
			}
		}

		private void DrawBottomLog(float width, float height)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			float num = 500f;
			float num2 = 24f;
			float num3 = Mathf.Max(74f, height - num - num2);
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(24f, num, width - 48f, num3);
			DrawPanel(rect);
			GUI.Label(new Rect(((Rect)(ref rect)).x + 16f, ((Rect)(ref rect)).y + 12f, 240f, 24f), "Resposta do servidor", _sectionStyle);
			float num4 = ((Rect)(ref rect)).y + 42f;
			float num5 = ((Rect)(ref rect)).yMax - 12f;
			float num6 = Mathf.Max(28f, num5 - num4);
			bool flag = num6 < 84f;
			float num7 = (flag ? num6 : 38f);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref rect)).x + 16f, num4, ((Rect)(ref rect)).width - 32f, num7);
			GUI.Box(val, _serverMessage, _messageStyle);
			if (flag)
			{
				return;
			}
			float num8 = ((Rect)(ref val)).yMax + 8f;
			float num9 = num5 - num8;
			if (!(num9 < 28f))
			{
				Rect rect2 = default(Rect);
				((Rect)(ref rect2))..ctor(((Rect)(ref rect)).x + 16f, num8, ((Rect)(ref rect)).width - 32f, num9);
				DrawBox(rect2, _bgInput, new Color(1f, 1f, 1f, 0.96f));
				DrawOutline(rect2, new Color(0.72f, 0.58f, 0.24f, 0.22f));
				float num10 = 24f;
				float num11 = 4f;
				int num12 = Mathf.Max(1, Mathf.FloorToInt((((Rect)(ref rect2)).height - 8f) / (num10 + num11)));
				int num13 = Mathf.Min(num12, _logEntries.Count);
				Rect val2 = default(Rect);
				for (int i = 0; i < num13; i++)
				{
					((Rect)(ref val2))..ctor(((Rect)(ref rect2)).x + 6f, ((Rect)(ref rect2)).y + 6f + (float)i * (num10 + num11), ((Rect)(ref rect2)).width - 12f, num10);
					DrawBox(val2, _bgAccent, new Color(1f, 1f, 1f, (i == 0) ? 0.9f : 0.55f));
					GUI.Box(val2, _logEntries[i], _logStyle);
				}
			}
		}

		private void SubmitCurrentAction()
		{
			if (string.IsNullOrWhiteSpace(_steamIdInput))
			{
				SetServerMessage("Informe um SteamID valido antes de continuar.");
			}
			else if (_currentTab == HudTab.Payments)
			{
				if (!TryGetPaymentAmount(out var amount))
				{
					SetServerMessage("Informe uma quantidade valida maior que zero.");
				}
				else
				{
					Plugin.ExecutePayment(_steamIdInput, amount);
				}
			}
			else if (_currentAction == HudAction.Remove)
			{
				Plugin.ExecuteRemove(GetCurrentListType(), _steamIdInput);
			}
			else
			{
				Plugin.ExecuteAdd(GetCurrentListType(), _steamIdInput, _aliasInput);
			}
		}

		private GUIStyle GetPrimaryActionStyle()
		{
			if (_currentTab == HudTab.Payments)
			{
				return _buttonActiveStyle;
			}
			return (_currentAction == HudAction.Remove) ? _dangerButtonStyle : _buttonActiveStyle;
		}

		private string GetCurrentListType()
		{
			return _currentTab switch
			{
				HudTab.Adminlist => "adminlist", 
				HudTab.Banlist => "banlist", 
				_ => "whitelist", 
			};
		}

		private bool TryGetPaymentAmount(out int amount)
		{
			if (string.IsNullOrWhiteSpace(_amountInput))
			{
				amount = 0;
				return false;
			}
			if (!int.TryParse(_amountInput.Trim(), out amount))
			{
				amount = 0;
				return false;
			}
			return amount > 0;
		}

		private string GetActionButtonText()
		{
			bool flag = _currentAction == HudAction.Remove;
			return _currentTab switch
			{
				HudTab.Payments => "Enviar moedas GLITNIR", 
				HudTab.Adminlist => flag ? "Remover da ADMIN LIST" : "Adicionar na ADMIN LIST", 
				HudTab.Banlist => flag ? "Remover da BAN LIST" : "Adicionar na BAN LIST", 
				_ => flag ? "Remover da WHITELIST" : "Adicionar na WHITELIST", 
			};
		}

		private string GetCardTitle()
		{
			return _currentTab switch
			{
				HudTab.Payments => "Pagamentos de moedas Glitnir", 
				HudTab.Adminlist => (_currentAction == HudAction.Remove) ? "Remocao dos guardioes" : "Lista dos guardioes", 
				HudTab.Banlist => (_currentAction == HudAction.Remove) ? "Perdao dos banidos" : "Lista dos banidos", 
				_ => (_currentAction == HudAction.Remove) ? "Portoes de saida" : "Portoes de Glitnir", 
			};
		}

		private string GetCardDescription()
		{
			bool flag = _currentAction == HudAction.Remove;
			return _currentTab switch
			{
				HudTab.Payments => "Use o prefab GlitnirCoin para pagamentos. O alvo deve estar online e com espaco no inventario.", 
				HudTab.Adminlist => flag ? "Remove administradores mantendo a mesma validacao RPC e a mesma leitura da adminlist." : "Somente os escolhidos poderao escrever os nomes na pedra dos administradores.", 
				HudTab.Banlist => flag ? "Retire um nome da banlist quando a pena tiver chegado ao fim." : "Aqui caem os nomes que nao mais cruzarao os portoes do reino.", 
				_ => flag ? "Remova jogadores permitidos sem alterar a logica de ADM que ja funcionava." : "Registre novos jogadores permitidos usando a mesma seguranca RPC do mod original.", 
			};
		}

		private void DrawPanel(Rect rect)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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)
			DrawBox(rect, _bgPanel, Color.white);
			DrawOutline(rect, new Color(0.77f, 0.61f, 0.26f, 0.45f));
			DrawAccentLine(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 2f));
		}

		private void DrawOutline(Rect rect, Color color)
		{
			//IL_0001: 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)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = color;
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), (Texture)(object)_whiteTex);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 1f, ((Rect)(ref rect)).width, 1f), (Texture)(object)_whiteTex);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)_whiteTex);
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - 1f, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)_whiteTex);
			GUI.color = Color.white;
		}

		private void DrawAccentLine(Rect rect)
		{
			//IL_0015: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = new Color(0.9f, 0.72f, 0.28f, 0.9f);
			GUI.DrawTexture(rect, (Texture)(object)_whiteTex);
			GUI.color = Color.white;
		}

		private void DrawBox(Rect rect, Texture2D texture, Color color)
		{
			//IL_0001: 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)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = color;
			GUI.DrawTexture(rect, (Texture)(object)texture, (ScaleMode)0);
			GUI.color = Color.white;
		}

		private Texture2D MakeTex(int width, int height, Color color)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = color;
			}
			Texture2D val = new Texture2D(width, height, (TextureFormat)5, false);
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private void OnDestroy()
		{
			if ((Object)(object)_inputBlockerCanvasObject != (Object)null)
			{
				Object.Destroy((Object)(object)_inputBlockerCanvasObject);
				_inputBlockerCanvasObject = null;
				_inputBlockerCanvas = null;
				_inputBlockerImage = null;
				_inputBlockerRaycaster = null;
			}
		}

		private string FilterDigits(string value, int maxLen)
		{
			if (string.IsNullOrEmpty(value))
			{
				return string.Empty;
			}
			char[] value2 = value.Where(char.IsDigit).Take(maxLen).ToArray();
			return new string(value2);
		}
	}
	internal static class AdminUtils
	{
		public static bool TryAuthorizeLocalHudOpen(out string message)
		{
			return TryAuthorizeHostLocalHudOpen(out message);
		}

		public static bool TryAuthorizeHostLocalHudOpen(out string message)
		{
			message = string.Empty;
			try
			{
				string text = ResolveHostLocalSteamId();
				if (string.IsNullOrWhiteSpace(text))
				{
					message = "[GlitnirLists] HUD bloqueado. Nao foi possivel resolver a SteamID local do host.";
					return false;
				}
				return IsSteamIdAllowedToOpenHud(text, out message);
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("Erro ao validar HUD local do host: " + ex));
				}
				message = "[GlitnirLists] HUD bloqueado. Falha ao validar permissoes locais do host.";
				return false;
			}
		}

		public static bool TryAuthorizeSenderHudOpen(long sender, out string message)
		{
			message = string.Empty;
			try
			{
				string text = ResolveHostIdFromSender(sender);
				if (string.IsNullOrWhiteSpace(text))
				{
					message = "[GlitnirLists] HUD bloqueado. Nao foi possivel resolver sua SteamID no servidor.";
					return false;
				}
				return IsSteamIdAllowedToOpenHud(text, out message);
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("Erro ao validar HUD do sender: " + ex));
				}
				message = "[GlitnirLists] HUD bloqueado. Falha ao validar permissoes no servidor.";
				return false;
			}
		}

		public static bool IsSenderAdmin(long sender)
		{
			try
			{
				string text = ResolveHostIdFromSender(sender);
				if (string.IsNullOrWhiteSpace(text))
				{
					Plugin.Print("[GlitnirLists] nao foi possivel resolver o hostId do sender: " + sender);
					return false;
				}
				bool result = IsHostIdInAdminList(text);
				Plugin.Print("[GlitnirLists] sender=" + sender + " hostId=" + text + " admin=" + result);
				return result;
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("Erro ao validar admin: " + ex));
				}
				return false;
			}
		}

		private static string ResolveHostIdFromSender(long sender)
		{
			//IL_005c: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)ZNet.instance == (Object)null)
				{
					return string.Empty;
				}
				string value = sender + ":";
				string text = string.Empty;
				List<PlayerInfo> playerList = ZNet.instance.GetPlayerList();
				if (playerList != null)
				{
					foreach (PlayerInfo item in playerList)
					{
						ZDOID characterID = item.m_characterID;
						string text2 = ((object)(ZDOID)(ref characterID)).ToString();
						if (!string.IsNullOrWhiteSpace(text2) && text2.StartsWith(value, StringComparison.Ordinal))
						{
							string playerInfoHost = GetPlayerInfoHost(item);
							if (!string.IsNullOrWhiteSpace(playerInfoHost))
							{
								return Validators.NormalizeSteam64(playerInfoHost);
							}
							text = GetPlayerInfoName(item);
							break;
						}
					}
				}
				foreach (ZNetPeer peer in ZNet.instance.GetPeers())
				{
					if (peer == null || peer.m_socket == null)
					{
						continue;
					}
					try
					{
						if (string.IsNullOrWhiteSpace(text))
						{
							continue;
						}
						string peerName = GetPeerName(peer);
						if (!string.IsNullOrWhiteSpace(peerName) && string.Equals(peerName, text, StringComparison.OrdinalIgnoreCase))
						{
							string hostName = peer.m_socket.GetHostName();
							if (!string.IsNullOrWhiteSpace(hostName))
							{
								return Validators.NormalizeSteam64(hostName);
							}
						}
					}
					catch
					{
					}
				}
			}
			catch (Exception ex)
			{
				if (Plugin.Log != null)
				{
					Plugin.Log.LogError((object)("Erro ao resolver hostId do sender: " + ex));
				}
			}
			return string.Empty;
		}

		private static string GetPlayerInfoHost(PlayerInfo player)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Type type = ((object)player).GetType();
				string[] array = new string[6] { "m_host", "m_hostName", "host", "hostName", "Host", "HostName" };
				string[] array2 = array;
				foreach (string name in array2)
				{
					FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null)
					{
						object value = field.GetValue(player);
						if (value != null)
						{
							string text = value.ToString();
							if (!string.IsNullOrWhiteSpace(text))
							{
								return text;
							}
						}
					}
					PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (!(property != null))
					{
						continue;
					}
					object value2 = property.GetValue(player, null);
					if (value2 != null)
					{
						string text2 = value2.ToString();
						if (!string.IsNullOrWhiteSpace(text2))
						{
							return text2;
						}
					}
				}
			}
			catch
			{
			}
			return string.Empty;
		}

		private static string GetPlayerInfoName(PlayerInfo player)
		{
			//IL_0002: 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)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Type type = ((object)player).GetType();
				string[] array = new string[3] { "m_name", "name", "Name" };
				string[] array2 = array;
				foreach (string name in array2)
				{
					FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null)
					{
						object value = field.GetValue(player);
						if (value != null)
						{
							string text = value.ToString();
							if (!string.IsNullOrWhiteSpace(text))
							{
								return text;
							}
						}
					}
					PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (!(property != null))
					{
						continue;
					}
					object value2 = property.GetValue(player, null);
					if (value2 != null)
					{
						string text2 = value2.ToString();
						if (!string.IsNullOrWhiteSpace(text2))
						{
							return text2;
						}
					}
				}
			}
			catch
			{
			}
			return string.Empty;
		}

		private static string GetPeerName(ZNetPeer peer)
		{
			try
			{
				Type type = ((object)peer).GetType();
				string[] array = new string[5] { "m_playerName", "m_name", "playerName", "name", "Name" };
				string[] array2 = array;
				foreach (string name in array2)
				{
					FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null)
					{
						object value = field.GetValue(peer);
						if (value != null)
						{
							string text = value.ToString();
							if (!string.IsNullOrWhiteSpace(text))
							{
								return text;
							}
						}
					}
					PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (!(property != null))
					{
						continue;
					}
					object value2 = property.GetValue(peer, null);
					if (value2 != null)
					{
						string text2 = value2.ToString();
						if (!string.IsNullOrWhiteSpace(text2))
						{
							return text2;
						}
					}
				}
			}
			catch
			{
			}
			return string.Empty;
		}

		private static bool IsSteamIdAllowedToOpenHud(string hostId, out string message)
		{
			bool flag = IsHostIdInAdminList(hostId);
			bool flag2 = IsHostIdInPermittedList(hostId);
			if (flag && flag2)
			{
				message = "[GlitnirLists] Permissao confirmada. Abrindo HUD.";
				return true;
			}
			if (!flag && !flag2)
			{
				message = "[GlitnirLists] HUD bloqueado. Seu SteamID nao esta na adminlist nem na whitelist.";
			}
			else if (!flag)
			{
				message = "[GlitnirLists] HUD bloqueado. Seu SteamID nao esta na adminlist.";
			}
			else
			{
				message = "[GlitnirLists] HUD bloqueado. Seu SteamID nao esta na whitelist.";
			}
			return false;
		}

		private static string ResolveSteamIdFromConfiguredFilesByLocalName()
		{
			string text = string.Empty;
			try
			{
				if ((Object)(object)Player.m_localPlayer != (Object)null)
				{
					text = Player.m_localPlayer.GetPlayerName();
				}
			}
			catch
			{
			}
			if (string.IsNullOrWhiteSpace(text))
			{
				try
				{
					if ((Object)(object)Game.instance != (Object)null && Game.instance.GetPlayerProfile() != null)
					{
						text = Game.instance.GetPlayerProfile().GetName();
					}
				}
				catch
				{
				}
			}
			text = (text ?? string.Empty).Trim();
			if (string.IsNullOrWhiteSpace(text))
			{
				return string.Empty;
			}
			try
			{
				string adminNotesFile = PathsConfig.AdminNotesFile;
				if (File.Exists(adminNotesFile))
				{
					string[] array = File.ReadAllLines(adminNotesFile);
					foreach (string text2 in array)
					{
						string text3 = (text2 ?? string.Empty).Trim();
						if (!string.IsNullOrWhiteSpace(text3) && !text3.StartsWith("//"))
						{
							string[] array2 = text3.Split(new char[1] { '|' }, 2);
							string text4 = ((array2.Length != 0) ? Validators.NormalizeSteam64(array2[0]) : string.Empty);
							string text5 = ((array2.Length > 1) ? (array2[1] ?? string.Empty).Trim() : string.Empty);
							if (!string.IsNullOrWhiteSpace(text4) && !string.IsNullOrWhiteSpace(text5) && string.Equals(text5, text, StringComparison.OrdinalIgnoreCase))
							{
								return text4;
							}
						}
					}
				}
			}
			catch
			{
			}
			return string.Empty;
		}

		private static string ResolveHostLocalSteamId()
		{
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Type type = AccessTools.TypeByName("Steamworks.SteamUser");
				if (type != null)
				{
					MethodInfo method = type.GetMethod("GetSteamID", BindingFlags.Static | BindingFlags.Public);
					if (method != null)
					{
						object obj = method.Invoke(null, null);
						if (obj != null)
						{
							FieldInfo field = obj.GetType().GetField("m_SteamID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							if (field != null)
							{
								object value = field.GetValue(obj);
								if (value != null)
								{
									string text = value.ToString();
									if (Regex.IsMatch(text ?? string.Empty, "^\\d{17}$"))
									{
										return text;
									}
								}
							}
							string text2 = obj.ToString();
							if (Regex.IsMatch(text2 ?? string.Empty, "^\\d{17}$"))
							{
								return text2;
							}
						}
					}
				}
			}
			catch
			{
			}
			try
			{
				if ((Object)(object)ZNet.instance != (Object)null)
				{
					List<PlayerInfo> playerList = ZNet.instance.GetPlayerList();
					if (playerList != null)
					{
						foreach (PlayerInfo item in playerList)
						{
							string playerInfoHost = GetPlayerInfoHost(item);
							string text3 = Validators.NormalizeSteam64(playerInfoHost);
							if (!string.IsNullOrWhiteSpace(text3))
							{
								return text3;
							}
						}
					}
				}
			}
			catch
			{
			}
			return string.Empty;
		}

		private static bool IsHostIdInPermittedList(string hostId)
		{
			if (!File.Exists(PathsConfig.PermittedFile))
			{
				Plugin.Print("[GlitnirLists] permittedlist.txt nao encontrado: " + PathsConfig.PermittedFile);
				return false;
			}
			string[] array = File.ReadAllLines(PathsConfig.PermittedFile);
			foreach (string text in array)
			{
				string text2 = (text ?? string.Empty).Trim();
				if (string.IsNullOrWhiteSpace(text2) || text2.StartsWith("//"))
				{
					continue;
				}
				try
				{
					string a = Validators.NormalizeSteam64(text2);
					if (string.Equals(a, hostId, StringComparison.OrdinalIgnoreCase))
					{
						return true;
					}
				}
				catch
				{
				}
			}
			return false;
		}

		private static bool IsHostIdInAdminList(string hostId)
		{
			if (!File.Exists(PathsConfig.AdminFile))
			{
				Plugin.Print("[GlitnirLists] adminlist.txt nao encontrado: " + PathsConfig.AdminFile);
				return false;
			}
			string[] array = File.ReadAllLines(PathsConfig.AdminFile);
			foreach (string text in array)
			{
				string text2 = (text ?? string.Empty).Trim();
				if (string.IsNullOrWhiteSpace(text2) || text2.StartsWith("//"))
				{
					continue;
				}
				try
				{
					string a = Validators.NormalizeSteam64(text2);
					if (string.Equals(a, hostId, StringComparison.OrdinalIgnoreCase))
					{
						return true;
					}
				}
				catch
				{
				}
			}
			return false;
		}
	}
	internal sealed class OnlinePlayerRecord
	{
		public string PlayerName = string.Empty;

		public string SteamId = string.Empty;
	}
	internal static class OnlinePlayersDirectory
	{
		public static List<OnlinePlayerRecord> GetOnlinePlayers()
		{
			return BuildOnlinePlayersForServer();
		}

		public static List<OnlinePlayerRecord> BuildOnlinePlayersForServer()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, OnlinePlayerRecord> dictionary = new Dictionary<string, OnlinePlayerRecord>(StringComparer.OrdinalIgnoreCase);
			try
			{
				if ((Object)(object)ZNet.instance == (Object)null)
				{
					return new List<OnlinePlayerRecord>();
				}
				Dictionary<string, string> dictionary2 = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
				try
				{
					List<ZNetPeer> peers = ZNet.instance.GetPeers();
					if (peers != null)
					{
						foreach (ZNetPeer item in peers)
						{
							if (item != null)
							{
								string peerName = GetPeerName(item);
								string value = ReadPeerSteamId(item);
								if (!string.IsNullOrWhiteSpace(peerName) && !string.IsNullOrWhiteSpace(value))
								{
									dictionary2[peerName] = value;
								}
							}
						}
					}
				}
				catch
				{
				}
				try
				{
					List<PlayerInfo> playerList = ZNet.instance.GetPlayerList();
					if (playerList != null)
					{
						foreach (PlayerInfo item2 in playerList)
						{
							string playerInfoName = GetPlayerInfoName(item2);
							if (!string.IsNullOrWhiteSpace(playerInfoName))
							{
								string value2 = string.Empty;
								if (!dictionary2.TryGetValue(playerInfoName, out value2))
								{
									value2 = ExtractSteam64(GetPlayerInfoHost(item2));
								}
								if (!string.IsNullOrWhiteSpace(value2))
								{
									Merge(dictionary, playerInfoName, value2);
								}
							}
						}
					}
				}
				catch
				{
				}
				if (dictionary.Count == 0)
				{
					TryAddLocalFallback(dictionary);
				}
			}
			catch
			{
			}
			return dictionary.Values.OrderBy<OnlinePlayerRecord, string>((OnlinePlayerRecord p) => p.PlayerName ?? string.Empty, StringComparer.OrdinalIgnoreCase).ThenBy<OnlinePlayerRecord, string>((OnlinePlayerRecord p) => p.SteamId ?? string.Empty, StringComparer.OrdinalIgnoreCase).ToList();
		}

		private static void TryAddLocalFallback(Dictionary<string, OnlinePlayerRecord> bySteam)
		{
			try
			{
				string text = string.Empty;
				if ((Object)(object)Player.m_localPlayer != (Object)null)
				{
					text = Player.m_localPlayer.GetPlayerName();
				}
				if (string.IsNullOrWhiteSpace(text) && (Object)(object)Game.instance != (Object)null && Game.instance.GetPlayerProfile() != null)
				{
					text = Game.instance.GetPlayerProfile().GetName();
				}
				string text2 = ResolveLocalSteamId();
				if (!string.IsNullOrWhiteSpace(text) && !string.IsNullOrWhiteSpace(text2))
				{
					Merge(bySteam, text, text2);
				}
			}
			catch
			{
			}
		}

		private static string ResolveLocalSteamId()
		{
			try
			{
				Type type = AccessTools.TypeByName("Steamworks.SteamUser");
				if (type != null)
				{
					MethodInfo method = type.GetMethod("GetSteamID", BindingFlags.Static | BindingFlags.Public);
					if (method != null)
					{
						object obj = method.Invoke(null, null);
						if (obj != null)
						{
							FieldInfo field = obj.GetType().GetField("m_SteamID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							if (field != null)
							{
								object value = field.GetValue(obj);
								if (value != null)
								{
									string text = value.ToString();
									if (Regex.IsMatch(text ?? string.Empty, "^\\d{17}$"))
									{
										return text;
									}
								}
							}
							string text2 = obj.ToString();
							if (Regex.IsMatch(text2 ?? string.Empty, "^\\d{17}$"))
							{
								return text2;
							}
						}
					}
				}
			}
			catch
			{
			}
			return string.Empty;
		}

		private static string ReadPeerSteamId(ZNetPeer peer)
		{
			if (peer == null)
			{
				return string.Empty;
			}
			try
			{
				if (peer.m_socket != null)
				{
					object socket = peer.m_socket;
					MethodInfo method = socket.GetType().GetMethod("GetPeerID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (method != null)
					{
						object obj = method.Invoke(socket, null);
						if (obj != null)
						{
							string text = obj.ToString();
							if (Regex.IsMatch(text ?? string.Empty, "^\\d{17}$"))
							{
								return text;
							}
						}
					}
					MethodInfo method2 = socket.GetType().GetMethod("GetHostName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (method2 != null)
					{
						object obj2 = method2.Invoke(socket, null);
						string text2 = ((obj2 != null) ? obj2.ToString() : string.Empty);
						string text3 = ExtractSteam64(text2);
						if (!string.IsNullOrWhiteSpace(text3))
						{
							return text3;
						}
					}
				}
			}
			catch
			{
			}
			try
			{
				Type type = ((object)peer).GetType();
				string[] array = new string[3] { "m_uid", "uid", "UID" };
				string[] array2 = array;
				foreach (string name in array2)
				{
					FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (!(field != null))
					{
						continue;
					}
					object value = field.GetValue(peer);
					if (value != null)
					{
						string text4 = value.ToString();
						if (Regex.IsMatch(text4 ?? string.Empty, "^\\d{17}$"))
						{
							return text4;
						}
					}
				}
			}
			catch
			{
			}
			return string.Empty;
		}

		private static void Merge(Dictionary<string, OnlinePlayerRecord> bySteam, string playerName, string steamId)
		{
			if (!string.IsNullOrWhiteSpace(steamId))
			{
				if (!bySteam.TryGetValue(steamId, out var value))
				{
					bySteam[steamId] = new OnlinePlayerRecord
					{
						PlayerName = (string.IsNullOrWhiteSpace(playerName) ? "Jogador" : playerName.Trim()),
						SteamId = steamId
					};
				}
				else if ((string.IsNullOrWhiteSpace(value.PlayerName) || string.Equals(value.PlayerName, "Stranger", StringComparison.OrdinalIgnoreCase)) && !string.IsNullOrWhiteSpace(playerName))
				{
					value.PlayerName = playerName.Trim();
				}
			}
		}

		private static string GetPlayerInfoHost(PlayerInfo player)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Type type = ((object)player).GetType();
				string[] array = new string[6] { "m_host", "m_hostName", "host", "hostName", "Host", "HostName" };
				string[] array2 = array;
				foreach (string name in array2)
				{
					FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null)
					{
						object value = field.GetValue(player);
						if (value != null && !string.IsNullOrWhiteSpace(value.ToString()))
						{
							return value.ToString();
						}
					}
					PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property != null)
					{
						object value2 = property.GetValue(player, null);
						if (value2 != null && !string.IsNullOrWhiteSpace(value2.ToString()))
						{
							return value2.ToString();
						}
					}
				}
			}
			catch
			{
			}
			return string.Empty;
		}

		private static string GetPlayerInfoName(PlayerInfo player)
		{
			//IL_0002: 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)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Type type = ((object)player).GetType();
				string[] array = new string[3] { "m_name", "name", "Name" };
				string[] array2 = array;
				foreach (string name in array2)
				{
					FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null)
					{
						object value = field.GetValue(player);
						if (value != null)
						{
							string text = value.ToString();
							if (!string.IsNullOrWhiteSpace(text))
							{
								return text;
							}
						}
					}
					PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (!(property != null))
					{
						continue;
					}
					object value2 = property.GetValue(player, null);
					if (value2 != null)
					{
						string text2 = value2.ToString();
						if (!string.IsNullOrWhiteSpace(text2))
						{
							return text2;
						}
					}
				}
			}
			catch
			{
			}
			return string.Empty;
		}

		private static string GetPeerName(ZNetPeer peer)
		{
			try
			{
				Type type = ((object)peer).GetType();
				string[] array = new string[5] { "m_playerName", "m_name", "playerName", "name", "Name" };
				string[] array2 = array;
				foreach (string name in array2)
				{
					FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null)
					{
						object value = field.GetValue(peer);
						if (value != null)
						{
							string text = value.ToString();
							if (!string.IsNullOrWhiteSpace(text))
							{
								return text;
							}
						}
					}
					PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (!(property != null))
					{
						continue;
					}
					object value2 = property.GetValue(peer, null);
					if (value2 != null)
					{
						string text2 = value2.ToString();
						if (!string.IsNullOrWhiteSpace(text2))
						{
							return text2;
						}
					}
				}
			}
			catch
			{
			}
			return string.Empty;
		}

		private static string ExtractSteam64(string text)
		{
			if (string.IsNullOrWhiteSpace(text))
			{
				return string.Empty;
			}
			Match match = Regex.Match(text, "\\d{17}");
			return match.Success ? match.Value : string.Empty;
		}
	}
	internal static class GlitnirPayments
	{
		[CompilerGenerated]
		private sealed class <EnumeratePeerIdentifiers>d__6 : IEnumerable<string>, IEnumerable, IEnumerator<string>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private string <>2__current;

			private int <>l__initialThreadId;

			private ZNetPeer peer;

			public ZNetPeer <>3__peer;

			pri