mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-18 10:13:51 +00:00
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:
parent
33e0ecac56
commit
da2aaf1247
12 changed files with 241 additions and 4 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue