From 4ee160552860e74c42a83c72637eaa4f128794a9 Mon Sep 17 00:00:00 2001 From: AlexProgrammerDE <40795980+AlexProgrammerDE@users.noreply.github.com> Date: Tue, 15 Oct 2024 19:50:08 +0200 Subject: [PATCH] Add print internal plugins command --- .../server/ServerCommandManager.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/server/src/main/java/com/soulfiremc/server/ServerCommandManager.java b/server/src/main/java/com/soulfiremc/server/ServerCommandManager.java index bf336015e..c7b987579 100644 --- a/server/src/main/java/com/soulfiremc/server/ServerCommandManager.java +++ b/server/src/main/java/com/soulfiremc/server/ServerCommandManager.java @@ -28,6 +28,8 @@ import com.soulfiremc.brigadier.CommandHelpWrapper; import com.soulfiremc.brigadier.PlatformCommandManager; import com.soulfiremc.brigadier.RedirectHelpWrapper; +import com.soulfiremc.server.api.InternalPlugin; +import com.soulfiremc.server.api.SoulFireAPI; import com.soulfiremc.server.api.event.EventUtil; import com.soulfiremc.server.api.event.bot.BotPreTickEvent; import com.soulfiremc.server.api.event.lifecycle.CommandManagerInitEvent; @@ -684,6 +686,24 @@ public void postConstruct() { } c.getSource().sendInfo(builder.toString()); + return Command.SINGLE_SUCCESS; + }))); + dispatcher.register( + literal("print-plugins") + .executes( + privateCommand( + c -> { + var builder = new StringBuilder("\n"); + for (var plugin : SoulFireAPI.getServerExtensions()) { + if (!(plugin instanceof InternalPlugin)) { + continue; + } + + var pluginInfo = plugin.pluginInfo(); + builder.append("| `%s` | `%s` | `%s` | `%s` | `%s` |\n".formatted(pluginInfo.id(), pluginInfo.version(), pluginInfo.author(), pluginInfo.license(), pluginInfo.description())); + } + c.getSource().sendInfo(builder.toString()); + return Command.SINGLE_SUCCESS; })));