diff --git a/Code/Helpers/FrameworkBridge.cs b/Code/Helpers/FrameworkBridge.cs index 5d52023b..7fb90189 100644 --- a/Code/Helpers/FrameworkBridge.cs +++ b/Code/Helpers/FrameworkBridge.cs @@ -1,4 +1,5 @@ -using LabApi.Loader; +using LabApi.Features.Console; +using LabApi.Loader; using MEC; using SER.Code.Extensions; using SER.Code.MethodSystem; @@ -27,7 +28,7 @@ public void Load() _handles.Add(Timing.RunCoroutine(Await(framework))); } } - + public string StopAndGetLoadedFrameworksMessage() { Timing.KillCoroutines(_handles.ToArray()); @@ -39,12 +40,39 @@ public string StopAndGetLoadedFrameworksMessage() private IEnumerator Await(Framework framework) { - while (PluginLoader.EnabledPlugins.All(plg => plg.Name != framework.Name)) + for (int timer = 0; timer <= 3; timer++) { - yield return Timing.WaitForSeconds(0.1f); + yield return Timing.WaitForSeconds(1f); + + if (_found.Contains(framework)) + { + continue; + } + + if (PluginLoader.EnabledPlugins.All(plg => plg.Name != framework.Name) && !IsExiledCompatFrameworkLoaded(framework)) + { + continue; + } + + _found.Add(framework); + MethodIndex.LoadMethodsOfFramework(framework.Type); } - - _found.Add(framework); - MethodIndex.LoadMethodsOfFramework(framework.Type); + + Logger.Raw(StopAndGetLoadedFrameworksMessage(), ConsoleColor.DarkYellow); + } + + private bool IsExiledCompatFrameworkLoaded(Framework framework) + { + if (framework.Type == IDependOnFramework.Type.Callvote) // As of right now, Callvote-Exiled is not compatible with SER. + { + return false; + } + + if (PluginLoader.Plugins.Any(plg => plg.Key.Name == "Exiled Loader")) + { + return Exiled.Loader.Loader.Plugins.Any(plg => plg.Name == framework.Name); + } + + return false; } } \ No newline at end of file diff --git a/Code/Plugin/MainPlugin.cs b/Code/Plugin/MainPlugin.cs index 9a8dad4b..155c6476 100644 --- a/Code/Plugin/MainPlugin.cs +++ b/Code/Plugin/MainPlugin.cs @@ -112,7 +112,7 @@ public override void Enable() fBridge.Load(); SendLogo(); - Events.ServerEvents.WaitingForPlayers += () => OnServerFullyInit(fBridge); + Events.ServerEvents.WaitingForPlayers += OnServerFullyInit; Events.ServerEvents.RoundRestarted += Disable; Events.PlayerEvents.Joined += OnJoined; @@ -125,7 +125,7 @@ public override void Disable() SetPlayerDataMethod.PlayerData.Clear(); } - private void OnServerFullyInit(FrameworkBridge fBridge) + private void OnServerFullyInit() { if (Config?.SendInitMessage is false) return; @@ -137,7 +137,6 @@ private void OnServerFullyInit(FrameworkBridge fBridge) GitHub repository: {GitHubLink} Documentation: {DocsLink} Discord: {DiscordLink} - {fBridge.StopAndGetLoadedFrameworksMessage()} """, ConsoleColor.Cyan );