Пример #1
0
        public override void OnDisabled()
        {
            if (!Config.IsEnabled)
            {
                return;
            }

            PlayerEvents.Verified -= PlayerEventHandlers.Verified;
            PlayerEvents.Spawning -= PlayerEventHandlers.Spawning;
            PlayerEventHandlers    = null;

            PatreonConfig = null;

            Log.Info("Disabled.");
        }
Пример #2
0
        public override void OnEnabled()
        {
            if (!Config.IsEnabled)
            {
                return;
            }

            Log.Info($"{Name} v{version} by {Author}. Last Modified: {LastModified}.");
            Log.Info("Inspired by DankRushen/PatreonPlugin on GitHub.");

            Log.Info("Loading base scripts.");
            UpdateChecker = new UpdateChecker(this);

            if (Config.CheckForUpdates)
            {
                _ = UpdateChecker.CheckForUpdate();
            }

            try
            {
                Log.Info("Loading patreon configuration.");
                PatreonConfig = new PatreonConfig();

                if (!Directory.Exists(ConfigurationFolderPath))
                {
                    Log.Info($"{ConfigurationFolderPath} does not exist. Creating folder...");
                    Directory.CreateDirectory(ConfigurationFolderPath);
                }


                if (File.Exists(ConfigurationFolderPath + "Configuration.json"))
                {
                    PatreonConfig = LoadPatreonConfig();
                }
                else
                {
                    Log.Info($"{ConfigurationFolderPath}Configuration.json does not exist. Saving the defaults...");
                    Log.Info("Modify the configuration to suit your needs!!");
                    SavePatreonConfig();
                    PatreonConfig = LoadPatreonConfig();
                }

                if (!PatreonConfig.PatreonRanks.ContainsKey("None"))
                {
                    //None does not exist. Init the defaults.
                    Log.Warn("None Patreon rank does not exist. Using defaults.");
                    PatreonConfig.PatreonRanks.Add("None", new PatreonRank());
                }
            }

            catch (Exception ex)
            {
                Log.Error($"Patreon Configuration parse error. Exception: {ex}");
            }

            Log.Info("Registering Event Handlers.");

            PlayerEventHandlers    = new PlayerEventHandlers(this);
            PlayerEvents.Verified += PlayerEventHandlers.Verified;
            PlayerEvents.Spawning += PlayerEventHandlers.Spawning;


            Log.Info("Done.");
        }