Beispiel #1
0
        public void GetSchemas()
        {
            // Get command schemas from addons
            for (int addonIndex = 0; addonIndex < CoreList.Count; addonIndex++)
            {
                try
                {
                    CommandRuleSets cmds = CoreList[addonIndex].DefineCommandSchemas();

                    if (cmds != null)
                    {
                        foreach (var cmd in cmds)
                        {
                            commands.ValidateAddSchema(cmd);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "addon {0}: Failed to load command schemas", CoreList[addonIndex].Name);
                }
            }
        }
Beispiel #2
0
        public void UserInitialize(AddonInjections CoreList)
        {
            this.ServerQueryConnection = CoreList[typeof(ServerQueryConnection.ServerQueryConnection).Name] as ServerQueryConnection.ServerQueryConnection;

            ServerQueryConnection.BotCommandAttempt += onBotCommandAttempt;

            // Hard-coded for now..
            //addons.Add(new Core.InputOwner.InputOwnerAddon());
            //addons.Add(new Core.Test.TestAddon());
            //addons.Add(new Core.ServerQuery.ServerQueryAddon());

            List <IAddon> failedAddons = new List <IAddon>();

            // Configure each addon with the basic stuff
            for (int addonIndex = 0; addonIndex < addons.Count; addonIndex++)
            {
                try
                {
                    addons[addonIndex].Configure(this.Subscriber, this.ServerQueryConnection);
                }
                catch (Exception)
                {
                    logger.Error("Removing addon {0}: failed to load during configuration", addons[addonIndex].CoreName);
                    addons.RemoveAt(addonIndex);
                }
            }

            // Wire up any injection requests by the addons to addon manager
            foreach (IAddon addon in addons)
            {
                addon.InjectionRequest += onInjectionRequest;
            }

            // Initialize each addon
            for (int addonIndex = 0; addonIndex < addons.Count; addonIndex++)
            {
                try
                {
                    addons[addonIndex].Initialize();
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Removing addon {0}: failed to load during initialization", addons[addonIndex].CoreName);
                    addons.RemoveAt(addonIndex);
                }
            }

            // Let addons define their dependencies
            for (int addonIndex = 0; addonIndex < addons.Count; addonIndex++)
            {
                try
                {
                    addons[addonIndex].DefineDependencies();
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Removing addon {0}: failed to load during dependency definitions", addons[addonIndex].CoreName);
                    addons.RemoveAt(addonIndex);
                }
            }

            // Initialize the dependencies
            for (int addonIndex = 0; addonIndex < addons.Count; addonIndex++)
            {
                try
                {
                    addons[addonIndex].InitializeDependencies();
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Removing addon {0}: failed to load during dependency initialization", addons[addonIndex].CoreName);
                    addons.RemoveAt(addonIndex);
                }
            }

            // Get command schemas from addons
            for (int addonIndex = 0; addonIndex < addons.Count; addonIndex++)
            {
                try
                {
                    CommandRuleSets cmds = addons[addonIndex].DefineCommandSchemas();

                    if (cmds != null)
                    {
                        foreach (var cmd in cmds)
                        {
                            commands.ValidateAddSchema(cmd);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Warn(ex, "addon {0}: Could not load command schemas", addons[addonIndex].CoreName);
                }
            }
        }