This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
beatsaber-scoretracker/Mod/Plugin.cs
Liam 8e3a46f8bc
All checks were successful
Release Mod / Build (push) Successful in 25s
mod: impl config for api url
2024-08-07 08:26:12 +01:00

56 lines
1.4 KiB
C#

using IPA;
using IPALogger = IPA.Logging.Logger;
using SiraUtil.Zenject;
using System.Threading.Tasks;
using ScoreTracker.API;
using IPA.Config.Stores;
using IPA.Config;
using ScoreTracker.Configuration;
using ScoreTracker.Installers;
namespace ScoreTracker
{
[Plugin(RuntimeOptions.DynamicInit)]
[NoEnableDisable]
public class Plugin
{
internal static Plugin Instance { get; private set; }
internal static IPALogger Log { get; private set; }
[Init]
public Plugin(IPALogger logger, Zenjector zenjector, Config config)
{
Instance = this;
Log = logger; // Setup the logger
// Setup Zenject
zenjector.UseLogger(logger);
zenjector.UseMetadataBinder<Plugin>();
zenjector.Install<AppInstaller>(Location.App);
// Setup the config
PluginConfig.Instance = config.Generated<PluginConfig>();
}
[OnStart]
public void OnApplicationStart()
{
Log.Info("OnApplicationStart");
// Ensure the user is logged in
Task.Factory.StartNew(async () =>
{
var authHelper = new AuthHelper();
await authHelper.EnsureLoggedIn();
});
}
[OnExit]
public void OnApplicationQuit()
{
Log.Info("OnApplicationQuit");
}
}
}