Starting from MSLX v1.6.4, the SDK provides a global event bus via SDK.MSLX.Events. Plugins can use this to monitor the lifecycle of Minecraft servers, backup systems, scheduled tasks, FRP tunnels, and host daemons without modifying host code.
Memory Leak Prevention: MSLX plugins run in a separate AssemblyLoadContext. The host plugin manager automatically removes all event listeners registered by a plugin when it is unloaded, meaning developers do not need to manually unsubscribe from events in the plugin's lifecycle to prevent memory leaks.
using MSLX.SDK;
using MSLX.SDK.Events;
public class MyPlugin : IPlugin
{
public void OnLoad()
{
// Example: Listen for backup completion
SDK.MSLX.Events.OnBackupCompleted += (sender, e) =>
{
SDK.MSLX.Logger.Info($"[Backup Notification] Instance {e.InstanceId} completed: {e.BackupFileName}");
};
}
}