using System;
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;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Text;
using Microsoft.CodeAnalysis;
using PleadIgnorance.Core;
using PleadIgnorance.Utils;
using ProjectM;
using ProjectM.Network;
using Unity.Collections;
using Unity.Entities;
using VampireCommandFramework;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PleadIgnorance")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0-release.1+6.Branch.release.Sha.88d3e9122dbed14c555f0dc5c64eef0b7ad8685d.88d3e9122dbed14c555f0dc5c64eef0b7ad8685d")]
[assembly: AssemblyProduct("PleadIgnorance")]
[assembly: AssemblyTitle("PleadIgnorance")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace PleadIgnorance
{
public class Commands
{
[Command("showmessageprompt", "src", null, "Show the message prompt", null, true)]
public void Test(ChatCommandContext ctx)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
Chat.SendFormattedMessage(ctx.User);
}
[Command("accept", null, null, "test", null, false)]
public void Accept(ChatCommandContext ctx)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Plugin.Instance.AcceptedUsers.Add(ctx.User.PlatformId);
ctx.Reply("You may now leave the spawn area!");
}
}
[BepInPlugin("PleadIgnorance", "PleadIgnorance", "0.1.0-release.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
public readonly List<ulong> AcceptedUsers = new List<ulong>();
private static Harmony? _harmony;
internal static Plugin? Instance { get; private set; }
public override void Load()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
Instance = this;
Log.Initialize(((BasePlugin)this).Log);
Config.Initialize();
_harmony = new Harmony("PleadIgnorance");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
CommandRegistry.RegisterAll();
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>("PleadIgnorance");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.0-release.1");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
}
public override bool Unload()
{
Harmony? harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "PleadIgnorance";
public const string PLUGIN_NAME = "PleadIgnorance";
public const string PLUGIN_VERSION = "0.1.0-release.1";
}
}
namespace PleadIgnorance.Utils
{
public static class Chat
{
public static void SendFormattedMessage(User target)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
StringBuilder sb = new StringBuilder();
Encoding utf8 = Encoding.UTF8;
int flushCount = 0;
if (!string.IsNullOrWhiteSpace(Config.Header?.Value))
{
Accumulate(Config.Header.Value);
}
foreach (string messageLine in Config.MessageLines)
{
Accumulate(messageLine);
}
if (!string.IsNullOrWhiteSpace(Config.Footer?.Value))
{
Accumulate(Config.Footer.Value);
}
Flush();
int Accumulate(string line)
{
int byteCount = utf8.GetByteCount(line + "\n");
if (utf8.GetByteCount(sb.ToString()) + byteCount > 512)
{
Flush();
if (flushCount > 0)
{
sb.AppendLine();
}
}
sb.AppendLine(line);
return byteCount;
}
void Flush()
{
//IL_0047: 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)
if (sb.Length != 0)
{
string text = sb.ToString();
if (utf8.GetByteCount(text) > 512)
{
text = TruncateToByteLimit(text, 512, utf8);
}
FixedString512Bytes val = default(FixedString512Bytes);
((FixedString512Bytes)(ref val))..ctor(text);
ServerChatUtils.SendSystemMessageToClient(VWorld.EntityManager, target, ref val);
sb.Clear();
flushCount++;
}
}
}
private static string TruncateToByteLimit(string input, int byteLimit, Encoding encoding)
{
int num = 0;
StringBuilder stringBuilder = new StringBuilder();
foreach (char c in input)
{
int byteCount = encoding.GetByteCount(new char[1] { c });
if (num + byteCount > byteLimit)
{
break;
}
stringBuilder.Append(c);
num += byteCount;
}
return stringBuilder.ToString();
}
}
}
namespace PleadIgnorance.Patch
{
[HarmonyPatch(typeof(TeleportationRequestSystem), "OnUpdate")]
public static class HandleTeleportationRequest
{
private static void Prefix(TeleportationRequestSystem __instance)
{
//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_0008: 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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//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_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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
EntityQuery teleportRequestQuery = __instance._TeleportRequestQuery;
NativeArray<Entity> val = ((EntityQuery)(ref teleportRequestQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
Enumerator<Entity> enumerator = val.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
TeleportationRequest val2 = current.Read<TeleportationRequest>();
int value = val2.CustomTravelBuffPrefab._Value;
User val3 = val2.PlayerEntity.Read<PlayerCharacter>().UserEntity.Read<User>();
if (value == 2033937156 && !Plugin.Instance.AcceptedUsers.Contains(val3.PlatformId))
{
if (Config.PreventCaveExit.Value.Equals(obj: true))
{
((EntityManager)(ref entityManager)).DestroyEntity(current);
}
Chat.SendFormattedMessage(val3);
}
}
val.Dispose();
}
}
}
namespace PleadIgnorance.Core
{
public static class Config
{
internal static List<string> MessageLines;
internal static ConfigEntry<string> Header;
internal static ConfigEntry<string> Footer;
internal static ConfigEntry<bool> PreventCaveExit;
internal static void Initialize()
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
string text = Path.Combine(Paths.ConfigPath, "PleadIgnorance", "config.cfg");
string path = Path.Combine(Paths.ConfigPath, "PleadIgnorance", "message.cfg");
if (!File.Exists(path))
{
Directory.CreateDirectory(Path.GetDirectoryName(path) ?? string.Empty);
File.WriteAllText(path, "<color=#ffffffff>Rule 1:</color> Dont be an asshole.\n<color=#ffffffff>Rule 2:</color> <b>You can</b>\n<color=#ffffffff>Rule 3:</color> <i>Also use</i>\n<color=#ffffffff>Rule 4:</color> <size=10>Rich text</size>\n<color=#ffffffff>Rule 5:</color> <size=15>Formatting in</size>\n<color=#ffffffff>Rule 6:</color> <size=20>The <color=#add8e6ff>Message</color></size>");
}
MessageLines = new List<string>(File.ReadAllLines(path));
Directory.CreateDirectory(Path.GetDirectoryName(text) ?? string.Empty);
ConfigFile val = new ConfigFile(text, true);
Header = val.Bind<string>("Text", "Header", "<color=#add8e6ff>Server Rules</color>", "Message header text");
Footer = val.Bind<string>("Text", "Footer", "Type <color=#ffff00ff><b>.accept</b></color> to continue", "Message footer text");
PreventCaveExit = val.Bind<bool>("Options", "PreventCaveExit", true, "Prevent cave exit until player accepts the rules.");
Log.Info("Config Initialized");
}
}
internal static class Extensions
{
private static EntityManager Em => VWorld.EntityManager;
public static T Read<T>(this Entity entity) where T : struct
{
//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)
EntityManager em = Em;
return ((EntityManager)(ref em)).GetComponentData<T>(entity);
}
public static void ExploreEntity(this Entity entity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
StringBuilder val = new StringBuilder();
EntityDebuggingUtility.DumpEntity(VWorld.Server, entity, true, val);
Log.Info(((Object)val).ToString());
}
}
public static class Log
{
private static ManualLogSource? LogSource { get; set; }
public static void Initialize(ManualLogSource? logSource)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
LogSource = logSource;
ManualLogSource logSource2 = LogSource;
if (logSource2 != null)
{
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 0, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Log] Source Initialized");
}
logSource2.LogInfo(val);
}
}
public static void Info(string message)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
ManualLogSource logSource = LogSource;
if (logSource != null)
{
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(0, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message);
}
logSource.LogInfo(val);
}
}
public static void Message(string message)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
ManualLogSource logSource = LogSource;
if (logSource != null)
{
bool flag = default(bool);
BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(0, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message);
}
logSource.LogMessage(val);
}
}
public static void Warning(string message)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
ManualLogSource logSource = LogSource;
if (logSource != null)
{
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(0, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message);
}
logSource.LogWarning(val);
}
}
public static void Error(string message)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Expected O, but got Unknown
ManualLogSource logSource = LogSource;
if (logSource != null)
{
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(0, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(message);
}
logSource.LogError(val);
}
}
}
public static class VWorld
{
private static World? _serverWorld;
private static EntityManager? _entityManager;
public static World Server
{
get
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
if (_serverWorld != null && _serverWorld.IsCreated)
{
return _serverWorld;
}
_serverWorld = GetWorld("Server");
if (_serverWorld == null || !_serverWorld.IsCreated)
{
_entityManager = null;
throw new Exception("Server world is not available or not created.");
}
_entityManager = _serverWorld.EntityManager;
return _serverWorld;
}
}
public static EntityManager EntityManager
{
get
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
if (_entityManager.HasValue && _serverWorld != null && _serverWorld.IsCreated)
{
return _entityManager.Value;
}
return Server.EntityManager;
}
}
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;
}
}
}