Decompiled source of AutoConsoleCommands v1.0.4

BepInEx/plugins/AutoConsoleCommands.dll

Decompiled 14 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("AutoConsoleCommands")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AutoConsoleCommands")]
[assembly: AssemblyTitle("AutoConsoleCommands")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AutoConsoleCommands;

[BepInPlugin("AutoConsoleCommands", "AutoConsoleCommands", "1.0.0")]
public class AutoConsoleCommandsPlugin : BaseUnityPlugin
{
	private static ConfigEntry<string> commandList;

	private Player lastLocalPlayer;

	private void Awake()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		commandList = ((BaseUnityPlugin)this).Config.Bind<string>("General", "CommandList", "god, debugmode", "Comma-separated list of console commands to run automatically once the player is loaded.");
		new Harmony("AutoConsoleCommands").PatchAll();
		Debug.Log((object)"[AutoConsoleCommands] Plugin loaded. Waiting for local player to spawn...");
	}

	private void Update()
	{
		if (!((Object)(object)Player.m_localPlayer != (Object)null) || !((Object)(object)Player.m_localPlayer != (Object)(object)lastLocalPlayer))
		{
			return;
		}
		lastLocalPlayer = Player.m_localPlayer;
		if ((Object)(object)Console.instance == (Object)null)
		{
			Debug.LogWarning((object)"[AutoConsoleCommands] Console instance is null; cannot run commands.");
			return;
		}
		string[] array = commandList.Value.Split(new char[1] { ',' });
		for (int i = 0; i < array.Length; i++)
		{
			string text = array[i].Trim();
			if (!string.IsNullOrEmpty(text))
			{
				Debug.Log((object)("[AutoConsoleCommands] Running command: " + text));
				((Terminal)Console.instance).TryRunCommand(text, false, false);
			}
		}
	}
}