using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ModLister")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ModLister")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("99663d31-af87-43c9-8d76-13c1f64c871f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ModLister
{
internal class Utils
{
public static string LogLocation;
public static void Init(string location)
{
LogLocation = location;
if (File.Exists(LogLocation))
{
File.Delete(LogLocation);
}
using StreamWriter streamWriter = File.AppendText(LogLocation);
streamWriter.WriteLine("Mod list:");
}
public static void PrintToLog(string line)
{
using StreamWriter streamWriter = File.AppendText(LogLocation);
streamWriter.WriteLine(line);
}
}
[BepInPlugin("Ccode.ModLister", "ModLister", "0.0.1")]
public class Plugin : BaseUnityPlugin
{
private const string MyGuid = "Ccode.ModLister";
private const string PluginName = "ModLister";
private const string VersionString = "0.0.1";
private static readonly Harmony Harmony = new Harmony("Ccode.ModLister");
public static ManualLogSource Log;
private void Awake()
{
Harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"ModLister 0.0.1 loaded.");
Log = ((BaseUnityPlugin)this).Logger;
Utils.Init(((BaseUnityPlugin)this).Info.Location.TrimEnd("ModLister.dll".ToCharArray()) + "Mods.log");
}
}
}
namespace ModLister.Patches
{
[HarmonyPatch(typeof(InitializeGame), "OnEnable")]
internal class InitializeGamePatches
{
public static void Postfix()
{
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
BepInPlugin metadata = pluginInfo.Value.Metadata;
Utils.PrintToLog("Plugin: \"" + metadata.Name + "\" Version: \"" + metadata.Version.ToString() + "\" GUID: \"" + metadata.GUID.ToString() + "\"");
}
}
}
}