From 15c7c844db5c82dbe0e53c1819f18554561d8790 Mon Sep 17 00:00:00 2001 From: Kaioru Date: Thu, 16 Nov 2023 00:09:07 +0800 Subject: [PATCH] Add call method to plugins for cross-mod support --- src/common/Edelstein.Common.Plugin/PluginHost.cs | 1 + src/common/Edelstein.Common.Plugin/PluginManager.cs | 1 + src/protocol/Edelstein.Protocol.Plugin/IPlugin.cs | 3 +++ src/protocol/Edelstein.Protocol.Plugin/IPluginHost.cs | 1 + 4 files changed, 6 insertions(+) diff --git a/src/common/Edelstein.Common.Plugin/PluginHost.cs b/src/common/Edelstein.Common.Plugin/PluginHost.cs index 4a3828825..6c8bd2d1a 100644 --- a/src/common/Edelstein.Common.Plugin/PluginHost.cs +++ b/src/common/Edelstein.Common.Plugin/PluginHost.cs @@ -10,6 +10,7 @@ public record PluginHost( IConfiguration Config, string DirectoryHost, string DirectoryPlugin, + IPluginManager Manager, IPlugin Plugin ) : IPluginHost { diff --git a/src/common/Edelstein.Common.Plugin/PluginManager.cs b/src/common/Edelstein.Common.Plugin/PluginManager.cs index 99f919452..81bfe1ae6 100644 --- a/src/common/Edelstein.Common.Plugin/PluginManager.cs +++ b/src/common/Edelstein.Common.Plugin/PluginManager.cs @@ -60,6 +60,7 @@ await Insert(new PluginHost( configuration, directoryHost, directoryPlugin, + this, plugin )); } diff --git a/src/protocol/Edelstein.Protocol.Plugin/IPlugin.cs b/src/protocol/Edelstein.Protocol.Plugin/IPlugin.cs index 2b4c32a29..401bec3d8 100644 --- a/src/protocol/Edelstein.Protocol.Plugin/IPlugin.cs +++ b/src/protocol/Edelstein.Protocol.Plugin/IPlugin.cs @@ -7,4 +7,7 @@ public interface IPlugin : IIdentifiable Task OnInit(IPluginHost host, TContext ctx); Task OnStart(IPluginHost host, TContext ctx); Task OnStop(); + + Task Call(string type, params object[] args) + => Task.FromResult(default); } diff --git a/src/protocol/Edelstein.Protocol.Plugin/IPluginHost.cs b/src/protocol/Edelstein.Protocol.Plugin/IPluginHost.cs index ab0493d84..973af74c2 100644 --- a/src/protocol/Edelstein.Protocol.Plugin/IPluginHost.cs +++ b/src/protocol/Edelstein.Protocol.Plugin/IPluginHost.cs @@ -14,5 +14,6 @@ public interface IPluginHost : IIdentifiable string DirectoryHost { get; } string DirectoryPlugin { get; } + IPluginManager Manager { get; } IPlugin Plugin { get; } }