From 3648989f2633e22302ac8d5a91bc14f6824212b8 Mon Sep 17 00:00:00 2001
From: Daniel Liland <3050747+Celsiusss@users.noreply.github.com>
Date: Thu, 7 Aug 2025 10:48:40 +0200
Subject: [PATCH] add plugins loaded event (#830)
---
MCGalaxy/Events/ServerEvents.cs | 9 +++++++++
MCGalaxy/Server/Server.Init.cs | 7 ++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/MCGalaxy/Events/ServerEvents.cs b/MCGalaxy/Events/ServerEvents.cs
index 1280bb777..d3918c40c 100644
--- a/MCGalaxy/Events/ServerEvents.cs
+++ b/MCGalaxy/Events/ServerEvents.cs
@@ -126,4 +126,13 @@ namespace MCGalaxy.Events.ServerEvents
CallCommon(pl => pl(p, channel, data));
}
}
+
+ public delegate void OnPluginsLoaded();
+ /// Called when all plugins have been auto-loaded.
+ public sealed class OnPluginsLoadedEvent : IEvent {
+ public static void Call() {
+ if (handlers.Count == 0) return;
+ CallCommon(pl => pl());
+ }
+ }
}
diff --git a/MCGalaxy/Server/Server.Init.cs b/MCGalaxy/Server/Server.Init.cs
index 5b0eb4946..e8aaa6033 100644
--- a/MCGalaxy/Server/Server.Init.cs
+++ b/MCGalaxy/Server/Server.Init.cs
@@ -19,6 +19,7 @@ using System;
using System.Collections.Generic;
using System.Net;
using MCGalaxy.DB;
+using MCGalaxy.Events.ServerEvents;
using MCGalaxy.Generator;
using MCGalaxy.Network;
using MCGalaxy.Tasks;
@@ -46,7 +47,11 @@ namespace MCGalaxy
LevelInfo.Add(mainLevel);
}
- static void LoadAllPlugins(SchedulerTask task) { Plugin.LoadAll(); }
+ static void LoadAllPlugins(SchedulerTask task)
+ {
+ Plugin.LoadAll();
+ OnPluginsLoadedEvent.Call();
+ }
static void InitPlayerLists(SchedulerTask task) {
try {