|
| 1 | +using LabApi.Loader.Features.Plugins; |
| 2 | +using System; |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.Linq; |
| 5 | +using System.Text; |
| 6 | +using System.Threading.Tasks; |
| 7 | +using LabApi.Events.CustomHandlers; |
| 8 | +using LabApi.Features; |
| 9 | +using LabApi.Features.Console; |
| 10 | +using LabApi.Loader.Features.Plugins.Enums; |
| 11 | +using HarmonyLib; |
| 12 | + |
| 13 | +namespace ScpProximityChat_LabAPI |
| 14 | +{ |
| 15 | + public class ScpProximityChat : Plugin<Config> |
| 16 | + { |
| 17 | + public static ScpProximityChat Instance { get; private set; } |
| 18 | + public Events Events { get; } = new Events(); |
| 19 | + public override string Name { get; } = "ScpProximityChat"; |
| 20 | + public override string Description { get; } = "Makes SCPs able to talk inside the proximity chat."; |
| 21 | + public override string Author { get; } = "FortNbreak"; |
| 22 | + public override Version Version { get; } = new Version(1, 0, 0); |
| 23 | + public override Version RequiredApiVersion { get; } = new Version(LabApiProperties.CompiledVersion); |
| 24 | + public override string ConfigFileName { get; set; } = "scpproximitychat.yml"; |
| 25 | + private static readonly Harmony HarmonyPatcher = new("scpproximitymodule.fortnbreak.com"); |
| 26 | + public static Config SharedConfig { get; private set; } |
| 27 | + |
| 28 | + public override void Enable() |
| 29 | + { |
| 30 | + if (!base.Config.Enabled) |
| 31 | + { |
| 32 | + Logger.Info("Plugin is set to not start, change the configuration file if this is a mistake"); |
| 33 | + return; |
| 34 | + } |
| 35 | + |
| 36 | + Logger.Info("Starting plugin..."); |
| 37 | + |
| 38 | + ScpProximityChat.Instance = this; |
| 39 | + |
| 40 | + Logger.Info("Loading config."); |
| 41 | + |
| 42 | + SharedConfig = base.Config; |
| 43 | + |
| 44 | + Logger.Info("Registering events..."); |
| 45 | + |
| 46 | + CustomHandlersManager.RegisterEventsHandler<Events>(this.Events); |
| 47 | + |
| 48 | + Logger.Info("Applying Harmony patches."); |
| 49 | + |
| 50 | + HarmonyPatcher.PatchAll(); |
| 51 | + |
| 52 | + Logger.Info("Plugin has been enabled."); |
| 53 | + } |
| 54 | + |
| 55 | + public override void Disable() |
| 56 | + { |
| 57 | + Logger.Info("Stopping plugin..."); |
| 58 | + |
| 59 | + ScpProximityChat.Instance = null; |
| 60 | + |
| 61 | + Logger.Info("Loading config."); |
| 62 | + |
| 63 | + SharedConfig = null; |
| 64 | + |
| 65 | + Logger.Info("Unregistering events..."); |
| 66 | + |
| 67 | + CustomHandlersManager.UnregisterEventsHandler<Events>(this.Events); |
| 68 | + |
| 69 | + Logger.Info("Unapplying Harmony patches."); |
| 70 | + |
| 71 | + HarmonyPatcher.UnpatchAll(); |
| 72 | + |
| 73 | + Logger.Info("Plugin has been disabled."); |
| 74 | + } |
| 75 | + } |
| 76 | +} |
0 commit comments