using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Tabs Poof Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Tabs Poof Mod")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8aad4f38-2ad4-4206-bf0b-7d28fb6d5c2e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SlimeCoreFixerr;
public enum moideoflistt
{
fixd,
none,
vanilla
}
[BepInPlugin("bayturtleking.slmacorefixturt", "SLMA Core Fix", "0.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class slimecorefixermod : BaseUnityPlugin
{
internal static ManualLogSource log;
internal static ConfigEntry<moideoflistt> moideoflisttcfg;
internal static ConfigEntry<bool> deletedumpcfg;
internal static ConfigEntry<bool> dedupecfg;
internal static ConfigEntry<bool> silencecfg;
private static bool isloghook;
private const string dafodlerfordump = "史莱姆的粘液";
private void Awake()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
log = ((BaseUnityPlugin)this).Logger;
bindcfg();
try
{
new Harmony("bayturtleking.slmacorefixturt").PatchAll();
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("harmony said no :( " + ex));
}
if (silencecfg.Value)
{
hooklogfilter();
}
if (dedupecfg.Value)
{
dedupegoslma();
}
if (deletedumpcfg.Value)
{
yeetdump();
}
}
private void bindcfg()
{
moideoflisttcfg = ((BaseUnityPlugin)this).Config.Bind<moideoflistt>("ModList", "mode", moideoflistt.fixd, "what do with mod list. fixd = it works now, none = no button, vanilla = it stays broken");
deletedumpcfg = ((BaseUnityPlugin)this).Config.Bind<bool>("Cleanup", "deletedump", true, "delete the chinese dump folder slma make every start. it still gets made; just deleted");
dedupecfg = ((BaseUnityPlugin)this).Config.Bind<bool>("Cleanup", "dedupegoslma", true, "slma put like 5 goslma on same thing. keep only 1");
silencecfg = ((BaseUnityPlugin)this).Config.Bind<bool>("Logging", "silencespam", true, "get rid of the random logs that SLMA spams");
}
private void hooklogfilter()
{
if (!isloghook)
{
isloghook = true;
Debug.unityLogger.logHandler = (ILogHandler)(object)new spamfilter(Debug.unityLogger.logHandler);
}
}
private void dedupegoslma()
{
try
{
GOSLMA[] array = Resources.FindObjectsOfTypeAll<GOSLMA>();
HashSet<int> hashSet = new HashSet<int>();
GOSLMA[] array2 = array;
foreach (GOSLMA val in array2)
{
if (!((Object)(object)val == (Object)null) && !hashSet.Add(((Object)((Component)val).gameObject).GetInstanceID()))
{
Object.DestroyImmediate((Object)(object)val, true);
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("no dedupe thing :( " + ex.Message));
}
}
private void yeetdump()
{
try
{
if (Directory.Exists("史莱姆的粘液"))
{
Directory.Delete("史莱姆的粘液", recursive: true);
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("no get rid of dis: " + ex.Message));
}
}
}
public class spamfilter : ILogHandler
{
private static readonly string[] exact = new string[2] { "Cringed", "Instant" };
private static readonly string[] prefixes = new string[4] { "Models Load :", "Textures Load :", "Sounds Load :", "Bundles Load :" };
private readonly ILogHandler origg;
public spamfilter(ILogHandler origg)
{
this.origg = origg;
}
public void LogFormat(LogType logtyp, Object ctx, string fmt, params object[] fmtargs)
{
//IL_001d: 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)
string msgg;
try
{
msgg = ((fmtargs != null && fmtargs.Length != 0) ? string.Format(fmt, fmtargs) : fmt);
}
catch
{
msgg = fmt;
}
if (!isspam(logtyp, msgg))
{
origg.LogFormat(logtyp, ctx, fmt, fmtargs);
}
}
public void LogException(Exception exxc, Object ctx)
{
origg.LogException(exxc, ctx);
}
private bool isspam(LogType logtyp, string msgg)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(msgg))
{
return false;
}
if ((int)logtyp == 0 && msgg.All(char.IsDigit))
{
return true;
}
if (exact.Contains(msgg))
{
return true;
}
string[] array = prefixes;
foreach (string value in array)
{
if (msgg.StartsWith(value, StringComparison.Ordinal))
{
return true;
}
}
return false;
}
}
[HarmonyPatch(typeof(SSLoader), "SceneLoaded")]
public static class scenepostfix
{
public static void Postfix()
{
try
{
if (slimecorefixermod.moideoflisttcfg.Value == moideoflistt.none)
{
GameObject val = GameObject.Find("Mod List");
if ((Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)val);
}
}
}
catch (Exception ex)
{
slimecorefixermod.log.LogWarning((object)("post the fix trhing for button died :( " + ex.Message));
}
}
}
[HarmonyPatch(typeof(FhpListUI), "Start")]
public static class liststartpatch
{
public static bool Prefix(FhpListUI __instance)
{
if (slimecorefixermod.moideoflisttcfg.Value != moideoflistt.fixd)
{
return true;
}
if ((Object)(object)((Component)__instance).GetComponent<fixedlist>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<fixedlist>();
}
return false;
}
}
public class fixedlist : MonoBehaviour
{
private class rowdata
{
public Sprite spr;
public string nam;
public string ver;
public string third;
}
private const int perpage = 3;
private static readonly string[] rownames = new string[3] { "Memeber (2)", "Memeber (1)", "Memeber" };
private readonly List<rowdata> rows = new List<rowdata>();
private int page;
private int pagecount = 1;
private void Start()
{
try
{
buildrows();
}
catch (Exception ex)
{
slimecorefixermod.log.LogError((object)("no build mod row row :( " + ex));
}
pagecount = Math.Max(1, (rows.Count + 3 - 1) / 3);
page = 0;
todotheabuttonssas();
showpagee();
}
private void buildrows()
{
foreach (PluginInfo value in Chainloader.PluginInfos.Values)
{
try
{
rows.Add(new rowdata
{
spr = iconfinder.geticon(value),
nam = value.Metadata.Name,
ver = value.Metadata.Version.ToString(),
third = value.Metadata.GUID
});
}
catch (Exception ex)
{
slimecorefixermod.log.LogWarning((object)("skip this one because it bad: " + ex.Message));
}
}
}
private void todotheabuttonssas()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
Transform val = ((Component)this).transform.Find("Lick-r");
Transform val2 = ((Component)this).transform.Find("Lick-l");
Button val3 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponentInChildren<Button>() : null);
Button val4 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponentInChildren<Button>() : null);
if ((Object)(object)val3 != (Object)null)
{
((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
{
todanext(1);
});
}
else
{
slimecorefixermod.log.LogWarning((object)"no get right arrow thingyt");
}
if ((Object)(object)val4 != (Object)null)
{
((UnityEvent)val4.onClick).AddListener((UnityAction)delegate
{
todanext(-1);
});
}
else
{
slimecorefixermod.log.LogWarning((object)"no get left arrow thing");
}
}
private void todanext(int dirr)
{
page = Math.Max(0, Math.Min(pagecount - 1, page + dirr));
showpagee();
}
private void showpagee()
{
Transform val = ((Component)this).transform.Find("ListIndex");
if ((Object)(object)val != (Object)null)
{
Text componentInChildren = ((Component)val).GetComponentInChildren<Text>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.text = page + 1 + "/" + pagecount;
}
}
for (int i = 0; i < 3; i++)
{
Transform val2 = ((Component)this).transform.Find(rownames[i]);
if ((Object)(object)val2 == (Object)null)
{
continue;
}
int num = page * 3 + i;
if (num >= rows.Count)
{
((Component)val2).gameObject.SetActive(false);
continue;
}
((Component)val2).gameObject.SetActive(true);
if (val2.childCount >= 4)
{
rowdata rowdata = rows[num];
Image componentInChildren2 = ((Component)val2.GetChild(0)).GetComponentInChildren<Image>();
if ((Object)(object)componentInChildren2 != (Object)null && (Object)(object)rowdata.spr != (Object)null)
{
componentInChildren2.sprite = rowdata.spr;
}
settxtt(val2.GetChild(1), rowdata.nam);
settxtt(val2.GetChild(2), rowdata.ver);
settxtt(val2.GetChild(3), rowdata.third);
}
}
}
private static void settxtt(Transform tr, string ss)
{
Text componentInChildren = ((Component)tr).GetComponentInChildren<Text>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.text = ss ?? "";
}
}
}
public static class iconfinder
{
private static readonly Dictionary<string, Sprite> iconcache = new Dictionary<string, Sprite>();
private static Sprite defaulticon;
public static Sprite geticon(PluginInfo pinf)
{
string gUID = pinf.Metadata.GUID;
if (iconcache.TryGetValue(gUID, out var value) && (Object)(object)value != (Object)null)
{
return value;
}
Sprite val = fromdisk(pinf, "icon.png") ?? fromembed(pinf, "mod.png") ?? getdefaultt();
iconcache[gUID] = val;
return val;
}
private static Sprite fromdisk(PluginInfo pinf, string filenm)
{
try
{
string text = findondiskk(pinf.Location, filenm);
if (text == null)
{
return null;
}
return spritefrombyt(File.ReadAllBytes(text));
}
catch (Exception ex)
{
slimecorefixermod.log.LogWarning((object)("could no load icon for " + pinf.Metadata.Name + " :( " + ex.Message));
return null;
}
}
private static Sprite fromembed(PluginInfo pinf, string nm)
{
try
{
Assembly assembly = (((Object)(object)pinf.Instance != (Object)null) ? ((object)pinf.Instance).GetType().Assembly : null);
if (assembly == null)
{
return null;
}
string text = assembly.GetManifestResourceNames().FirstOrDefault((string rn) => rn.Equals(nm, StringComparison.OrdinalIgnoreCase) || rn.EndsWith("." + nm, StringComparison.OrdinalIgnoreCase));
if (text == null)
{
return null;
}
using Stream stream = assembly.GetManifestResourceStream(text);
if (stream == null)
{
return null;
}
using MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
return spritefrombyt(memoryStream.ToArray());
}
catch (Exception ex)
{
slimecorefixermod.log.LogWarning((object)("no get the embed icon for " + pinf.Metadata.Name + " :( " + ex.Message));
return null;
}
}
private static string findondiskk(string plugloc, string filenm)
{
if (string.IsNullOrEmpty(plugloc) || string.IsNullOrEmpty(filenm))
{
return null;
}
try
{
char directorySeparatorChar = Path.DirectorySeparatorChar;
string text = Path.GetFullPath(Paths.PluginPath).TrimEnd(new char[1] { directorySeparatorChar });
string text2 = Path.GetFullPath(Path.GetDirectoryName(plugloc)).TrimEnd(new char[1] { directorySeparatorChar });
if (!text2.StartsWith(text + directorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{
if (text2.Equals(text, StringComparison.OrdinalIgnoreCase))
{
return null;
}
string text3 = Path.Combine(text2, filenm);
return File.Exists(text3) ? text3 : null;
}
while (text2 != null && text2.StartsWith(text + directorySeparatorChar, StringComparison.OrdinalIgnoreCase))
{
string text4 = Path.Combine(text2, filenm);
if (File.Exists(text4))
{
return text4;
}
text2 = Path.GetDirectoryName(text2);
}
}
catch
{
}
return null;
}
private static Sprite spritefrombyt(byte[] byts)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(2, 2);
if (!ImageConversion.LoadImage(val, byts))
{
Object.Destroy((Object)(object)val);
return null;
}
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
}
private static Sprite getdefaultt()
{
if ((Object)(object)defaulticon != (Object)null)
{
return defaulticon;
}
try
{
defaulticon = FhpListUI.GetSprite(typeof(FhpListUI).Assembly, "mod.jpg");
}
catch (Exception ex)
{
slimecorefixermod.log.LogWarning((object)("no get the default icon :(" + ex.Message));
}
return defaulticon;
}
}