Skip to content

Commit 5db923e

Browse files
committed
fix: make SER check for EXILED plugins
Added a helper function for checking for EXILED plugins. Removed FrameworkBridge::StopAndGetLoadedFrameworksMessage() from MainPlugin::OnServerFullyInit() Corrected MainPlugin::OnServerFullyInit() signature so it doesn't use FrameworkBridge anymore # Changes to FrameworkBridge::Await(Framework framework) assumes that coroutines are paused between server loading and after a while of WaitingForPlayers is triggered - Also reflects changes proposed in group chat
1 parent 1ead57a commit 5db923e

2 files changed

Lines changed: 37 additions & 10 deletions

File tree

Code/Helpers/FrameworkBridge.cs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using LabApi.Loader;
1+
using LabApi.Features.Console;
2+
using LabApi.Loader;
23
using MEC;
34
using SER.Code.Extensions;
45
using SER.Code.MethodSystem;
@@ -27,7 +28,7 @@ public void Load()
2728
_handles.Add(Timing.RunCoroutine(Await(framework)));
2829
}
2930
}
30-
31+
3132
public string StopAndGetLoadedFrameworksMessage()
3233
{
3334
Timing.KillCoroutines(_handles.ToArray());
@@ -39,12 +40,39 @@ public string StopAndGetLoadedFrameworksMessage()
3940

4041
private IEnumerator<float> Await(Framework framework)
4142
{
42-
while (PluginLoader.EnabledPlugins.All(plg => plg.Name != framework.Name))
43+
for (int timer = 0; timer <= 3; timer++)
4344
{
44-
yield return Timing.WaitForSeconds(0.1f);
45+
yield return Timing.WaitForSeconds(1f);
46+
47+
if (_found.Contains(framework))
48+
{
49+
continue;
50+
}
51+
52+
if (PluginLoader.EnabledPlugins.All(plg => plg.Name != framework.Name) && !IsExiledCompatFrameworkLoaded(framework))
53+
{
54+
continue;
55+
}
56+
57+
_found.Add(framework);
58+
MethodIndex.LoadMethodsOfFramework(framework.Type);
4559
}
46-
47-
_found.Add(framework);
48-
MethodIndex.LoadMethodsOfFramework(framework.Type);
60+
61+
Logger.Raw(StopAndGetLoadedFrameworksMessage(), ConsoleColor.DarkYellow);
62+
}
63+
64+
private bool IsExiledCompatFrameworkLoaded(Framework framework)
65+
{
66+
if (framework.Type == IDependOnFramework.Type.Callvote) // As of right now, Callvote-Exiled is not compatible with SER.
67+
{
68+
return false;
69+
}
70+
71+
if (PluginLoader.Plugins.Any(plg => plg.Key.Name == "Exiled Loader"))
72+
{
73+
return Exiled.Loader.Loader.Plugins.Any(plg => plg.Name == framework.Name);
74+
}
75+
76+
return false;
4977
}
5078
}

Code/Plugin/MainPlugin.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public override void Enable()
112112
fBridge.Load();
113113
SendLogo();
114114

115-
Events.ServerEvents.WaitingForPlayers += () => OnServerFullyInit(fBridge);
115+
Events.ServerEvents.WaitingForPlayers += OnServerFullyInit;
116116
Events.ServerEvents.RoundRestarted += Disable;
117117
Events.PlayerEvents.Joined += OnJoined;
118118

@@ -125,7 +125,7 @@ public override void Disable()
125125
SetPlayerDataMethod.PlayerData.Clear();
126126
}
127127

128-
private void OnServerFullyInit(FrameworkBridge fBridge)
128+
private void OnServerFullyInit()
129129
{
130130
if (Config?.SendInitMessage is false) return;
131131

@@ -137,7 +137,6 @@ private void OnServerFullyInit(FrameworkBridge fBridge)
137137
GitHub repository: {GitHubLink}
138138
Documentation: {DocsLink}
139139
Discord: {DiscordLink}
140-
{fBridge.StopAndGetLoadedFrameworksMessage()}
141140
""",
142141
ConsoleColor.Cyan
143142
);

0 commit comments

Comments
 (0)