Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Custom Boombox Fix v1.2.5
CustomBoomboxFix.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CustomBoomboxFix2.Configs; using HarmonyLib; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CustomBoomboxFix")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.2.5.0")] [assembly: AssemblyInformationalVersion("1.2.5")] [assembly: AssemblyProduct("CustomBoomboxFix")] [assembly: AssemblyTitle("CustomBoomboxFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.5.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.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; } } [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 CustomBoomboxFix2 { [BepInPlugin("CustomBoomboxFix", "CustomBoomboxFix", "1.2.5")] public class CustomBoomboxFix2 : BaseUnityPlugin { internal static BoomboxFixConfigs? boomboxFixConfigs; private bool isPluginMethodEnabled = false; private bool isConfigShareEnabled = false; public static CustomBoomboxFix2 Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private string CustomSongsPluginPath => Path.Combine(Paths.PluginPath, "Custom Songs"); private string CustomSongsConfigPath => Path.Combine(Paths.ConfigPath, "Custom Songs"); private string TargetPath => Path.Combine(Paths.BepInExRootPath, "Custom Songs", "Boombox Music"); private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; boomboxFixConfigs = new BoomboxFixConfigs(((BaseUnityPlugin)this).Config); isPluginMethodEnabled = boomboxFixConfigs.isPluginMethodEnabled.Value; isConfigShareEnabled = boomboxFixConfigs.isConfigShareEnabled.Value; Logger.LogInfo((object)"Plugin CustomBoomboxFix is loaded!"); CreatePluginCustomSongsFolder(); DeleteAllFilesInTargetPath(); SearchAndCopyCustomSongs(); if (isPluginMethodEnabled) { CopyMusicFiles(CustomSongsPluginPath); } if (isConfigShareEnabled) { CopyMusicFiles(CustomSongsConfigPath); } } private void CreatePluginCustomSongsFolder() { if (isPluginMethodEnabled && !Directory.Exists(CustomSongsPluginPath)) { Directory.CreateDirectory(CustomSongsPluginPath); Logger.LogInfo((object)"Created 'Custom Songs' folder in plugin directory."); } if (isConfigShareEnabled && !Directory.Exists(CustomSongsConfigPath)) { Directory.CreateDirectory(CustomSongsConfigPath); Logger.LogInfo((object)"Created 'Custom Songs' folder in config directory."); } } private void CopyMusicFiles(string customSongsPath) { if (!Directory.Exists(TargetPath)) { Directory.CreateDirectory(TargetPath); } IEnumerable<string> enumerable = Directory.GetFiles(customSongsPath, "*.mp3").Concat(Directory.GetFiles(customSongsPath, "*.ogg")).Concat(Directory.GetFiles(customSongsPath, "*.wav")); foreach (string item in enumerable) { string fileName = Path.GetFileName(item); string text = Path.Combine(TargetPath, fileName); if (!File.Exists(text)) { File.Copy(item, text); Logger.LogInfo((object)("Copied " + fileName + " to Boombox Music folder.")); } } } private void DeleteAllFilesInTargetPath() { try { if (Directory.Exists(TargetPath)) { string[] files = Directory.GetFiles(TargetPath); Logger.LogInfo((object)("Deleting files in '" + TargetPath + "'...")); string[] array = files; string[] array2 = array; foreach (string path in array2) { File.Delete(path); } Logger.LogInfo((object)("Deleted files in '" + TargetPath + "'")); } else { Logger.LogWarning((object)("Target path '" + TargetPath + "' does not exist.")); } } catch (Exception ex) { Logger.LogError((object)("An error occurred while trying to delete files: " + ex.Message)); } } private void SearchAndCopyCustomSongs() { string[] directories = Directory.GetDirectories(Paths.PluginPath); if (isConfigShareEnabled) { if (isPluginMethodEnabled) { CollectionExtensions.AddRangeToArray<string>(directories, Directory.GetDirectories(Paths.ConfigPath)); } else { directories = Directory.GetDirectories(Paths.ConfigPath); } } string[] array = directories; string[] array2 = array; foreach (string path in array2) { string text = Path.Combine(path, "Custom Songs"); if (!Directory.Exists(text)) { continue; } IEnumerable<string> enumerable = Directory.GetFiles(text, "*.mp3").Concat(Directory.GetFiles(text, "*.ogg")).Concat(Directory.GetFiles(text, "*.wav")); foreach (string item in enumerable) { string fileName = Path.GetFileName(item); string text2 = Path.Combine(TargetPath, fileName); if (!File.Exists(text2)) { File.Copy(item, text2); Logger.LogInfo((object)("Copied " + fileName + " from " + text + " to Boombox Music folder.")); } } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "CustomBoomboxFix"; public const string PLUGIN_NAME = "CustomBoomboxFix"; public const string PLUGIN_VERSION = "1.2.5"; } } namespace CustomBoomboxFix2.Configs { internal class BoomboxFixConfigs { internal ConfigEntry<bool> isPluginMethodEnabled; internal ConfigEntry<bool> isConfigShareEnabled; public BoomboxFixConfigs(ConfigFile cfg) { isPluginMethodEnabled = cfg.Bind<bool>("BoomboxFix", "useStandardMethod", true, "This will create a folder in 'BepInEx\\plugins\\Custom Songs', where you have to put your music (or install a music content-mod from Thunderstore). \nEveryone needs to do this in order to have the same music."); isConfigShareEnabled = cfg.Bind<bool>("BoomboxFix", "useConfigShareMethod", false, "A way of sharing your music with friends without needing a music content-mod. \nPut your music in 'BepInEx\\config\\Custom Songs' and simply share your profile code/file. \nWARNING: Sharing modpacks via profile code has a size limit of 20MB! \nIf you plan on using a lot of songs that way, you'll have to share your profile file!"); if (!isPluginMethodEnabled.Value && !isConfigShareEnabled.Value) { isPluginMethodEnabled.Value = true; } } } }