Add PlayerPreLoginEvent (#8)

* PlayerPreLoginEvent, comments for more events

* basic plugin events

* plugin failed to load event

* add docs

---------

Co-authored-by: sylvessa <225480449+sylvessa@users.noreply.github.com>
This commit is contained in:
DrPerkyLegit 2026-03-29 13:56:24 -04:00 committed by GitHub
parent 33e0ecac56
commit da2aaf1247
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 241 additions and 4 deletions

View file

@ -1,3 +1,4 @@
using Minecraft.Server.FourKit.Event.Server;
using Minecraft.Server.FourKit.Plugin;
using System.Reflection;
@ -44,15 +45,30 @@ internal sealed class PluginLoader
if (mainDll != null)
{
try { LoadPluginAssembly(mainDll); }
catch (Exception ex) { ServerLog.Error("fourkit", $"Failed to load {Path.GetFileName(mainDll)}: {ex.Message}"); }
try
{
LoadPluginAssembly(mainDll);
}
catch (Exception ex)
{
ServerLog.Error("fourkit", $"Failed to load {Path.GetFileName(mainDll)}: {ex.Message}");
FourKit.FireEvent(new PluginLoadFailedEvent(mainDll, ex.Message));
}
}
else
{
foreach (var dll in allDlls)
{
try { LoadPluginAssembly(dll); }
catch (Exception ex) { ServerLog.Error("fourkit", $"Failed to load {Path.GetFileName(dll)}: {ex.Message}"); }
try
{
LoadPluginAssembly(dll);
}
catch (Exception ex)
{
ServerLog.Error("fourkit", $"Failed to load {Path.GetFileName(dll)}: {ex.Message}");
FourKit.FireEvent(new PluginLoadFailedEvent(dll, ex.Message));
}
}
}
}
@ -108,6 +124,8 @@ internal sealed class PluginLoader
InvokePluginMethod(plugin, "onEnable", "OnEnable");
string pName = GetPluginString(plugin, "name", "getName", "GetName", plugin.GetType().Name);
ServerLog.Info("fourkit", $"Enabled: {pName}");
FourKit.FireEvent(new PluginEnableEvent(plugin));
}
catch (Exception ex)
{
@ -126,6 +144,8 @@ internal sealed class PluginLoader
InvokePluginMethod(_plugins[i], "onDisable", "OnDisable");
string pName = GetPluginString(_plugins[i], "name", "getName", "GetName", _plugins[i].GetType().Name);
ServerLog.Info("fourkit", $"Disabled: {pName}");
FourKit.FireEvent(new PluginDisableEvent(_plugins[i]));
}
catch (Exception ex)
{