Ejemplo n.º 1
0
        public void Handle(string[] cmd)
        {
            var type = cmd[1];
            var path = cmd[2];

            switch (type)
            {
            case "load":
                BotPlugin p = new BotPlugin(path);

                if (p.Load())
                {
                    Console.WriteLine($"{p.Name} was loaded.");
                    Console.WriteLine(p.Description);
                }
                else
                {
                    Console.WriteLine(p.LastError);
                }
                break;

            case "unload":
                BotPlugin pn = BotPlugin.Plugins.FirstOrDefault(x => x.Path == path);

                if (pn.Unload())
                {
                    Console.WriteLine($"{pn.Name} was unloaded.");
                }
                else
                {
                    Console.WriteLine(pn.LastError);
                }
                break;
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            foreach (string plugin in JObject.Parse(File.ReadAllText("plugins.json"))["plugins"])
            {
                var p = new BotPlugin(plugin);

                if (p.Load())
                {
                    Console.WriteLine($"{p.Name} was loaded!");
                    Console.WriteLine(p.Description);
                }
                else
                {
                    Console.WriteLine(p.LastError);
                }
            }

            BotTerminal.Instance.Initialize();
        }
Ejemplo n.º 3
0
        internal static void GetBotPluginsInformation()
        {
            if (Server.IsSocketConnected() == false || Core.Player == null)
            {
                return;
            }

            List <BotPlugin> botPluginHolderList = new List <BotPlugin>();

            foreach (PluginContainer botPlugin in PluginManager.Plugins)
            {
                BotVersion botVersion = new BotVersion();
                botVersion.Build    = botPlugin.Plugin.Version.Build;
                botVersion.Major    = botPlugin.Plugin.Version.Major;
                botVersion.Minor    = botPlugin.Plugin.Version.Minor;
                botVersion.Revision = botPlugin.Plugin.Version.Revision;

                BotPlugin botPluginItem = new BotPlugin();
                botPluginItem.Author      = botPlugin.Plugin.Author;
                botPluginItem.Description = botPlugin.Plugin.Description;
                botPluginItem.Name        = botPlugin.Plugin.Name;
                botPluginItem.IsEnabled   = botPlugin.Enabled;
                botPluginItem.Version     = botVersion;

                botPluginHolderList.Add(botPluginItem);
            }

            LocalPlayer player = Core.Player;

            BotPluginsMessage botPluginsMessage = new BotPluginsMessage();

            botPluginsMessage.CoreAuthKey     = Settings.Instance.CoreAuthKey;
            botPluginsMessage.PlayerName      = player.Name;
            botPluginsMessage.Plugins         = new BotPlugins();
            botPluginsMessage.Plugins.Plugins = botPluginHolderList;

            Server.QueueMessage(JsonConvert.SerializeObject(botPluginsMessage));
        }