Decompiled source of iLikeMySteamName v1.0.0

Mods/iLikeMySteamName.dll

Decompiled a month ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using ILMSN;
using MelonLoader;
using MelonLoader.Preferences;
using RUMBLE.Platform;
using Steamworks;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("no more ruining steam names!")]
[assembly: AssemblyDescription("no more ruining steam names!")]
[assembly: AssemblyCompany(null)]
[assembly: AssemblyProduct("iLikeMySteamName")]
[assembly: AssemblyCopyright("Created by elmish")]
[assembly: AssemblyTrademark(null)]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: MelonInfo(typeof(ILMSNClass), "iLikeMySteamName", "1.0.0", "elmish", null)]
[assembly: MelonColor]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ILMSN;

public static class BuildInfo
{
	public const string Name = "iLikeMySteamName";

	public const string Description = "no more ruining steam names!";

	public const string Author = "elmish";

	public const string Company = null;

	public const string Version = "1.0.0";

	public const string DownloadLink = null;
}
public class ILMSNClass : MelonMod
{
	[HarmonyPatch(typeof(SteamInfo), "GetPersonaName")]
	public static class Patch2
	{
		public static bool Prefix(ref string __result)
		{
			MelonLogger.Msg("steaminfo is being called");
			if (username.Length > 48 || username.Length <= 0)
			{
				MelonLogger.Error("name too long or too short, or you missdid the username, incase you deleted shit from the file and it's not restoring just delete it and launch the game again");
				return true;
			}
			__result = username;
			return false;
		}
	}

	[HarmonyPatch(typeof(SteamFriends), "GetPersonaName")]
	public static class Patch3
	{
		public static bool Prefix(ref string __result)
		{
			MelonLogger.Msg("Steamfriends is being called");
			if (username.Length > 48 || username.Length <= 0)
			{
				MelonLogger.Error("name too long or too short, or you missdid the username, incase you deleted shit from the file and it's not restoring just delete it and launch the game again");
				return true;
			}
			__result = username;
			return false;
		}
	}

	public static string username = "";

	private MelonPreferences_Category SteamNameCategory;

	private MelonPreferences_Entry<string> UserNameEntry;

	public override void OnInitializeMelon()
	{
		((MelonBase)this).OnInitializeMelon();
		SteamNameCategory = MelonPreferences.CreateCategory("Steam Username");
		UserNameEntry = SteamNameCategory.CreateEntry<string>("name", "", (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		SteamNameCategory.SetFilePath("UserData/customName.cfg");
		SteamNameCategory.SaveToFile(true);
		username = UserNameEntry.Value;
	}
}