using System;
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.Security;
using System.Security.Permissions;
using AssetBundleTools;
using BepInEx;
using BepInEx.Logging;
using BlockInChatPlugin;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Util;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("Celestial Corp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+bbd6a518511c23c4d0cb7acf268e725e71f167cf")]
[assembly: AssemblyProduct("BlockInChatPlugin")]
[assembly: AssemblyTitle("BlockInChatPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[HarmonyPatch]
public class ChatGuildPatch
{
[HarmonyPatch(typeof(ChatGuild), "Awake")]
private class AwakePatch
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__0_0;
internal void <Postfix>b__0_0()
{
OnManageClick();
}
}
private static void Postfix(ChatGuild __instance)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
DataUtils.LoadBlocklist();
Transform val = ((Component)__instance).transform.Find("Dialog/Container/Viewport/Content");
Transform val2 = Object.Instantiate<Transform>(val.Find("JoinChannel"), val);
((Component)val2).transform.SetAsFirstSibling();
((Object)val2).name = "ManageBlocks";
((Component)val2).GetComponent<RectTransform>().anchoredPosition = new Vector2(146.6459f, -18.7999f);
Transform obj = val2.Find("Image");
Image component = ((Component)obj).GetComponent<Image>();
Color color = ((Graphic)component).color;
Object.DestroyImmediate((Object)(object)component);
Image obj2 = ((Component)obj).gameObject.AddComponent<Image>();
((Graphic)obj2).color = color;
obj2.sprite = BundleTool.GetSprite("Assets/BlockInChatPlugin/Block.png");
((Component)val2).gameObject.GetComponent<Tooltip>().texto = "Manage Blocklist";
Button component2 = ((Component)val2).GetComponent<Button>();
ColorBlock colors = ((Selectable)component2).colors;
Object.DestroyImmediate((Object)(object)component2);
Button obj3 = ((Component)val2).gameObject.AddComponent<Button>();
((Selectable)obj3).colors = colors;
((Selectable)obj3).targetGraphic = (Graphic)(object)((Component)val2).GetComponent<Image>();
ButtonClickedEvent onClick = obj3.onClick;
object obj4 = <>c.<>9__0_0;
if (obj4 == null)
{
UnityAction val3 = delegate
{
OnManageClick();
};
<>c.<>9__0_0 = val3;
obj4 = (object)val3;
}
((UnityEvent)onClick).AddListener((UnityAction)obj4);
GameObject prefab = BundleTool.GetPrefab("Assets/BlockInChatPlugin/PanelBlock.prefab");
if (!((Object)(object)prefab == (Object)null))
{
GameObject obj5 = Object.Instantiate<GameObject>(prefab, val);
((Object)obj5).name = "PanelBlock";
bm = obj5.AddComponent<BlockListManager>();
obj5.SetActive(false);
}
}
private static void OnManageClick()
{
((Component)bm).gameObject.SetActive(true);
bm.LoadBlocklist();
}
}
[HarmonyPatch(typeof(ChatGuild), "RecibeMensajePrivado")]
private class RecibeMensajePrivadoPatch
{
private static bool Prefix(ChatGuild __instance, ref ChatMessage message, ref string otherNickname)
{
if (DataUtils.blockedPlayers.Contains(otherNickname))
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(ChatGuild), "RecibeMensaje")]
private class RecibeMensajePatch
{
private static bool Prefix(ChatGuild __instance, ref ChatMessage message)
{
if (DataUtils.blockedPlayers.Contains(message.nickName))
{
message.message = "<color=#6a7485><i> --- Message Blocked ---<i></color>";
}
return true;
}
}
private static BlockListManager bm;
}
namespace BlockInChatPlugin
{
public class BlockListManager : MonoBehaviour
{
public class BlockedUser
{
public string _nickName;
public GameObject _blockedUser;
public BlockedUser(string nickName)
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
_nickName = nickName;
Transform transform = GameObject.Find("PanelBlock/Panel/BlockList/Viewport/Content").transform;
GameObject gameObject = ((Component)transform.Find("BlockedUserTemplate")).gameObject;
_blockedUser = Object.Instantiate<GameObject>(gameObject, transform);
_blockedUser.SetActive(true);
((TMP_Text)((Component)_blockedUser.transform.Find("Text")).GetComponent<TextMeshProUGUI>()).text = _nickName;
((UnityEvent)_blockedUser.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
OnBlockedUserRemove();
});
}
public void OnBlockedUserRemove()
{
Object.FindObjectOfType<BlockListManager>().blocks.Remove(this);
Object.Destroy((Object)(object)_blockedUser);
}
}
public List<BlockedUser> blocks = new List<BlockedUser>();
private TMP_InputField addField;
private void Awake()
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected O, but got Unknown
addField = ((Component)((Component)this).transform.Find("Panel/Top/AddNameInput")).GetComponent<TMP_InputField>();
((UnityEvent)((Component)((Component)this).transform.Find("Panel/Top/AddButton")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
OnAddBlock();
});
((UnityEvent)((Component)((Component)this).transform.Find("Panel/Bottom/SaveButton")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
OnSaveClick();
});
((UnityEvent)((Component)((Component)this).transform.Find("Panel/ExitButton")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
OnExitClick();
});
((Component)this).gameObject.SetActive(false);
}
public void LoadBlocklist()
{
foreach (string blockedPlayer in DataUtils.blockedPlayers)
{
blocks.Add(new BlockedUser(blockedPlayer));
}
}
public void ClearBlocks()
{
for (int i = 0; i < blocks.Count; i++)
{
Object.Destroy((Object)(object)blocks[i]._blockedUser);
}
blocks.Clear();
}
private void OnAddBlock()
{
if (string.IsNullOrEmpty(addField.text))
{
OS.ShowError("Name input cannot be blank!");
return;
}
if (blocks.FirstOrDefault((BlockedUser x) => x._nickName == addField.text) != null)
{
OS.ShowError(addField.text + " is already in list");
return;
}
blocks.Add(new BlockedUser(addField.text));
addField.text = "";
}
private void OnSaveClick()
{
List<string> list = new List<string>();
foreach (BlockedUser block in blocks)
{
list.Add(block._nickName);
}
DataUtils.blockedPlayers = list;
DataUtils.SaveBlocklist();
addField.text = "";
ClearBlocks();
((Component)this).gameObject.SetActive(false);
}
private void OnExitClick()
{
ClearBlocks();
((Component)this).gameObject.SetActive(false);
}
}
internal class DataUtils
{
public static List<string> blockedPlayers;
internal static string dataFilePath = Path.Combine(Paths.ConfigPath, "Blocklist.json");
public static void LoadBlocklist()
{
if (!File.Exists(dataFilePath))
{
Plugin.Logger.LogWarning((object)"No blocklist found");
blockedPlayers = new List<string>();
SaveBlocklist();
}
else
{
blockedPlayers = JsonConvert.DeserializeObject<List<string>>(File.ReadAllText(dataFilePath));
Plugin.Logger.LogInfo((object)"Blocklist loaded");
}
}
public static void SaveBlocklist()
{
string contents = JsonConvert.SerializeObject((object)blockedPlayers, (Formatting)1);
File.WriteAllText(dataFilePath, contents);
Plugin.Logger.LogInfo((object)"Blocklist saved");
}
}
[BepInPlugin("com.machaceleste.blockinchatplugin", "BlockInChatPlugin", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private void Awake()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin BlockInChatPlugin is loaded!");
BundleTool.LoadBundle();
new Harmony("com.machaceleste.blockinchatplugin").PatchAll();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "BlockInChatPlugin";
public const string PLUGIN_NAME = "BlockInChatPlugin";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace AssetBundleTools
{
public class BundleTool
{
public static AssetBundle bundle;
public static void LoadBundle()
{
string text = Path.Combine(Paths.PluginPath, Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BlockInChatPlugin.bundle");
if (!File.Exists(text))
{
Debug.LogError((object)"[Info :BlockInChatPlugin] Bundle not found!");
return;
}
bundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)bundle == (Object)null)
{
Debug.LogError((object)"[Info :BlockInChatPlugin] Failed to load bundle!");
}
else
{
Debug.Log((object)"[Info :BlockInChatPlugin] Loaded bundle");
}
}
public static GameObject GetPrefab(string path)
{
GameObject val = bundle.LoadAsset<GameObject>(path);
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)("[Info :BlockInChatPlugin] Failed to load prefab " + path));
return null;
}
return val;
}
public static AudioClip GetClip(string path)
{
AudioClip val = bundle.LoadAsset<AudioClip>(path);
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)("[Info :BlockInChatPlugin] Failed to load audio clip " + path));
return null;
}
return val;
}
public static Sprite GetSprite(string path)
{
Sprite val = bundle.LoadAsset<Sprite>(path);
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)("[Info :BlockInChatPlugin] Failed to load sprite " + path));
return null;
}
return val;
}
}
}