public void Initialize(DalamudPluginInterface pluginInterface) { PluginInterface = pluginInterface; PluginConfiguration = pluginInterface.GetPluginConfig() as VisibilityConfiguration ?? new VisibilityConfiguration(); PluginConfiguration.Init(this, pluginInterface); PluginInterface.CommandManager.AddHandler(PluginCommandName, new CommandInfo(PluginCommand) { HelpMessage = $"Shows the config for the visibility plugin.\nAdditional help available via '{PluginCommandName} help'", ShowInHelp = true }); PluginInterface.CommandManager.AddHandler(VoidCommandName, new CommandInfo(VoidPlayer) { HelpMessage = $"Adds player to void list.\nUsage: {VoidCommandName} <charactername> <worldname> <reason>", ShowInHelp = true }); PluginInterface.CommandManager.AddHandler(VoidTargetCommandName, new CommandInfo(VoidTargetPlayer) { HelpMessage = $"Adds targeted player to void list.\nUsage: {VoidTargetCommandName} <reason>", ShowInHelp = true }); PluginInterface.CommandManager.AddHandler(WhitelistCommandName, new CommandInfo(WhitelistPlayer) { HelpMessage = $"Adds player to whitelist.\nUsage: {WhitelistCommandName} <charactername> <worldname>", ShowInHelp = true }); PluginInterface.CommandManager.AddHandler(WhitelistTargetCommandName, new CommandInfo(WhitelistTargetPlayer) { HelpMessage = $"Adds targeted player to whitelist.\nUsage: {WhitelistTargetCommandName}", ShowInHelp = true }); _characterDrawResolver = new CharacterDrawResolver(); _characterDrawResolver.Init(pluginInterface, PluginConfiguration); Common = new XivCommonBase(PluginInterface, Hooks.ContextMenu); PluginContextMenu = new ContextMenu(this); if (PluginConfiguration.EnableContextMenu) { PluginContextMenu.Toggle(); } PluginInterface.Framework.OnUpdateEvent += FrameworkOnOnUpdateEvent; PluginInterface.UiBuilder.OnBuildUi += BuildUi; PluginInterface.UiBuilder.OnOpenConfigUi += OpenConfigUi; PluginInterface.Framework.Gui.Chat.OnChatMessage += OnChatMessage; }
/// <summary> /// Initializes a new instance of the <see cref="PriceCheckPlugin"/> class. /// </summary> public PriceCheckPlugin() { Task.Run(() => { try { this.LoadConfig(); this.HandleFreshInstall(); this.localization = new Localization(PluginInterface, CommandManager); this.PriceService = new PriceService(this); this.PluginCommandManager = new PluginCommandManager(this); this.UniversalisClient = new UniversalisClient(this); this.XivCommon = new XivCommonBase(Hooks.ContextMenu); this.ContextMenuManager = new ContextMenuManager(this); this.HoveredItemManager = new HoveredItemManager(this); ClientState.Login += this.Login; this.LoadUI(); } catch (Exception ex) { Logger.LogError(ex, "Failed to initialize plugin."); } }); }
/// <summary> /// Initializes a new instance of the <see cref="PlayerTrackPlugin"/> class. /// </summary> public PlayerTrackPlugin() { Task.Run(() => { try { // setup common libs this.localization = new Localization(PluginInterface, CommandManager); this.BackupManager = new BackupManager(PluginInterface.GetPluginConfigDirectory()); this.XivCommon = new XivCommonBase(Hooks.NamePlates); // load config try { this.Configuration = PluginInterface.GetPluginConfig() as PlayerTrackConfig ?? new PlayerTrackConfig(); } catch (Exception ex) { Logger.LogError("Failed to load config so creating new one.", ex); this.Configuration = new PlayerTrackConfig(); this.SaveConfig(); } // setup services this.BaseRepository = new BaseRepository(GetPluginFolder()); this.LodestoneService = new LodestoneService(this); this.ActorManager = new ActorManager(this); this.CategoryService = new CategoryService(this); this.EncounterService = new EncounterService(this); this.PlayerService = new PlayerService(this); this.VisibilityService = new VisibilityService(this); this.FCNameColorService = new FCNameColorService(this); this.PlayerTrackProvider = new PlayerTrackProvider(PluginInterface, new PlayerTrackAPI(this)); this.WindowManager = new WindowManager(this); this.PluginCommandManager = new PluginCommandManager(this); this.NamePlateManager = new NamePlateManager(this); // run backup this.backupTimer = new Timer { Interval = this.Configuration.BackupFrequency, Enabled = false }; this.backupTimer.Elapsed += this.BackupTimerOnElapsed; var pluginVersion = Assembly.GetExecutingAssembly().VersionNumber(); if (this.Configuration.PluginVersion < pluginVersion) { Logger.LogInfo("Running backup since new version detected."); this.RunUpgradeBackup(); this.Configuration.PluginVersion = pluginVersion; this.SaveConfig(); } else { this.BackupTimerOnElapsed(this, null); } // migrate if needed var success = Migrator.Migrate(this); if (success) { // special handling for fresh install this.HandleFreshInstall(); // reset categories if failed to load if (this.CategoryService.GetCategories().Length == 0) { this.CategoryService.ResetCategories(); } // start plugin this.IsDoneLoading = true; this.backupTimer.Enabled = true; this.VisibilityService.Start(); this.FCNameColorService.Start(); this.ActorManager.Start(); this.WindowManager.AddWindows(); } } catch (Exception ex) { Logger.LogError(ex, "Failed to initialize plugin."); } }); }