BepInEx / BepInEx.ConfigurationManager

Plugin configuration manager for BepInEx
https://www.patreon.com/ManlyMarco
GNU Lesser General Public License v3.0
227 stars 54 forks source link

Craftopia plugins not detected past version 16.4 #70

Closed Eradev closed 1 year ago

Eradev commented 1 year ago

I wonder if it's because they require "HideManagerGameObject = true"?

ManlyMarco commented 1 year ago

Very unlikely, check game log for related errors. Maybe the plugins are using some obsolete APIs that got removed.

Eradev commented 1 year ago

It would've been easier if there was an error in the log. If a single plugin would at least appear in the list then I'd assume that some mod are erroneous, but that's not the case.

Anything in here screams obsolete API?

using System;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Oc;

namespace eradev.craftopia.DigitalClockDate
{
    [BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
    public class DigitalClockDatePlugin : BaseUnityPlugin
    {
        private const string ColorDefault = "white";
        private const string FormatDefault = @"hh\:mm";

        private static ConfigEntry<string> _color;
        private static ConfigEntry<string> _format;

        private static int _curMin = -1;

        private void Awake()
        {
            _color = Config.Bind("General", "color", ColorDefault, "Color of the time display");
            _format = Config.Bind("General", "format", FormatDefault, "Time format. See https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-timespan-format-strings");

            new Harmony(MyPluginInfo.PLUGIN_GUID).PatchAll();

            Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
        }

        [HarmonyPatch(typeof(OcClockUI), "Update")]
        public class OcClockUIUpdatePatch
        {
            public static void Postfix(
                OcClockUI __instance,
                string ____CurDayStr)
            {
                var dayMng = SingletonMonoBehaviour<OcDayMng>.Inst;

                if (dayMng.CurMin_60 == _curMin)
                {
                    return;
                }

                _curMin = dayMng.CurMin_60;

                __instance.ClockTextDay.text = $"{____CurDayStr} — <color={_color.Value}>{new TimeSpan((int)dayMng.CurHour, dayMng.CurMin_60, 0).ToString(_format.Value)}</color>";
            }
        }
    }
}
Eradev commented 1 year ago

Or could it be because they're an old Unity version? 2021.3.15f I think.

ManlyMarco commented 1 year ago

It seems fine, all that matters is that the plugin uses BaseUnityPlugin.Config.Bind. If it doesn't show up then it can mean either the plugin or config manager component dies early (in that case setting HideManagerGameObject = true might help, but might also create other issues like config manager not finding some plugins), or something messes with the plugin load process. You can use REPL console in runtime editor to run parts of config manager logic to see at what point it fails if you want to debug it.

ManlyMarco commented 1 year ago

Here's a build that works with HideManagerGameObject = true, see if that helps ConfigurationManager.zip

Eradev commented 1 year ago

Yes it does.

ManlyMarco commented 1 year ago

8fc53a4820624052794fd7cd9d367d01a0101aec