Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions Code/Helpers/FrameworkBridge.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LabApi.Loader;
using LabApi.Features.Console;
using LabApi.Loader;
using MEC;
using SER.Code.Extensions;
using SER.Code.MethodSystem;
Expand Down Expand Up @@ -27,7 +28,7 @@ public void Load()
_handles.Add(Timing.RunCoroutine(Await(framework)));
}
}

public string StopAndGetLoadedFrameworksMessage()
{
Timing.KillCoroutines(_handles.ToArray());
Expand All @@ -39,12 +40,39 @@ public string StopAndGetLoadedFrameworksMessage()

private IEnumerator<float> 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;
}
}
5 changes: 2 additions & 3 deletions Code/Plugin/MainPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -137,7 +137,6 @@ private void OnServerFullyInit(FrameworkBridge fBridge)
GitHub repository: {GitHubLink}
Documentation: {DocsLink}
Discord: {DiscordLink}
{fBridge.StopAndGetLoadedFrameworksMessage()}
""",
ConsoleColor.Cyan
);
Expand Down