示例#1
0
        public PluginManager(Dalamud dalamud, string pluginDirectory, string defaultPluginDirectory)
        {
            this.dalamud                = dalamud;
            this.pluginDirectory        = pluginDirectory;
            this.defaultPluginDirectory = defaultPluginDirectory;

            this.dalamudInterface = new DalamudPluginInterface(dalamud);
        }
示例#2
0
        private void LoadPluginsAt(string folder)
        {
            if (Directory.Exists(folder))
            {
                Log.Debug("Loading plugins at {0}", folder);

                var pluginFileNames = Directory.GetFiles(folder, "*.dll");

                var assemblies = new List <Assembly>(pluginFileNames.Length);
                foreach (var dllFile in pluginFileNames)
                {
                    Log.Debug("Loading assembly at {0}", dllFile);
                    var assemblyName   = AssemblyName.GetAssemblyName(dllFile);
                    var pluginAssembly = Assembly.Load(assemblyName);
                    assemblies.Add(pluginAssembly);
                }

                var interfaceType        = typeof(IDalamudPlugin);
                var foundImplementations = new List <Type>();
                foreach (var assembly in assemblies)
                {
                    if (assembly != null)
                    {
                        Log.Debug("Loading types for {0}", assembly.FullName);
                        var types = assembly.GetTypes();
                        foreach (var type in types)
                        {
                            if (type.IsInterface || type.IsAbstract)
                            {
                                continue;
                            }

                            if (type.GetInterface(interfaceType.FullName) != null)
                            {
                                foundImplementations.Add(type);
                            }
                        }
                    }
                }

                this.plugins = new List <IDalamudPlugin>(foundImplementations.Count);
                foreach (var pluginType in foundImplementations)
                {
                    var plugin = (IDalamudPlugin)Activator.CreateInstance(pluginType);

                    var dalamudInterface = new DalamudPluginInterface(this.dalamud, pluginType.Assembly.GetName().Name);

                    plugin.Initialize(dalamudInterface);
                    Log.Information("Loaded plugin: {0}", plugin.Name);
                    this.plugins.Add(plugin);
                }
            }
        }
        public MarketBoardActionButton(Dalamud.Plugin.DalamudPluginInterface pluginInterface, ItemSearchPluginConfig pluginConfig)
        {
            this.pluginInterface = pluginInterface;
            this.pluginConfig    = pluginConfig;

            try {
                pluginInterface.Subscribe("MarketBoardPlugin", (o) => {
                    PluginLog.Log("Recieved Message from MarketBoardPlugin");
                    dynamic msg = o;
                    if (msg.Target == "ItemSearchPlugin" && msg.Action == "pong")
                    {
                        marketBoardResponsed = true;
                    }
                });
            } catch (Exception ex) {
                PluginLog.LogError($"Exception Subscribing to MarketBoardPlugin: {ex.Message}");
            }

            dynamic areYouThereMarketBoard = new ExpandoObject();

            areYouThereMarketBoard.Target = "MarketBoardPlugin";
            areYouThereMarketBoard.Action = "ping";
            pluginInterface.SendMessage(areYouThereMarketBoard);
        }