diff --git a/Minecraft.Server.FourKit/FourKit.cs b/Minecraft.Server.FourKit/FourKit.cs
index 2c3a11b7b..71ed26aa3 100644
--- a/Minecraft.Server.FourKit/FourKit.cs
+++ b/Minecraft.Server.FourKit/FourKit.cs
@@ -4,6 +4,7 @@ using Minecraft.Server.FourKit.Command;
using Minecraft.Server.FourKit.Entity;
using Minecraft.Server.FourKit.Event;
using Minecraft.Server.FourKit.Inventory;
+using Minecraft.Server.FourKit.Plugin;
public static class FourKit
{
@@ -351,4 +352,25 @@ public static class FourKit
{
return new Inventory.Inventory(title, type, type.getDefaultSize());
}
+
+ ///
+ /// Checks if the given plugin is loaded and returns it when applicable.
+ ///
+ /// Please note that the name of the plugin is case-sensitive.
+ ///
+ ///
+ /// Name of the plugin to check.
+ /// Plugin if it exists, otherwise null
+ public static ServerPlugin? getPlugin(string name) {
+ var loadedPlugins = Minecraft.Server.FourKit.FourKitHost.getLoadedPlugins().Where(x => x.name == name);
+
+ if (loadedPlugins.Count() > 1) ServerLog.Warn("fourkit", $"More than one instance of a(n) '{name}' plugin.");
+ return loadedPlugins.FirstOrDefault();
+ }
+
+ ///
+ /// Gets a list of all currently loaded plugins.
+ ///
+ /// The array of plugins.
+ public static ServerPlugin[] getPlugins() => Minecraft.Server.FourKit.FourKitHost.getLoadedPlugins().ToArray(); // returns an array for better compatibility for bukkit->fourkit
}
diff --git a/Minecraft.Server.FourKit/FourKitHost.cs b/Minecraft.Server.FourKit/FourKitHost.cs
index 72a55168c..613c6a564 100644
--- a/Minecraft.Server.FourKit/FourKitHost.cs
+++ b/Minecraft.Server.FourKit/FourKitHost.cs
@@ -9,6 +9,8 @@ public static partial class FourKitHost
{
private static PluginLoader? s_loader;
+ public static IReadOnlyList getLoadedPlugins() => s_loader?.Plugins ?? [];
+
[UnmanagedCallersOnly]
public static void Initialize()
{