using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using MuteChatPlayer.Database;
using MuteChatPlayer.Utils;
using ProjectM;
using ProjectM.Network;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
using VampireCommandFramework;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MuteChatPlayer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Block players from sending messages")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("MuteChatPlayer")]
[assembly: AssemblyTitle("MuteChatPlayer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MuteChatPlayer
{
[BepInPlugin("MuteChatPlayer", "MuteChatPlayer", "0.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
private Harmony _harmony;
public static ManualLogSource Logger;
internal static Plugin Instance;
public override void Load()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
Instance = this;
Logger = ((BasePlugin)this).Log;
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MuteChatPlayer");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
_harmony = new Harmony("MuteChatPlayer");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
CommandRegistry.RegisterAll(Assembly.GetExecutingAssembly());
}
public static void GamedataInit()
{
MutePlayersSystem.Initialize();
}
public override bool Unload()
{
CommandRegistry.UnregisterAssembly();
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MuteChatPlayer";
public const string PLUGIN_NAME = "MuteChatPlayer";
public const string PLUGIN_VERSION = "0.1.0";
}
}
namespace MuteChatPlayer.Utils
{
public class Helper
{
private static World? _serverWorld;
public static EntityManager EntityManager => Server.EntityManager;
public static World Server
{
get
{
if (_serverWorld != null)
{
return _serverWorld;
}
_serverWorld = GetWorld("Server") ?? throw new Exception("There is no Server world (yet). Did you install a server mod on the client?");
return _serverWorld;
}
}
public static bool IsServer => Application.productName == "VRisingServer";
private static World GetWorld(string name)
{
Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
while (enumerator.MoveNext())
{
World current = enumerator.Current;
if (current.Name == name)
{
return current;
}
}
return null;
}
internal static bool FindPlayer(string name, out User user)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: 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_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_0085: Unknown result type (might be due to invalid IL or missing references)
user = default(User);
EntityManager entityManager = Server.EntityManager;
EntityQueryDesc[] array = new EntityQueryDesc[1];
EntityQueryDesc val = new EntityQueryDesc();
val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<User>() });
val.Options = (EntityQueryOptions)2;
array[0] = val;
EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array);
NativeArray<Entity> val3 = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
Enumerator<Entity> enumerator = val3.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
entityManager = EntityManager;
user = ((EntityManager)(ref entityManager)).GetComponentData<User>(current);
if (((object)(FixedString64Bytes)(ref user.CharacterName)).ToString().ToLower() == name)
{
val3.Dispose();
return true;
}
}
val3.Dispose();
return false;
}
}
public class MutePlayersSystem : MonoBehaviour
{
private static MutePlayersSystem _instance;
public static DateTime LastSaveMuteList = DateTime.Now;
private static readonly string FileDirectory = Path.Combine("BepInEx", "config", "MuteChatPlayer");
private static readonly string FileName = "Mute_List.json";
private static readonly string fullPath = Path.Combine(FileDirectory, FileName);
private static int loop = 0;
public static bool MutePlayerSystem_Enabled = true;
public static bool OnChatMessage(ChatMessageEvent chatMessage, FromCharacter fromCharacter)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: 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)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Invalid comparison between Unknown and I4
//IL_005e: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = Helper.EntityManager;
User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(fromCharacter.User);
if (DB.PlayerChatMute.ContainsKey(componentData.PlatformId))
{
DateTime now = DateTime.Now;
PlayerMuteChat playerMuteChat = DB.PlayerChatMute[componentData.PlatformId];
if (now > playerMuteChat.BanTime)
{
DB.PlayerChatMute.TryRemove(componentData.PlatformId, out var _);
return false;
}
if ((int)chatMessage.MessageType == playerMuteChat.MuteChatChannel || playerMuteChat.MuteChatChannel == -1)
{
ServerChatUtils.SendSystemMessageToClient(Helper.EntityManager, componentData, $"You have been muted for {Math.Ceiling(DB.PlayerChatMute[componentData.PlatformId].BanTime.Subtract(now).TotalMinutes)} more minutes.");
return true;
}
return false;
}
return false;
}
private void Update()
{
}
private void Start()
{
Load_Mute_List();
((MonoBehaviour)this).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(UpdateDurabilityInSpecialStorage()));
}
private IEnumerator UpdateDurabilityInSpecialStorage()
{
while (true)
{
KeyValuePair<ulong, PlayerMuteChat>[] array = DB.PlayerChatMute.ToArray();
for (int i = 0; i < array.Length; i++)
{
KeyValuePair<ulong, PlayerMuteChat> player = array[i];
PlayerMuteChat value = DB.PlayerChatMute[player.Key];
if (value.BanTime < DateTime.Now)
{
DB.PlayerChatMute.TryRemove(player.Key, out value);
}
}
if ((DateTime.Now - LastSaveMuteList).TotalSeconds >= 300.0)
{
LastSaveMuteList = DateTime.Now;
}
yield return (object)new WaitForSeconds(60f);
}
}
private void LateUpdate()
{
}
public static void Initialize()
{
if (!ClassInjector.IsTypeRegisteredInIl2Cpp<MutePlayersSystem>())
{
ClassInjector.RegisterTypeInIl2Cpp<MutePlayersSystem>();
}
_instance = ((BasePlugin)Plugin.Instance).AddComponent<MutePlayersSystem>();
}
public static void Save_Mute_List()
{
File.WriteAllText(fullPath, JsonSerializer.Serialize(DB.PlayerChatMute, new JsonSerializerOptions
{
WriteIndented = true
}));
Plugin.Logger.LogWarning((object)"Mute_List DB Saved.");
}
public static void Load_Mute_List()
{
if (!Directory.Exists(FileDirectory))
{
Directory.CreateDirectory(FileDirectory);
}
if (!File.Exists(fullPath))
{
DB.PlayerChatMute.Clear();
Plugin.Logger.LogWarning((object)"Mute_List DB Created.");
Save_Mute_List();
}
else
{
string json = File.ReadAllText(fullPath);
DB.PlayerChatMute = JsonSerializer.Deserialize<ConcurrentDictionary<ulong, PlayerMuteChat>>(json);
Plugin.Logger.LogWarning((object)"Mute_List DB Populated");
}
}
public static void Uninitialize()
{
Object.Destroy((Object)(object)_instance);
_instance = null;
}
}
}
namespace MuteChatPlayer.Hooks
{
[HarmonyAfter(new string[] { "gg.deca.VampireCommandFramework" })]
[HarmonyBefore(new string[] { "gg.deca.Bloodstone" })]
[HarmonyPatch(typeof(ChatMessageSystem), "OnUpdate")]
public class ChatMessageSystem_Patch
{
[HarmonyPrefix]
public static void prefix(ChatMessageSystem __instance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
EntityQuery chatMessageQuery = __instance._ChatMessageQuery;
Enumerator<Entity> enumerator = ((EntityQuery)(ref chatMessageQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityManager entityManager = Helper.Server.EntityManager;
ChatMessageEvent componentData = ((EntityManager)(ref entityManager)).GetComponentData<ChatMessageEvent>(current);
entityManager = Helper.Server.EntityManager;
FromCharacter componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<FromCharacter>(current);
entityManager = Helper.EntityManager;
User componentData3 = ((EntityManager)(ref entityManager)).GetComponentData<User>(componentData2.User);
if (MutePlayersSystem.MutePlayerSystem_Enabled && !componentData3.IsAdmin && MutePlayersSystem.OnChatMessage(componentData, componentData2))
{
entityManager = Helper.EntityManager;
((EntityManager)(ref entityManager)).DestroyEntity(current);
}
}
}
}
[HarmonyPatch(typeof(LoadPersistenceSystemV2), "SetLoadState")]
public class PersistenceSystem_Patch
{
public static void Prefix(State loadState, LoadPersistenceSystemV2 __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)loadState == 4)
{
Plugin.GamedataInit();
}
}
}
[HarmonyPatch(typeof(TriggerPersistenceSaveSystem), "TriggerSave")]
public class TriggerPersistenceSaveSystem_Patch
{
[HarmonyPostfix]
public static void Postfix(SaveReason reason, FixedString128Bytes saveName, ServerRuntimeSettings saveConfig)
{
MutePlayersSystem.Save_Mute_List();
}
}
}
namespace MuteChatPlayer.Database
{
public struct PlayerMuteChat
{
public DateTime BanTime { get; set; }
public int MuteChatChannel { get; set; }
public PlayerMuteChat(DateTime bantime, int mutechatchannel)
{
BanTime = bantime;
MuteChatChannel = mutechatchannel;
}
}
internal class DB
{
public static ConcurrentDictionary<ulong, PlayerMuteChat> PlayerChatMute = new ConcurrentDictionary<ulong, PlayerMuteChat>();
}
}
namespace MuteChatPlayer.Commands
{
public static class MuteCommands
{
[Command("mute", null, "[Player Name] [global|local|all] [time in minuts]", "Command for mute player.", null, true)]
public static void MuteCommand(ChatCommandContext ctx, string name = "null", string channal = "all", int bantime = 60)
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
int num = -1;
if (name != "null")
{
if (Helper.FindPlayer(name, out var user))
{
switch (channal.ToLower())
{
case "global":
num = 0;
break;
case "local":
num = 4;
break;
case "all":
num = -1;
break;
default:
ctx.Reply("<color=#ff0000>Invalid chat-type option. Options are: global, local,all</color>");
num = -55;
break;
}
if (num != -55)
{
if (DB.PlayerChatMute.ContainsKey(user.PlatformId))
{
DB.PlayerChatMute[user.PlatformId] = new PlayerMuteChat(DateTime.Now.AddMinutes(bantime), num);
ctx.Reply($"Mute player [{user.CharacterName}] is updated. Mute end: [{DB.PlayerChatMute[user.PlatformId].BanTime}]");
}
else
{
DB.PlayerChatMute.TryAdd(user.PlatformId, new PlayerMuteChat(DateTime.Now.AddMinutes(bantime), num));
ctx.Reply($"Player [{user.CharacterName}] is muted. Mute end: [{DB.PlayerChatMute[user.PlatformId].BanTime}]");
}
}
}
else
{
ctx.Reply("Player with name : [" + name + "] not found!");
}
}
else
{
ctx.Reply("You need use player name for mute.");
}
}
}
}