What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

How to disable a plugin from another plugin

rantay

New Member
Joined
Mar 20, 2015
Messages
15
Reaction score
0
Hi,

I would like to write a plugin that will start / stop the QuestPlugin.
I found the following function in the EB manual but could you please tell me what to put as the function argument?

I have tried "QuestPlugin", Loki.Bot.PluginManager.QuestPlugin, Loki.Bot.IPlugin.QuestPlugin and many many other combinations but nothing seems to work.

Loki.Bot.PluginManager.Enable(Loki.Bot.IPlugin) Enables the specified plugin.
Loki.Bot.PluginManager.Disable(Loki.Bot.IPlugin) Disables the specified plugin.

I have also found the start and stop class

Loki.Bot.PluginManager.Stop(Loki.Bot.IPlugin)
Loki.Bot.PluginManager.Stop(Loki.Bot.IPlugin)

But what is the difference between enabling/disabling and starting/stopping a plugin?

Thank you very much!
R
 
No idea where the last comment from here posted by Pusedex is gone, but I have tried what he suggested:

var QuestPluginHandle = PluginManager.EnabledPlugins.FirstOrDefault(p => p.Name == "QuestPlugin");
Loki.Bot.PluginManager.Disable(QuestPluginHandle);

Unfortunately it resulting in the following error:

Exception during plugin Disable.System.InvalidOperationException: Cannot Disable plugins while the bot is running.
at Loki.Bot.PluginManager.Disable(IPlugin plugin)


Looking into the QuestPlugin itself, I have noticed that it is possible to untick the "Enable" checkbox in the settings tab of the plugin and it will stop/start the plugin even when the bot is running.

I have been trying to access QuestPluginSettings.Instance.QuestPluginEnabled which seems to be linked with the checkbox directly, from another plugin, with no success.

I am trying to write a plugin which will be able stop and start QuestPlugin, I will be very grateful for a kind person to point me in a direction to achieve this, please.

Thank you very much.
 
No idea where the last comment from here posted by Pusedex is gone, but I have tried what he suggested:



Unfortunately it resulting in the following error:

Exception during plugin Disable.System.InvalidOperationException: Cannot Disable plugins while the bot is running.
at Loki.Bot.PluginManager.Disable(IPlugin plugin)


Looking into the QuestPlugin itself, I have noticed that it is possible to untick the "Enable" checkbox in the settings tab of the plugin and it will stop/start the plugin even when the bot is running.

I have been trying to access QuestPluginSettings.Instance.QuestPluginEnabled which seems to be linked with the checkbox directly, from another plugin, with no success.

I am trying to write a plugin which will be able stop and start QuestPlugin, I will be very grateful for a kind person to point me in a direction to achieve this, please.

Thank you very much.

You have to hook this "event" or the behavior in the initialization or the enableable of your plugin (in the "Enable()" or "Initialize()" part), if the plugin is running you can't disable it.
 
Thank you toNyx, this is what I understood from the error message.

Can you think of any way of stopping/starting Quest plugin whilst the bot is running?
 
Weird, no idea where my reply went. There must have been a forum issue, but it's not showing up at all.

I'm pretty sure I mentioned that issue, but enabling/disabling plugins at runtime is not supported by design because it breaks complex plugins that need to be updating constantly or are making changes to the execution flow of the task manager. If a plugin is enabled for start, and does logic that affects the bot, then gets disabled, it won't receive a Stop to reset any changes it might have made. Or the opposite, it's not enabled for Start, doesn't get the hooks it needs registered There's still ways to do it right now because of the design flaw Release has, but it has been fixed for Beta. That is, if you call QuestPluginHandle.Disable() directly, the plugin will set it's enabled state to false, if coded to do so, and the plugin would no longer be updated. However, a plugin could be coded not to do this, and ignore that and always keep itself enabled.

The solution for this is that the plugin must be coded to support "soft disables", such that it can still run and get its updates, but not do whatever actions you're wanting to prevent. In Release, this is not easily doable because of dynamic loading issues when it comes to types. Your plugin could be loaded before another plugin, and not have access to that Type at compile time, since it doesn't exist yet. You'd have a direct dependency on that object which starts to spiral things out of control if your plugin is also meant to work without the other plugin even being present.

In Beta, this is fixed by some changes to the interfaces all bots, plugins, and routines inherit from. If you read over this thread, you'll see that you'll be able to call a loosely typed function that each plugin can interpret however it needs to be able to communicate between plugins without having any type dependencies. For example,
Code:
/// <summary>
		/// Non-coroutine logic to execute.
		/// </summary>
		/// <param name="name">The name of the logic to invoke.</param>
		/// <param name="param">The data passed to the logic.</param>
		/// <returns>Data from the executed logic.</returns>
		public object Execute(string name, params object[] param)
		{
			if (name == "Enable")
			{
				_enabled = true;
				Log.InfoFormat("[ClearCursorTask] Enabled.");
			}
			else if (name == "Disable")
			{
				_enabled = false;
				Log.InfoFormat("[ClearCursorTask] Disabled.");
			}
			else if (name == "IsEnabled")
			{
				return _enabled;
			}
			return null;
		}

That task now supports being "soft" disabled/enabled via a message so you don't have to know about the actual ClearCursorTask type to enable/disable it.
 
Back
Top